From 4eec80a7296fd32006c010387d8ead6cbc2847d8 Mon Sep 17 00:00:00 2001 From: jmunro Date: Sat, 2 Mar 2002 05:26:28 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2529 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/filters/filters.php | 26 ++++++++++++++++++++++++++ plugins/filters/setup.php | 1 + 2 files changed, 27 insertions(+) diff --git a/plugins/filters/filters.php b/plugins/filters/filters.php index 170c7870..1550fa54 100644 --- a/plugins/filters/filters.php +++ b/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++; + } + } +} ?> diff --git a/plugins/filters/setup.php b/plugins/filters/setup.php index 1de252da..a3906273 100644 --- a/plugins/filters/setup.php +++ b/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 ) { -- 2.25.1