This commit adds the hability to add a special folder through the hook
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 31 Jan 2002 16:53:54 +0000 (16:53 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 31 Jan 2002 16:53:54 +0000 (16:53 +0000)
'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
functions/plugin.php
plugins/administrator/defines.php
plugins/filters/setup.php

index 375b97b..f6fafd9 100755 (executable)
@@ -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 );
 
 }
index 3ce547c..9ef6d7f 100644 (file)
@@ -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;
 }
 
 /*************************************/
index f61d376..677e586 100644 (file)
@@ -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 ),
index 2557f40..c8f5749 100644 (file)
       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() {