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
22 function squirrelmail_plugin_init_fortune() {
23 global $squirrelmail_plugin_hooks;
25 $squirrelmail_plugin_hooks['mailbox_index_before']['fortune'] = 'fortune';
26 $squirrelmail_plugin_hooks['options_display_inside']['fortune'] = 'fortune_options';
27 $squirrelmail_plugin_hooks['options_display_save']['fortune'] = 'fortune_save';
28 $squirrelmail_plugin_hooks['loading_prefs']['fortune'] = 'fortune_load';
36 global $fortune_visible, $color;
38 if (!$fortune_visible) {
42 $fortune_location = '/usr/games/fortune';
43 $exist = file_exists($fortune_location);
44 echo "<center><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"$color[10]\">\n".
45 "<tr><td><table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\" bgcolor=\"$color[5]\">\n".
46 "<tr><td align=\"center\">\n";
47 echo '<table><tr><td>';
49 echo "$fortune_location" . _(" not found.");
51 echo "<center><em>" . _("Today's Fortune") . "</em><br /></font></center><pre>";
52 htmlspecialchars(system($fortune_location));
55 echo '</pre></td></tr></table></td></tr></table></td></tr></table></center>';
62 function fortune_load() {
63 global $username, $data_dir, $fortune_visible;
65 $fortune_visible = getPref($data_dir, $username, 'fortune_visible');
72 function fortune_options() {
73 global $fortune_visible;
75 echo "<tr>" . html_tag('td',_("Fortunes:"),'right','','nowrap') . "\n";
76 echo '<td><input name="fortune_fortune_visible" type="checkbox"';
78 echo ' checked="checked"';
79 echo " /> " . _("Show fortunes at top of mailbox") . "</td></tr>\n";
86 function fortune_save() {
87 global $username,$data_dir;
89 if (sqgetGlobalVar('fortune_fortune_visible',$fortune_fortune_visible,SQ_POST
)) {
90 setPref($data_dir, $username, 'fortune_visible', '1');
92 setPref($data_dir, $username, 'fortune_visible', '');