I moved the filter update on folder rename/delete
authorjmunro <jmunro@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 2 Mar 2002 05:26:28 +0000 (05:26 +0000)
committerjmunro <jmunro@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 2 Mar 2002 05:26:28 +0000 (05:26 +0000)
out of imap_mailbox.php (sorry folks) and into the
filter plugin. 3 new hooks in imap_mailbox.php.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2529 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/filters/filters.php
plugins/filters/setup.php

index 170c7870a0121321b2fbaf915bc21d0ed1fbd147..1550fa541d299dd9b79a4affe52ca55408d8db99 100644 (file)
@@ -704,4 +704,30 @@ function filter_swap($id1, $id2) {
         setPref($data_dir, $username, 'filter' . $id1, $SecondFilter);
     }
 }
+
+/* This update the filter rules when
+   renaming or deleting folders */
+function update_for_folder ($old_folder, $action, $new_folder = 'INBOX') {
+    global $plugins, $data_dir, $username;
+    $filters = array();
+    $filters = load_filters();
+    $filter_count = count($filters);
+    $p = 0;
+    for ($i=0;$i<$filter_count;$i++) {
+        if (!empty($filters)) {
+            if ($old_folder == $filters[$i]['folder']) {
+                if ($action == 'rename') {
+                    $filters[$i]['folder'] = $new_folder;
+                    setPref($data_dir, $username, 'filter'.$i,
+                    $filters[$i]['where'].','.$filters[$i]['what'].','.$new_folder);
+                }
+                elseif ($action == 'delete') {
+                    remove_filter($p);
+                    $p = $p-1;
+                }
+            }
+        $p++;
+        }
+    }
+}
 ?>
index 1de252da2a6a03c83fcdefb6f44348c09c638483..a3906273af4070abe5a5b52fefa3bbeec5301dad 100644 (file)
@@ -86,6 +86,7 @@ function squirrelmail_plugin_init_filters() {
     }
     $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'squirrelmail_plugin_optpage_register_block';
 #    $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox';
+    $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder';
 }
 
 function filters_special_mailbox( $mb ) {