This commit has been accessed 576 times via Git panel.
commit 0ccac1a59cf04fdf22b8f11468f6bd0ff901e821
tree 421a4a713b2fe3e43d5c19fe7f54fbab4df933db
parent a056ad97059351db4b020c2d2108e5fc24cafb01
author Engels Antonio <engels@majcms.org> 1334693241 +0800
committer Engels Antonio <engels@majcms.org> 1334693241 +0800
Add Sieve filter rules reordering
diff --git a/index.php b/index.php
index 029a8ca..b6b6c66 100644
--- a/index.php
+++ b/index.php
@@ -1073,20 +1073,7 @@ if (isset($_SESSION['logged_uid'])) {
$sieveV = trim($_POST['sieveV']);
$sieveF = imap_utf7_encode(trim(strip_tags($_POST['sieveF'])));
- if ($sieveT == "cc") {
- $sieveP = "cc";
- }
-
- if ($sieveT == "to") {
- $sieveP = "to";
- }
-
- if ($sieveT == "from") {
- $sieveP = "from";
- }
-
if ($sieveT == "subject") {
- $sieveP = "subj";
$sieveV = strip_tags($sieveV);
}
@@ -1108,7 +1095,7 @@ if (isset($_SESSION['logged_uid'])) {
}
}
- $sieveP = "$sivP/{$sieveP}-" . date("YmdHis") . ".sieve";
+ $sieveP = "$sivP/" . date("YmdHis") . ".sieve";
if (!file_exists($sivP)) {
mkdir($sivP,0700,true);
@@ -1133,6 +1120,25 @@ if (isset($_SESSION['logged_uid'])) {
$sieve = strtolower(trim(strip_tags($_POST['sieve'])));
+ if (isset($_POST['sivM']) and !empty($_POST['sivM'])) {
+
+ $sivM = trim(strip_tags($_POST['sivM']));
+
+ if (file_exists("$sivP/$sivM") and ($_POST['set'] == "sivM")) {
+
+ $sivMs = file_get_contents("$sivP/$sieve");
+ $sivMt = file_get_contents("$sivP/$sivM");
+
+ $fp = fopen("$sivP/$sieve","w");
+ fwrite($fp,$sivMt);
+ fclose($fp);
+
+ $fp = fopen("$sivP/$sivM","w");
+ fwrite($fp,$sivMs);
+ fclose($fp);
+ }
+ }
+
if (file_exists("$sivP/$sieve") and ($_POST['set'] == "sivD")) {
unlink("$sivP/$sieve");
}
@@ -1157,7 +1163,7 @@ if (isset($_SESSION['logged_uid'])) {
}
echo "</select></td>";
- echo "<td><input type=\"submit\" value=\"add\"></td>";
+ echo "<td><input class=\"button\" type=\"submit\" value=\"add filter\"></td>";
echo "</tr></form>";
echo "</table>";
@@ -1167,10 +1173,41 @@ if (isset($_SESSION['logged_uid'])) {
$sivW = 'require "include";';
- echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\">";
+ echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
+
+ foreach ($sivR as $sivK => $sivS) {
+
+ if ($bgColor == "#ffffff") {
+ $bgColor = "#fdfdfd";
+ }
+ else {
+ $bgColor = "#ffffff";
+ }
+
+ if ($sivK > 0) {
+
+ $sivKp = $sivK - 1;
+
+ if (array_key_exists($sivKp,$sivR)) {
+ $sivKp = basename($sivR[$sivKp]);
+ }
+ else {
+ unset($sivKp);
+ }
+ }
+
+ if ($sivK < count($sivR)) {
+
+ $sivKn = $sivK + 1;
+
+ if (array_key_exists($sivKn,$sivR)) {
+ $sivKn = basename($sivR[$sivKn]);
+ }
+ else {
+ unset($sivKn);
+ }
+ }
- foreach ($sivR as $sivS) {
-
$sivC = (explode('"',file_get_contents($sivS)));
$sivF = basename($sivS);
@@ -1179,11 +1216,35 @@ if (isset($_SESSION['logged_uid'])) {
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"set\" value=\"sivD\">";
echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
- echo "<tr>";
- echo "<td><input type=\"submit\" value=\"del\"></td>";
+ echo "<tr bgcolor=\"$bgColor\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-del.png\"></td>";
+ echo "</form>";
+
+ if ($sivKp) {
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
+ echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
+ echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKp\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-up.png\"></td>";
+ echo "</form>";
+ }
+ else {
+ echo "<td></td>";
+ }
+
+ if ($sivKn) {
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
+ echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
+ echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKn\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-down.png\"></td>";
+ echo "</form>";
+ }
+ else {
+ echo "<td></td>";
+ }
echo "<td>If message {$sivC[3]} contains {$sivC[5]} then move to {$sivC[7]}</td>";
echo "</tr>";
- echo "</form>";
}
echo "</table>";
tree 421a4a713b2fe3e43d5c19fe7f54fbab4df933db
parent a056ad97059351db4b020c2d2108e5fc24cafb01
author Engels Antonio <engels@majcms.org> 1334693241 +0800
committer Engels Antonio <engels@majcms.org> 1334693241 +0800
Add Sieve filter rules reordering
diff --git a/index.php b/index.php
index 029a8ca..b6b6c66 100644
--- a/index.php
+++ b/index.php
@@ -1073,20 +1073,7 @@ if (isset($_SESSION['logged_uid'])) {
$sieveV = trim($_POST['sieveV']);
$sieveF = imap_utf7_encode(trim(strip_tags($_POST['sieveF'])));
- if ($sieveT == "cc") {
- $sieveP = "cc";
- }
-
- if ($sieveT == "to") {
- $sieveP = "to";
- }
-
- if ($sieveT == "from") {
- $sieveP = "from";
- }
-
if ($sieveT == "subject") {
- $sieveP = "subj";
$sieveV = strip_tags($sieveV);
}
@@ -1108,7 +1095,7 @@ if (isset($_SESSION['logged_uid'])) {
}
}
- $sieveP = "$sivP/{$sieveP}-" . date("YmdHis") . ".sieve";
+ $sieveP = "$sivP/" . date("YmdHis") . ".sieve";
if (!file_exists($sivP)) {
mkdir($sivP,0700,true);
@@ -1133,6 +1120,25 @@ if (isset($_SESSION['logged_uid'])) {
$sieve = strtolower(trim(strip_tags($_POST['sieve'])));
+ if (isset($_POST['sivM']) and !empty($_POST['sivM'])) {
+
+ $sivM = trim(strip_tags($_POST['sivM']));
+
+ if (file_exists("$sivP/$sivM") and ($_POST['set'] == "sivM")) {
+
+ $sivMs = file_get_contents("$sivP/$sieve");
+ $sivMt = file_get_contents("$sivP/$sivM");
+
+ $fp = fopen("$sivP/$sieve","w");
+ fwrite($fp,$sivMt);
+ fclose($fp);
+
+ $fp = fopen("$sivP/$sivM","w");
+ fwrite($fp,$sivMs);
+ fclose($fp);
+ }
+ }
+
if (file_exists("$sivP/$sieve") and ($_POST['set'] == "sivD")) {
unlink("$sivP/$sieve");
}
@@ -1157,7 +1163,7 @@ if (isset($_SESSION['logged_uid'])) {
}
echo "</select></td>";
- echo "<td><input type=\"submit\" value=\"add\"></td>";
+ echo "<td><input class=\"button\" type=\"submit\" value=\"add filter\"></td>";
echo "</tr></form>";
echo "</table>";
@@ -1167,10 +1173,41 @@ if (isset($_SESSION['logged_uid'])) {
$sivW = 'require "include";';
- echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\">";
+ echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
+
+ foreach ($sivR as $sivK => $sivS) {
+
+ if ($bgColor == "#ffffff") {
+ $bgColor = "#fdfdfd";
+ }
+ else {
+ $bgColor = "#ffffff";
+ }
+
+ if ($sivK > 0) {
+
+ $sivKp = $sivK - 1;
+
+ if (array_key_exists($sivKp,$sivR)) {
+ $sivKp = basename($sivR[$sivKp]);
+ }
+ else {
+ unset($sivKp);
+ }
+ }
+
+ if ($sivK < count($sivR)) {
+
+ $sivKn = $sivK + 1;
+
+ if (array_key_exists($sivKn,$sivR)) {
+ $sivKn = basename($sivR[$sivKn]);
+ }
+ else {
+ unset($sivKn);
+ }
+ }
- foreach ($sivR as $sivS) {
-
$sivC = (explode('"',file_get_contents($sivS)));
$sivF = basename($sivS);
@@ -1179,11 +1216,35 @@ if (isset($_SESSION['logged_uid'])) {
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"set\" value=\"sivD\">";
echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
- echo "<tr>";
- echo "<td><input type=\"submit\" value=\"del\"></td>";
+ echo "<tr bgcolor=\"$bgColor\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-del.png\"></td>";
+ echo "</form>";
+
+ if ($sivKp) {
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
+ echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
+ echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKp\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-up.png\"></td>";
+ echo "</form>";
+ }
+ else {
+ echo "<td></td>";
+ }
+
+ if ($sivKn) {
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
+ echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
+ echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKn\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-down.png\"></td>";
+ echo "</form>";
+ }
+ else {
+ echo "<td></td>";
+ }
echo "<td>If message {$sivC[3]} contains {$sivC[5]} then move to {$sivC[7]}</td>";
echo "</tr>";
- echo "</form>";
}
echo "</table>";