Quellcode durchsuchen

I moved the filter update on folder rename/delete
out of imap_mailbox.php (sorry folks) and into the
filter plugin. 3 new hooks in imap_mailbox.php.

jmunro vor 23 Jahren
Ursprung
Commit
c6cd43df6f
2 geänderte Dateien mit 27 neuen und 0 gelöschten Zeilen
  1. 26 0
      plugins/filters/filters.php
  2. 1 0
      plugins/filters/setup.php

+ 26 - 0
plugins/filters/filters.php

@@ -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++;
+        }
+    }
+}
 ?>

+ 1 - 0
plugins/filters/setup.php

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