From 2586d588585b8f4a346b38dc3d42567e15fb6cc2 Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Thu, 31 Jan 2002 16:53:54 +0000 Subject: [PATCH] This commit adds the hability to add a special folder through the hook 'special_mailbox'. As an example I added the spam mailbox. Please, someone with docs skills at this to the docs 8-) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2324 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_mailbox.php | 4 ++++ functions/plugin.php | 7 ++++--- plugins/administrator/defines.php | 6 ++++-- plugins/filters/setup.php | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 375b97bf..f6fafd93 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -50,6 +50,10 @@ function isSpecialMailbox( $box ) { ( $move_to_sent && isBoxBelow( $box, $sent_folder )) || ($save_as_draft && $box == $draft_folder ) ); + if ( !$ret ) { + $ret = do_hook( 'special_mailbox', $box ); + } + return( $ret ); } diff --git a/functions/plugin.php b/functions/plugin.php index 3ce547ca..9ef6d7f5 100644 --- a/functions/plugin.php +++ b/functions/plugin.php @@ -28,23 +28,24 @@ function use_plugin ($name) { } /* This function executes a hook. */ -function do_hook ($name) { +function do_hook ($name,$parm=NULL) { global $squirrelmail_plugin_hooks; $data = func_get_args(); + $ret = ''; if (isset($squirrelmail_plugin_hooks[$name]) && is_array($squirrelmail_plugin_hooks[$name])) { foreach ($squirrelmail_plugin_hooks[$name] as $function) { /* Add something to set correct gettext domain for plugin. */ if (function_exists($function)) { - $function($data); + $ret = $function($data,$parm); } } } /* Variable-length argument lists have a slight problem when */ /* passing values by reference. Pity. This is a workaround. */ - return $data; + return $ret; } /*************************************/ diff --git a/plugins/administrator/defines.php b/plugins/administrator/defines.php index f61d3769..677e5862 100644 --- a/plugins/administrator/defines.php +++ b/plugins/administrator/defines.php @@ -90,7 +90,8 @@ $defcfg = array( '$config_version' => array( 'name' => _("Config File Version"), '$optional_delimiter' => array( 'name' => _("IMAP Folder Delimiter"), 'type' => SMOPT_TYPE_STRING, 'comment' => _("Use \"detect\" to auto-detect."), - 'size' => 10 ), + 'size' => 10, + 'default' => 'detect' ), '$useSendmail' => array( 'name' => _("Use Sendmail"), 'type' => SMOPT_TYPE_BOOLEAN ), '$sendmail_path' => array( 'name' => _("Sendmail Path"), @@ -196,7 +197,8 @@ $defcfg = array( '$config_version' => array( 'name' => _("Config File Version"), 'size' => 40 ), '$addrbook_table' => array( 'name' => _("Address book table"), 'type' => SMOPT_TYPE_STRING, - 'size' => 40 ), + 'size' => 40, + 'default' => 'address' ), /* --------------------------------------------------------*/ 'Group7' => array( 'name' => _("Themes"), 'type' => SMOPT_TYPE_TITLE ), diff --git a/plugins/filters/setup.php b/plugins/filters/setup.php index 2557f409..c8f5749c 100644 --- a/plugins/filters/setup.php +++ b/plugins/filters/setup.php @@ -65,9 +65,20 @@ global $mailbox, $imap_stream, $imapConnection; $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters'; - if ($mailbox == 'INBOX') - $squirrelmail_plugin_hooks["right_main_after_header"]['filters'] = 'start_filters'; + if ($mailbox == 'INBOX') { + $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters'; + } $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'squirrelmail_plugin_optpage_register_block'; + $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox'; + } + + function filters_special_mailbox( $data, $mb ) { + + if ( $mb == getPref($data_dir, $username, 'filters_spam_folder', 'na' ) ) { + return( TRUE ); + } else { + return( FALSE ); + } } function squirrelmail_plugin_optpage_register_block() { -- 2.25.1