$ cd plugins
$ tar -zxvf /usr/archives/fortune_plugin.tar.gz
-You may have to edit plugins/fortune/setup.php and change the location
-of fortune on your system. Simply modify the $fortune_location variable
-This script was written on RedHat 6.2 as such fortune is expected in
-/usr/games/fortune also if safe mode is enabled your going to have to
-copy fortune into your safe_mode bin directory.
-
Then go to your config directory and run conf.pl. Choose option
8 and add the plugin (+). Save and exit, then that should be all
if the plugin was made correctly. :)
$ cd ../config
$ ./conf.pl
+
+Configuration is stored in config/fortune_config.php or
+plugins/fortune/config.php. System won't load plugins/fortune/config.php,
+if config/fortune_config.php is present. Default configuration values
+are stored in plugins/fortune/config_default.php.
--- /dev/null
+Simple SquirrelMail plugin that displays the quotes above the message listing.
+
+Original code contributed by paulm@spider.org
+
+Plugin requires /usr/games/fortune or any other similar program, that outputs
+short text messages. If you are running php in safe_mode, path to program must
+be present in php safe_mode_exec_dir setting. If you are running chrooted
+webserver, program must be present inside of your chroot jail.
+
+Plugin can be configured with config/fortune_config.php or
+plugins/fortune/config.php files.
--- /dev/null
+<?php
+/**
+ * Default Fortune plugin configuration
+ *
+ * Configuration defaults to /usr/games/fortune with short quotes
+ *
+ * @copyright (c) 2004 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package plugins
+ * @subpackage fortune
+ */
+
+/**
+ * program that displays quotes
+ * @global string $fortune_location
+ */
+$fortune_location = '/usr/games/fortune';
+
+/**
+ * options that have to be passed to program
+ * @global string $fortune_options
+ * @since 1.5.1
+ */
+$fortune_options = '-s';
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Fortune plugin functions
+ *
+ * @copyright (c) 2004 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package plugins
+ * @subpackage fortune
+ */
+
+/**
+ * Declare configuration globals
+ */
+global $fortune_location, $fortune_options;
+
+/**
+ * Load default config
+ */
+include_once(SM_PATH . 'plugins/fortune/config_default.php');
+
+/**
+ * Load site config
+ */
+if (file_exists(SM_PATH . 'config/fortune_config.php')) {
+ include_once(SM_PATH . 'config/fortune_config.php');
+} elseif (file_exists(SM_PATH . 'plugins/fortune/config.php')) {
+ include_once(SM_PATH . 'plugins/fortune/config.php');
+}
+
+/**
+ * Show fortune
+ * @access private
+ * @since 1.5.1
+ */
+function fortune_function() {
+ global $fortune_visible, $color, $fortune_location, $fortune_options;
+
+ if (!$fortune_visible) {
+ return;
+ }
+
+ $exist = file_exists($fortune_location);
+
+ if ($fortune_options!='') {
+ $fortune_command=$fortune_location . ' ' . $fortune_options;
+ } else {
+ $fortune_command=$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 sprintf(_("%s is not found."),$fortune_location);
+ } else {
+ echo "<center><em>" . _("Today's Fortune") . "</em></center><pre>\n";
+ htmlspecialchars(system($fortune_command));
+ echo "</pre>\n";
+ }
+
+ echo '</td></tr></table></td></tr></table></td></tr></table></center>';
+}
+
+/**
+ * Add fortune options
+ * @access private
+ * @since 1.5.1
+ */
+function fortune_function_options() {
+ global $optpage_data;
+
+ $optpage_data['grps']['fortune'] = _("Fortunes:");
+ $optionValues = array();
+ $optionValues[] = array('name' => 'fortune_visible',
+ 'caption' => _("Show fortunes at top of mailbox"),
+ 'type' => SMOPT_TYPE_BOOLEAN,
+ 'initial_value' => false );
+ $optpage_data['vals']['fortune'] = $optionValues;
+}
+
+/**
+ * Get fortune prefs
+ * @access private
+ * @since 1.5.1
+ */
+function fortune_function_load() {
+ global $username, $data_dir, $fortune_visible;
+
+ $fortune_visible = getPref($data_dir, $username, 'fortune_visible');
+}
+?>
\ No newline at end of file
<?php
-
/**
- * plugins/fortune/setup.php
- *
- * Original code contributed by paulm@spider.org
- *
- * Simple SquirrelMail WebMail Plugin that displays the output of
- * fortune above the message listing.
+ * Fortune plugin setup script
*
* @copyright (c) 1999-2004 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package plugins
* @subpackage fortune
- *
- * FIXME
- * There should be no code in setup.php, just hook registrations. Create functions.php
- * and move the code there.
*/
/**
- * 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
+ * Init plugin
* @access private
*/
-function fortune() {
- global $fortune_visible, $color;
-
- if (!$fortune_visible) {
- return;
- }
-
- $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));
- }
+function squirrelmail_plugin_init_fortune() {
+ global $squirrelmail_plugin_hooks;
- 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
+ * 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
+ * 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="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
+ * 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