4 * plugins/fortune/setup.php
6 * Original code contributed by paulm@spider.org
8 * Simple SquirrelMail WebMail Plugin that displays the output of
9 * fortune above the message listing.
11 * @copyright (c) 1999-2004 The SquirrelMail Project Team
12 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
18 * There should be no code in setup.php, just hook registrations. Create functions.php
19 * and move the code there.
26 function squirrelmail_plugin_init_fortune() {
27 global $squirrelmail_plugin_hooks;
29 $squirrelmail_plugin_hooks['mailbox_index_before']['fortune'] = 'fortune';
30 $squirrelmail_plugin_hooks['options_display_inside']['fortune'] = 'fortune_options';
31 $squirrelmail_plugin_hooks['options_display_save']['fortune'] = 'fortune_save';
32 $squirrelmail_plugin_hooks['loading_prefs']['fortune'] = 'fortune_load';
40 global $fortune_visible, $color;
42 if (!$fortune_visible) {
46 $fortune_location = '/usr/games/fortune';
47 $exist = file_exists($fortune_location);
48 echo "<center><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"$color[10]\">\n".
49 "<tr><td><table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\" bgcolor=\"$color[5]\">\n".
50 "<tr><td align=\"center\">\n";
51 echo '<table><tr><td>';
53 echo "$fortune_location" . _(" not found.");
55 echo "<center><em>" . _("Today's Fortune") . "</em><br /></font></center><pre>";
56 htmlspecialchars(system($fortune_location));
59 echo '</pre></td></tr></table></td></tr></table></td></tr></table></center>';
66 function fortune_load() {
67 global $username, $data_dir, $fortune_visible;
69 $fortune_visible = getPref($data_dir, $username, 'fortune_visible');
76 function fortune_options() {
77 global $fortune_visible;
79 echo "<tr>" . html_tag('td',_("Fortunes:"),'right','','nowrap') . "\n";
80 echo '<td><input name="fortune_fortune_visible" type="checkbox"';
82 echo ' checked="checked"';
83 echo " /> " . _("Show fortunes at top of mailbox") . "</td></tr>\n";
90 function fortune_save() {
91 global $username,$data_dir;
93 if (sqgetGlobalVar('fortune_fortune_visible',$fortune_fortune_visible,SQ_POST
)) {
94 setPref($data_dir, $username, 'fortune_visible', '1');
96 setPref($data_dir, $username, 'fortune_visible', '');