setup.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * plugins/fortune/setup.php
  4. *
  5. * Original code contributed by paulm@spider.org
  6. *
  7. * Simple SquirrelMail WebMail Plugin that displays the output of
  8. * fortune above the message listing.
  9. *
  10. * @copyright (c) 1999-2004 The SquirrelMail Project Team
  11. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  12. * @version $Id$
  13. * @package plugins
  14. * @subpackage fortune
  15. */
  16. /**
  17. * Init plugin
  18. * @access private
  19. */
  20. function squirrelmail_plugin_init_fortune() {
  21. global $squirrelmail_plugin_hooks;
  22. $squirrelmail_plugin_hooks['mailbox_index_before']['fortune'] = 'fortune';
  23. $squirrelmail_plugin_hooks['options_display_inside']['fortune'] = 'fortune_options';
  24. $squirrelmail_plugin_hooks['options_display_save']['fortune'] = 'fortune_save';
  25. $squirrelmail_plugin_hooks['loading_prefs']['fortune'] = 'fortune_load';
  26. }
  27. /**
  28. * Show fortune
  29. * @access private
  30. */
  31. function fortune() {
  32. global $fortune_visible, $color;
  33. if (!$fortune_visible) {
  34. return;
  35. }
  36. $fortune_location = '/usr/games/fortune';
  37. $exist = file_exists($fortune_location);
  38. echo "<center><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"$color[10]\">\n".
  39. "<tr><td><table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\" bgcolor=\"$color[5]\">\n".
  40. "<tr><td align=\"center\">\n";
  41. echo '<table><tr><td>';
  42. if (!$exist) {
  43. echo "$fortune_location" . _(" not found.");
  44. } else {
  45. echo "<center><em>" . _("Today's Fortune") . "</em><br></font></center><pre>";
  46. htmlspecialchars(system($fortune_location));
  47. }
  48. echo '</pre></td></tr></table></td></tr></table></td></tr></table></center>';
  49. }
  50. /**
  51. * Get fortune prefs
  52. * @access private
  53. */
  54. function fortune_load() {
  55. global $username, $data_dir, $fortune_visible;
  56. $fortune_visible = getPref($data_dir, $username, 'fortune_visible');
  57. }
  58. /**
  59. * Add fortune options
  60. * @access private
  61. */
  62. function fortune_options() {
  63. global $fortune_visible;
  64. echo "<tr>" . html_tag('td',_("Fortunes:"),'right','','nowrap') . "\n";
  65. echo '<td><input name="fortune_fortune_visible" type=CHECKBOX';
  66. if ($fortune_visible)
  67. echo ' CHECKED';
  68. echo " /> " . _("Show fortunes at top of mailbox") . "</td></tr>\n";
  69. }
  70. /**
  71. * Save fortune prefs
  72. * @access private
  73. */
  74. function fortune_save() {
  75. global $username,$data_dir;
  76. if (sqgetGlobalVar('fortune_fortune_visible',$fortune_fortune_visible,SQ_POST)) {
  77. setPref($data_dir, $username, 'fortune_visible', '1');
  78. } else {
  79. setPref($data_dir, $username, 'fortune_visible', '');
  80. }
  81. }
  82. ?>