Source for file setup.php

Documentation is available at setup.php

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

Documentation generated on Sat, 07 Oct 2006 16:33:29 +0300 by phpDocumentor 1.3.0RC6