Adding reminder
[squirrelmail.git] / plugins / fortune / setup.php
CommitLineData
9b5edd1d 1<?php
2
3/**
4 * plugins/fortune/setup.php
5 *
9b5edd1d 6 * Original code contributed by paulm@spider.org
7 *
8 * Simple SquirrelMail WebMail Plugin that displays the output of
9 * fortune above the message listing.
10 *
0fe5da50 11 * @copyright (c) 1999-2004 The SquirrelMail Project Team
12 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 * @version $Id$
ea5f4b8e 14 * @package plugins
15 * @subpackage fortune
7413ef70 16 *
17 * FIXME
18 * There should be no code in setup.php, just hook registrations. Create functions.php
19 * and move the code there.
9b5edd1d 20 */
21
ea5f4b8e 22/**
0fe5da50 23 * Init plugin
7413ef70 24 * @access private
0fe5da50 25 */
9b5edd1d 26function squirrelmail_plugin_init_fortune() {
27 global $squirrelmail_plugin_hooks;
7413ef70 28
9b5edd1d 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';
7413ef70 32 $squirrelmail_plugin_hooks['loading_prefs']['fortune'] = 'fortune_load';
9b5edd1d 33}
34
0fe5da50 35/**
36 * Show fortune
7413ef70 37 * @access private
0fe5da50 38 */
9b5edd1d 39function fortune() {
40 global $fortune_visible, $color;
41
42 if (!$fortune_visible) {
43 return;
44 }
45
46 $fortune_location = '/usr/games/fortune';
ecaf45ec 47 $exist = file_exists($fortune_location);
a9e1e670 48 echo "<center><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"$color[10]\">\n".
7413ef70 49 "<tr><td><table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\" bgcolor=\"$color[5]\">\n".
50 "<tr><td align=\"center\">\n";
a9e1e670 51 echo '<table><tr><td>';
9b5edd1d 52 if (!$exist) {
75d3419e 53 echo "$fortune_location" . _(" not found.");
9b5edd1d 54 } else {
6fd95361 55 echo "<center><em>" . _("Today's Fortune") . "</em><br /></font></center><pre>";
a9e1e670 56 htmlspecialchars(system($fortune_location));
7413ef70 57 }
58
a9e1e670 59 echo '</pre></td></tr></table></td></tr></table></td></tr></table></center>';
9b5edd1d 60}
61
0fe5da50 62/**
63 * Get fortune prefs
7413ef70 64 * @access private
0fe5da50 65 */
9b5edd1d 66function fortune_load() {
67 global $username, $data_dir, $fortune_visible;
68
69 $fortune_visible = getPref($data_dir, $username, 'fortune_visible');
70}
71
0fe5da50 72/**
73 * Add fortune options
7413ef70 74 * @access private
0fe5da50 75 */
9b5edd1d 76function fortune_options() {
7413ef70 77 global $fortune_visible;
9b5edd1d 78
7413ef70 79 echo "<tr>" . html_tag('td',_("Fortunes:"),'right','','nowrap') . "\n";
80 echo '<td><input name="fortune_fortune_visible" type="checkbox"';
81 if ($fortune_visible)
82 echo ' checked="checked"';
83 echo " /> " . _("Show fortunes at top of mailbox") . "</td></tr>\n";
9b5edd1d 84}
85
0fe5da50 86/**
87 * Save fortune prefs
7413ef70 88 * @access private
0fe5da50 89 */
9b5edd1d 90function fortune_save() {
91 global $username,$data_dir;
9b5edd1d 92
a8a3b441 93 if (sqgetGlobalVar('fortune_fortune_visible',$fortune_fortune_visible,SQ_POST)) {
9b5edd1d 94 setPref($data_dir, $username, 'fortune_visible', '1');
95 } else {
96 setPref($data_dir, $username, 'fortune_visible', '');
97 }
98}
99
7413ef70 100?>