phpDocumentor updates
[squirrelmail.git] / plugins / fortune / setup.php
index dbdc7b109853f30650bddcb04eeeae6c1e908f75..589daaf9c7b667b13357d2d64cce4c805def74a7 100644 (file)
@@ -1,14 +1,9 @@
 <?php
 
 /**
- * plugins/fortune/setup.php
+ * Fortune plugin setup script
  *
- * Original code contributed by paulm@spider.org
- *
- * Simple SquirrelMail WebMail Plugin that displays the output of
- * fortune above the message listing.
- *
- * @copyright (c) 1999-2004 The SquirrelMail Project Team
+ * @copyright &copy; 1999-2005 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
  */
 
 /**
- * Init plugin
- * @access private 
+ * If SM_PATH isn't defined, define it.
+ * @ignore
  */
-function squirrelmail_plugin_init_fortune() {
-  global $squirrelmail_plugin_hooks;
-  
-  $squirrelmail_plugin_hooks['mailbox_index_before']['fortune'] = 'fortune';
-  $squirrelmail_plugin_hooks['options_display_inside']['fortune'] = 'fortune_options';
-  $squirrelmail_plugin_hooks['options_display_save']['fortune'] = 'fortune_save';
-  $squirrelmail_plugin_hooks['loading_prefs']['fortune'] = 'fortune_load';  
+if (!defined('SM_PATH'))  {
+    define('SM_PATH','../../');
 }
 
 /**
- * Show fortune
- * @access private 
+ * Init plugin
+ * @access private
  */
-function fortune() {
-    global $fortune_visible, $color;
-
-    if (!$fortune_visible) {
-        return;
-    }
+function squirrelmail_plugin_init_fortune() {
+    global $squirrelmail_plugin_hooks;
 
-    $fortune_location = '/usr/games/fortune';
-    $exist = file_exists($fortune_location);
-    echo "<center><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"$color[10]\">\n".
-         "<tr><td><table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\" bgcolor=\"$color[5]\">\n".
-        "<tr><td align=\"center\">\n";
-    echo '<table><tr><td>';
-    if (!$exist) {
-        echo "$fortune_location" . _(" not found.");
-    } else {
-        echo "<center><em>" . _("Today's Fortune") . "</em><br></font></center><pre>";
-        htmlspecialchars(system($fortune_location));
-    } 
-  
-    echo '</pre></td></tr></table></td></tr></table></td></tr></table></center>';
+    $squirrelmail_plugin_hooks['mailbox_index_before']['fortune'] = 'fortune';
+    $squirrelmail_plugin_hooks['loading_prefs']['fortune'] = 'fortune_load';
+    $squirrelmail_plugin_hooks['optpage_loadhook_display']['fortune'] = 'fortune_options';
 }
 
 /**
- * Get fortune prefs
- * @access private 
+ * Call fortune display function
+ * @access private
  */
-function fortune_load() {
-    global $username, $data_dir, $fortune_visible;
-
-    $fortune_visible = getPref($data_dir, $username, 'fortune_visible');
+function fortune() {
+    include_once(SM_PATH . 'plugins/fortune/functions.php');
+    fortune_function();
 }
 
 /**
- * Add fortune options
- * @access private 
+ * Call fortune option display function
+ * @access private
  */
 function fortune_options() {
-  global $fortune_visible;
-
-  echo "<tr>" . html_tag('td',_("Fortunes:"),'right','','nowrap') . "\n";
-  echo '<td><input name="fortune_fortune_visible" type=CHECKBOX';
-  if ($fortune_visible)
-    echo ' CHECKED';
-  echo " /> " . _("Show fortunes at top of mailbox") . "</td></tr>\n";
+    include_once(SM_PATH . 'plugins/fortune/functions.php');
+    fortune_function_options();
 }
 
 /**
- * Save fortune prefs
- * @access private 
+ * Call fortune prefs load function
+ * @access private
  */
-function fortune_save() {
-    global $username,$data_dir;
-
-    if (sqgetGlobalVar('fortune_fortune_visible',$fortune_fortune_visible,SQ_POST)) {
-        setPref($data_dir, $username, 'fortune_visible', '1');
-    } else {
-        setPref($data_dir, $username, 'fortune_visible', '');
-    }
+function fortune_load() {
+    include_once(SM_PATH . 'plugins/fortune/functions.php');
+    fortune_function_load();
 }
-
-?>
+?>
\ No newline at end of file