From 28e62e6d76cf414fbdaa1dd02eae4344d11ab2d6 Mon Sep 17 00:00:00 2001 From: tokul Date: Fri, 1 Oct 2004 18:39:39 +0000 Subject: [PATCH] moving functions to separate file, adding configuration files git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@8110 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/fortune/INSTALL | 11 ++-- plugins/fortune/README | 11 ++++ plugins/fortune/config_default.php | 26 +++++++++ plugins/fortune/functions.php | 93 ++++++++++++++++++++++++++++++ plugins/fortune/setup.php | 88 ++++++++-------------------- 5 files changed, 158 insertions(+), 71 deletions(-) create mode 100644 plugins/fortune/README create mode 100644 plugins/fortune/config_default.php create mode 100644 plugins/fortune/functions.php diff --git a/plugins/fortune/INSTALL b/plugins/fortune/INSTALL index 3f158175..11450a78 100644 --- a/plugins/fortune/INSTALL +++ b/plugins/fortune/INSTALL @@ -8,15 +8,14 @@ directory: $ 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. diff --git a/plugins/fortune/README b/plugins/fortune/README new file mode 100644 index 00000000..0bf1f7b7 --- /dev/null +++ b/plugins/fortune/README @@ -0,0 +1,11 @@ +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. diff --git a/plugins/fortune/config_default.php b/plugins/fortune/config_default.php new file mode 100644 index 00000000..7c701907 --- /dev/null +++ b/plugins/fortune/config_default.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/plugins/fortune/functions.php b/plugins/fortune/functions.php new file mode 100644 index 00000000..5e98f066 --- /dev/null +++ b/plugins/fortune/functions.php @@ -0,0 +1,93 @@ +\n". + "
\n". + "
\n"; + echo '
'; + if (!$exist) { + echo sprintf(_("%s is not found."),$fortune_location); + } else { + echo "
" . _("Today's Fortune") . "
\n";
+        htmlspecialchars(system($fortune_command));
+        echo "
\n"; + } + + echo '
'; +} + +/** + * 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 diff --git a/plugins/fortune/setup.php b/plugins/fortune/setup.php index 8e4e93c9..0dca671e 100644 --- a/plugins/fortune/setup.php +++ b/plugins/fortune/setup.php @@ -1,100 +1,58 @@ \n". - "
\n". - "
\n"; - echo '
'; - if (!$exist) { - echo "$fortune_location" . _(" not found."); - } else { - echo "
" . _("Today's Fortune") . "
";
-        htmlspecialchars(system($fortune_location));
-    }
+function squirrelmail_plugin_init_fortune() {
+    global $squirrelmail_plugin_hooks;
 
-    echo '
'; + $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 "" . html_tag('td',_("Fortunes:"),'right','','nowrap') . "\n"; - echo ' " . _("Show fortunes at top of mailbox") . "\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 -- 2.25.1