This commit has been accessed 586 times via Git panel.
commit 982c3a55de4be55368144fb742c6013030559b73
tree 35caaf32f0a55f6c41125d565d96e54978ac8f79
parent a15ccd7d4a452dc269aa8e857642139fdf341e75
author Engels Antonio <engels@majcms.org> 1334338506 +0800
committer Engels Antonio <engels@majcms.org> 1334338506 +0800
Add clean-up of Sieve rules associated with deleted folders
diff --git a/index.php b/index.php
index c58da0d..fab1074 100644
--- a/index.php
+++ b/index.php
@@ -851,6 +851,7 @@ if (isset($_SESSION['logged_uid'])) {
if (isset($_POST['del_box']) and !empty($_POST['del_box'])) {
$del_box = imap_utf7_encode(ucwords(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['del_box'])))));
+ $del_siv = $del_box;
if (($del_box != "INBOX") and ($del_box != "Sent") and ($del_box != "Trash")) {
imap_deletemailbox($mbox,"{$host}$del_box");
@@ -1056,6 +1057,16 @@ if (isset($_SESSION['logged_uid'])) {
$sivP = "$mail_home/$sivD/{$sivN[0]}/$sivN";
$sivR = glob("$sivP/*.sieve",GLOB_NOSORT);
+ if ($del_siv) {
+
+ foreach ($sivR as $sivI) {
+
+ if (stripos(file_get_contents($sivI),"fileinto \"$del_siv\";")) {
+ unlink($sivI);
+ }
+ }
+ }
+
if (isset($_POST['sieveT']) and !empty($_POST['sieveT']) and isset($_POST['sieveV']) and !empty($_POST['sieveV']) and isset($_POST['sieveF']) and !empty($_POST['sieveF'])) {
$sieveT = strtolower(trim(strip_tags($_POST['sieveT'])));
@@ -1116,23 +1127,23 @@ if (isset($_SESSION['logged_uid'])) {
}
}
-echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">";
-echo "<form method=\"post\"><input type=\"hidden\" name=\"set\" value=\"sivA\"><tr>";
-echo "<td width=\"200\"><select class=\"input\" name=\"sieveT\"><option value=\"from\">If message is from</option><option value=\"subject\">If message subject contains</option></td>";
-echo "<td><input class=\"input\" type=\"text\" name=\"sieveV\" autocomplete=\"off\" required></td>";
-echo "<td><select class=\"input\" name=\"sieveF\"><option value=\"Trash\" selected>then move to Trash</option>";
+ echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">";
+ echo "<form method=\"post\"><input type=\"hidden\" name=\"set\" value=\"sivA\"><tr>";
+ echo "<td width=\"200\"><select class=\"input\" name=\"sieveT\"><option value=\"from\">If message is from</option><option value=\"subject\">If message subject contains</option></td>";
+ echo "<td><input class=\"input\" type=\"text\" name=\"sieveV\" autocomplete=\"off\" required></td>";
+ echo "<td><select class=\"input\" name=\"sieveF\"><option value=\"Trash\" selected>then move to Trash</option>";
-foreach ($usr_box as $sieveF) {
+ foreach ($usr_box as $sieveF) {
- $sieveF = str_replace($host,"",$sieveF);
+ $sieveF = str_replace($host,"",$sieveF);
- echo "<option value=\"$sieveF\">then move to $sieveF</option>";
-}
+ echo "<option value=\"$sieveF\">then move to $sieveF</option>";
+ }
-echo "</select></td>";
-echo "<td><input type=\"submit\" value=\"add\"></td>";
-echo "</tr></form>";
-echo "</table>";
+ echo "</select></td>";
+ echo "<td><input type=\"submit\" value=\"add\"></td>";
+ echo "</tr></form>";
+ echo "</table>";
$sivR = glob("$sivP/*.sieve");
tree 35caaf32f0a55f6c41125d565d96e54978ac8f79
parent a15ccd7d4a452dc269aa8e857642139fdf341e75
author Engels Antonio <engels@majcms.org> 1334338506 +0800
committer Engels Antonio <engels@majcms.org> 1334338506 +0800
Add clean-up of Sieve rules associated with deleted folders
diff --git a/index.php b/index.php
index c58da0d..fab1074 100644
--- a/index.php
+++ b/index.php
@@ -851,6 +851,7 @@ if (isset($_SESSION['logged_uid'])) {
if (isset($_POST['del_box']) and !empty($_POST['del_box'])) {
$del_box = imap_utf7_encode(ucwords(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['del_box'])))));
+ $del_siv = $del_box;
if (($del_box != "INBOX") and ($del_box != "Sent") and ($del_box != "Trash")) {
imap_deletemailbox($mbox,"{$host}$del_box");
@@ -1056,6 +1057,16 @@ if (isset($_SESSION['logged_uid'])) {
$sivP = "$mail_home/$sivD/{$sivN[0]}/$sivN";
$sivR = glob("$sivP/*.sieve",GLOB_NOSORT);
+ if ($del_siv) {
+
+ foreach ($sivR as $sivI) {
+
+ if (stripos(file_get_contents($sivI),"fileinto \"$del_siv\";")) {
+ unlink($sivI);
+ }
+ }
+ }
+
if (isset($_POST['sieveT']) and !empty($_POST['sieveT']) and isset($_POST['sieveV']) and !empty($_POST['sieveV']) and isset($_POST['sieveF']) and !empty($_POST['sieveF'])) {
$sieveT = strtolower(trim(strip_tags($_POST['sieveT'])));
@@ -1116,23 +1127,23 @@ if (isset($_SESSION['logged_uid'])) {
}
}
-echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">";
-echo "<form method=\"post\"><input type=\"hidden\" name=\"set\" value=\"sivA\"><tr>";
-echo "<td width=\"200\"><select class=\"input\" name=\"sieveT\"><option value=\"from\">If message is from</option><option value=\"subject\">If message subject contains</option></td>";
-echo "<td><input class=\"input\" type=\"text\" name=\"sieveV\" autocomplete=\"off\" required></td>";
-echo "<td><select class=\"input\" name=\"sieveF\"><option value=\"Trash\" selected>then move to Trash</option>";
+ echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">";
+ echo "<form method=\"post\"><input type=\"hidden\" name=\"set\" value=\"sivA\"><tr>";
+ echo "<td width=\"200\"><select class=\"input\" name=\"sieveT\"><option value=\"from\">If message is from</option><option value=\"subject\">If message subject contains</option></td>";
+ echo "<td><input class=\"input\" type=\"text\" name=\"sieveV\" autocomplete=\"off\" required></td>";
+ echo "<td><select class=\"input\" name=\"sieveF\"><option value=\"Trash\" selected>then move to Trash</option>";
-foreach ($usr_box as $sieveF) {
+ foreach ($usr_box as $sieveF) {
- $sieveF = str_replace($host,"",$sieveF);
+ $sieveF = str_replace($host,"",$sieveF);
- echo "<option value=\"$sieveF\">then move to $sieveF</option>";
-}
+ echo "<option value=\"$sieveF\">then move to $sieveF</option>";
+ }
-echo "</select></td>";
-echo "<td><input type=\"submit\" value=\"add\"></td>";
-echo "</tr></form>";
-echo "</table>";
+ echo "</select></td>";
+ echo "<td><input type=\"submit\" value=\"add\"></td>";
+ echo "</tr></form>";
+ echo "</table>";
$sivR = glob("$sivP/*.sieve");