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 375b97bfee4262691b5e23d3750cf131d60af45e..f6fafd930aa5da34952e0a42b02de25072b498b5 100755 (executable)
@@ -50,6 +50,10 @@ function isSpecialMailbox( $box ) {
              ( $move_to_sent && isBoxBelow( $box, $sent_folder )) ||
              ($save_as_draft && $box == $draft_folder ) );
 
              ( $move_to_sent && isBoxBelow( $box, $sent_folder )) ||
              ($save_as_draft && $box == $draft_folder ) );
 
+    if ( !$ret ) {
+        $ret = do_hook( 'special_mailbox', $box );
+    }
+
     return( $ret );
 
 }
     return( $ret );
 
 }
index 3ce547ca38ce8e4b52144274a8bc05fe947f2dc6..9ef6d7f5e5c5994b9a5c0166be3df4bfc43b2897 100644 (file)
@@ -28,23 +28,24 @@ function use_plugin ($name) {
 }
 
 /* This function executes a hook. */
 }
 
 /* This function executes a hook. */
-function do_hook ($name) {
+function do_hook ($name,$parm=NULL) {
     global $squirrelmail_plugin_hooks;
     $data = func_get_args();
     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)) {
 
     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.  */
             }
         }
     }
 
     /* Variable-length argument lists have a slight problem when */
     /* passing values by reference. Pity. This is a workaround.  */
-    return $data;
+    return $ret;
 }
 
 /*************************************/
 }
 
 /*************************************/
index f61d3769eb57faac05ad237384e03d5af16e512c..677e58627977fcf74207636b3ef63e4f06fc2fea 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."),
                  '$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"),
                  '$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 ), 
                  '$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 ),
                  /* --------------------------------------------------------*/
                  'Group7' => array( 'name' => _("Themes"),
                                     'type' => SMOPT_TYPE_TITLE ),
index 2557f409adb774244efb742e01cc1204273a690a..c8f5749ce7f2beab6646a79f75bdd3d106b5ce3d 100644 (file)
       global $mailbox, $imap_stream, $imapConnection;
 
       $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters';
       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['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() {
    }
 
    function squirrelmail_plugin_optpage_register_block() {