Browse Source

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-)

philippe_mingo 23 years ago
parent
commit
37c3e89856

+ 4 - 0
functions/imap_mailbox.php

@@ -50,6 +50,10 @@ function isSpecialMailbox( $box ) {
              ( $move_to_sent && isBoxBelow( $box, $sent_folder )) ||
              ( $move_to_sent && isBoxBelow( $box, $sent_folder )) ||
              ($save_as_draft && $box == $draft_folder ) );
              ($save_as_draft && $box == $draft_folder ) );
 
 
+    if ( !$ret ) {
+        $ret = do_hook( 'special_mailbox', $box );
+    }
+
     return( $ret );
     return( $ret );
 
 
 }
 }

+ 4 - 3
functions/plugin.php

@@ -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;
     global $squirrelmail_plugin_hooks;
     $data = func_get_args();
     $data = func_get_args();
+    $ret = '';
 
 
     if (isset($squirrelmail_plugin_hooks[$name])
     if (isset($squirrelmail_plugin_hooks[$name])
           && is_array($squirrelmail_plugin_hooks[$name])) {
           && is_array($squirrelmail_plugin_hooks[$name])) {
         foreach ($squirrelmail_plugin_hooks[$name] as $function) {
         foreach ($squirrelmail_plugin_hooks[$name] as $function) {
             /* Add something to set correct gettext domain for plugin. */
             /* Add something to set correct gettext domain for plugin. */
             if (function_exists($function)) {
             if (function_exists($function)) {
-                $function($data);
+                $ret = $function($data,$parm);
             }
             }
         }
         }
     }
     }
 
 
     /* Variable-length argument lists have a slight problem when */
     /* Variable-length argument lists have a slight problem when */
     /* passing values by reference. Pity. This is a workaround.  */
     /* passing values by reference. Pity. This is a workaround.  */
-    return $data;
+    return $ret;
 }
 }
 
 
 /*************************************/
 /*************************************/

+ 4 - 2
plugins/administrator/defines.php

@@ -90,7 +90,8 @@ $defcfg = array( '$config_version' => array( 'name' => _("Config File Version"),
                  '$optional_delimiter' => array( 'name' => _("IMAP Folder Delimiter"),
                  '$optional_delimiter' => array( 'name' => _("IMAP Folder Delimiter"),
                                                  'type' => SMOPT_TYPE_STRING,
                                                  'type' => SMOPT_TYPE_STRING,
                                                  'comment' => _("Use \"detect\" to auto-detect."),
                                                  'comment' => _("Use \"detect\" to auto-detect."),
-                                                 'size' => 10 ),
+                                                 'size' => 10,
+                                                 'default' => 'detect' ),
                  '$useSendmail' => array( 'name' => _("Use Sendmail"),
                  '$useSendmail' => array( 'name' => _("Use Sendmail"),
                                           'type' => SMOPT_TYPE_BOOLEAN ),
                                           'type' => SMOPT_TYPE_BOOLEAN ),
                  '$sendmail_path' => array( 'name' => _("Sendmail Path"),
                  '$sendmail_path' => array( 'name' => _("Sendmail Path"),
@@ -196,7 +197,8 @@ $defcfg = array( '$config_version' => array( 'name' => _("Config File Version"),
                                            'size' => 40 ), 
                                            'size' => 40 ), 
                  '$addrbook_table' => array( 'name' => _("Address book table"),
                  '$addrbook_table' => array( 'name' => _("Address book table"),
                                              'type' => SMOPT_TYPE_STRING,
                                              'type' => SMOPT_TYPE_STRING,
-                                             'size' => 40 ),
+                                             'size' => 40,
+                                             'default' => 'address' ),
                  /* --------------------------------------------------------*/
                  /* --------------------------------------------------------*/
                  'Group7' => array( 'name' => _("Themes"),
                  'Group7' => array( 'name' => _("Themes"),
                                     'type' => SMOPT_TYPE_TITLE ),
                                     'type' => SMOPT_TYPE_TITLE ),

+ 13 - 2
plugins/filters/setup.php

@@ -65,9 +65,20 @@
       global $mailbox, $imap_stream, $imapConnection;
       global $mailbox, $imap_stream, $imapConnection;
 
 
       $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters';
       $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() {