This commit has been accessed 570 times via Git panel.
commit 2bd71e63e09a473768b11f37332fde2c8ba1b618
tree 3c9d3058685d05847c27891cb462d3a8a565b878
parent 4f053fd0e4f29965507d8b929b1b7f177674ce52
author Engels Antonio <engels@majcms.org> 1333969049 +0800
committer Engels Antonio <engels@majcms.org> 1333969049 +0800
Add move message to folder support
diff --git a/folders.php b/folders.php
index 845e439..e5aef41 100644
--- a/folders.php
+++ b/folders.php
@@ -95,8 +95,38 @@ if (is_array($get_folders)) {
unset($inbox);
}
+ if (in_array("{$host}Sent",$get_folders)) {
+
+ $priv_sent = 1;
+
+ $sent = array_search("{$host}Sent",$get_folders);
+
+ unset($get_folders[$sent]);
+ unset($sent);
+ }
+
+ if (in_array("{$host}Trash",$get_folders)) {
+
+ $priv_trash = 1;
+
+ $trash = array_search("{$host}Trash",$get_folders);
+
+ unset($get_folders[$trash]);
+ unset($trash);
+ }
+
sort($get_folders);
+ if ($priv_trash == 1) {
+ array_unshift($get_folders,"{$host}Trash");
+ unset($priv_trash);
+ }
+
+ if ($priv_sent == 1) {
+ array_unshift($get_folders,"{$host}Sent");
+ unset($priv_sent);
+ }
+
array_unshift($get_folders,"{$host}INBOX");
reset($get_folders);
@@ -109,7 +139,7 @@ if (is_array($get_folders)) {
$status_folder = "(" . $status->unseen . "/" . $status->messages . ")";
- $get_folder = str_replace($host,"",$get_folder);
+ $get_folder = imap_utf7_decode(trim(str_replace($host,"",$get_folder)));
echo "<tr><form method=\"post\"><td align=\"center\"><input type=\"hidden\" name=\"box\" value=\"$get_folder\">";
diff --git a/index.php b/index.php
index 3ccab56..99477a0 100644
--- a/index.php
+++ b/index.php
@@ -830,18 +830,29 @@ if (isset($_SESSION['logged_uid'])) {
$mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key'], CL_EXPUNGE) or die(imap_last_error());
- if (isset($_POST['fnew_name']) and !empty($_POST['fnew_name'])) {
+ if (isset($_POST['move_msg']) and !empty($_POST['move_msg']) and isset($_POST['move_box']) and !empty($_POST['move_box'])) {
- $fnew_name = imap_utf7_encode(ucwords(strtolower(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['fnew_name']))))));
- imap_createmailbox($mbox,"{$host}$fnew_name");
+ $move_msg = trim(strip_tags($_POST['move_msg']));
+ $move_box = imap_utf7_encode(ucwords(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['move_box'])))));
+
+ if (($move_box != "Sent") and ($move_box != "Trash")) {
+ imap_mail_move($mbox,$move_msg,$move_box,CP_UID);
+ imap_expunge($mbox);
+ }
+ }
+
+ if (isset($_POST['new_box']) and !empty($_POST['new_box'])) {
+
+ $new_box = imap_utf7_encode(ucwords(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['new_box'])))));
+ imap_createmailbox($mbox,"{$host}$new_box");
}
- if (isset($_POST['fdel_name']) and !empty($_POST['fdel_name'])) {
+ if (isset($_POST['del_box']) and !empty($_POST['del_box'])) {
- $fdel_name = imap_utf7_encode(ucwords(strtolower(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['fdel_name']))))));
+ $del_box = imap_utf7_encode(ucwords(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['del_box'])))));
- if (($fdel_name != "INBOX") and ($fdel_name != "Sent") and ($fdel_name != "Trash")) {
- imap_deletemailbox($mbox,"{$host}$fdel_name");
+ if (($del_box != "INBOX") and ($del_box != "Sent") and ($del_box != "Trash")) {
+ imap_deletemailbox($mbox,"{$host}$del_box");
}
}
@@ -1009,29 +1020,29 @@ if (isset($_SESSION['logged_uid'])) {
echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"800\">";
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><input class=\"input\" type=\"text\" name=\"fnew_name\" autocomplete=\"off\" maxlength=\"200\" required autofocus></td>";
+ echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><input class=\"input\" type=\"text\" name=\"new_box\" autocomplete=\"off\" maxlength=\"200\" required autofocus></td>";
echo "<td width=\"197\"><input class=\"button\" type=\"submit\" value=\"create folder\"></td><td></td></tr>";
echo "</form>";
- $fdel_mbox = imap_list($mbox,$host,"*");
- $fdel_mbox = array_diff($fdel_mbox,array("{$host}INBOX","{$host}Sent","{$host}Trash"));
+ $usr_box = imap_list($mbox,$host,"*");
+ $usr_box = array_diff($usr_box,array("{$host}INBOX","{$host}Sent","{$host}Trash"));
- if (count($fdel_mbox) > 0) {
+ if (count($usr_box) > 0) {
- sort($fdel_mbox);
+ sort($usr_box);
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><select class=\"input\" name=\"fdel_name\">";
+ echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><select class=\"input\" name=\"del_box\">";
- foreach ($fdel_mbox as $fdel_name) {
+ foreach ($usr_box as $del_box) {
- $fdel_name = imap_utf7_decode(str_replace($host,"",$fdel_name));
+ $del_box = imap_utf7_decode(str_replace($host,"",$del_box));
- echo "<option value=\"$fdel_name\">$fdel_name</option>";
+ echo "<option value=\"$del_box\">$del_box</option>";
}
- echo "</select></td><td width=\"197\"><input class=\"button\" type=\"submit\" value=\"delete folder\" onclick=\"if (confirm('Delete folder ($fdel_name) and all messages in it?')) {return true;} else {return false;}\"></td><td></td></tr>";
+ echo "</select></td><td width=\"197\"><input class=\"button\" type=\"submit\" value=\"delete folder\" onclick=\"if (confirm('Delete folder and all messages in it?')) {return true;} else {return false;}\"></td><td></td></tr>";
echo "</form>";
}
echo "</table>";
diff --git a/read.php b/read.php
index 2ba6b31..42f760a 100644
--- a/read.php
+++ b/read.php
@@ -104,7 +104,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<div class=\"message\" style=\"padding: 2px;\">";
- echo "<table border=\"0\" cellspacing=\"0\" cellpadidng=\"0\" width=\"100%\"><tr>";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr>";
echo "<form method=\"post\"><td class=\"label\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
@@ -284,10 +284,51 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "</div>";
-
echo "<div class=\"spacer\"></div>";
+
+ $usr_mbox = imap_list($mbox,$host,"*");
+ $usr_mbox = array_diff($usr_mbox,array("{$host}INBOX","{$host}Sent","{$host}Trash"));
+
+ if ((count($usr_mbox) > 0) and ($folder != "Sent") and ($folder != "Trash")) {
+
+ sort($usr_mbox);
+
+ array_unshift($usr_mbox,"{$host}INBOX");
+
+ echo "<div class=\"message\">";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"move_msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+
+ if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
+ echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
+ echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
+ }
+
+ echo "<tr><td><select name=\"move_box\" onchange=\"this.form.submit();\">";
+ echo "<option value=\"\" selected>$folder</option>";
+
+ foreach ($usr_mbox as $move_box) {
+ $move_box = str_replace($host,"",$move_box);
+
+ if ($folder == $move_box) {
+ continue;
+ }
+
+ echo "<option value=\"$move_box\">$move_box</option>";
+ }
+
+ echo "</select></td>";
+ echo "<noscript><td><input type=\"submit\" value=\"move\"></td></noscript>";
+ echo "</tr></form></table>";
+ echo "</div>";
+ echo "<div class=\"spacer\"></div>";
+ }
+
echo "<div class=\"message\">";
$filePath = "attach/o/$fileUsr/$fileDir";
tree 3c9d3058685d05847c27891cb462d3a8a565b878
parent 4f053fd0e4f29965507d8b929b1b7f177674ce52
author Engels Antonio <engels@majcms.org> 1333969049 +0800
committer Engels Antonio <engels@majcms.org> 1333969049 +0800
Add move message to folder support
diff --git a/folders.php b/folders.php
index 845e439..e5aef41 100644
--- a/folders.php
+++ b/folders.php
@@ -95,8 +95,38 @@ if (is_array($get_folders)) {
unset($inbox);
}
+ if (in_array("{$host}Sent",$get_folders)) {
+
+ $priv_sent = 1;
+
+ $sent = array_search("{$host}Sent",$get_folders);
+
+ unset($get_folders[$sent]);
+ unset($sent);
+ }
+
+ if (in_array("{$host}Trash",$get_folders)) {
+
+ $priv_trash = 1;
+
+ $trash = array_search("{$host}Trash",$get_folders);
+
+ unset($get_folders[$trash]);
+ unset($trash);
+ }
+
sort($get_folders);
+ if ($priv_trash == 1) {
+ array_unshift($get_folders,"{$host}Trash");
+ unset($priv_trash);
+ }
+
+ if ($priv_sent == 1) {
+ array_unshift($get_folders,"{$host}Sent");
+ unset($priv_sent);
+ }
+
array_unshift($get_folders,"{$host}INBOX");
reset($get_folders);
@@ -109,7 +139,7 @@ if (is_array($get_folders)) {
$status_folder = "(" . $status->unseen . "/" . $status->messages . ")";
- $get_folder = str_replace($host,"",$get_folder);
+ $get_folder = imap_utf7_decode(trim(str_replace($host,"",$get_folder)));
echo "<tr><form method=\"post\"><td align=\"center\"><input type=\"hidden\" name=\"box\" value=\"$get_folder\">";
diff --git a/index.php b/index.php
index 3ccab56..99477a0 100644
--- a/index.php
+++ b/index.php
@@ -830,18 +830,29 @@ if (isset($_SESSION['logged_uid'])) {
$mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key'], CL_EXPUNGE) or die(imap_last_error());
- if (isset($_POST['fnew_name']) and !empty($_POST['fnew_name'])) {
+ if (isset($_POST['move_msg']) and !empty($_POST['move_msg']) and isset($_POST['move_box']) and !empty($_POST['move_box'])) {
- $fnew_name = imap_utf7_encode(ucwords(strtolower(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['fnew_name']))))));
- imap_createmailbox($mbox,"{$host}$fnew_name");
+ $move_msg = trim(strip_tags($_POST['move_msg']));
+ $move_box = imap_utf7_encode(ucwords(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['move_box'])))));
+
+ if (($move_box != "Sent") and ($move_box != "Trash")) {
+ imap_mail_move($mbox,$move_msg,$move_box,CP_UID);
+ imap_expunge($mbox);
+ }
+ }
+
+ if (isset($_POST['new_box']) and !empty($_POST['new_box'])) {
+
+ $new_box = imap_utf7_encode(ucwords(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['new_box'])))));
+ imap_createmailbox($mbox,"{$host}$new_box");
}
- if (isset($_POST['fdel_name']) and !empty($_POST['fdel_name'])) {
+ if (isset($_POST['del_box']) and !empty($_POST['del_box'])) {
- $fdel_name = imap_utf7_encode(ucwords(strtolower(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['fdel_name']))))));
+ $del_box = imap_utf7_encode(ucwords(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['del_box'])))));
- if (($fdel_name != "INBOX") and ($fdel_name != "Sent") and ($fdel_name != "Trash")) {
- imap_deletemailbox($mbox,"{$host}$fdel_name");
+ if (($del_box != "INBOX") and ($del_box != "Sent") and ($del_box != "Trash")) {
+ imap_deletemailbox($mbox,"{$host}$del_box");
}
}
@@ -1009,29 +1020,29 @@ if (isset($_SESSION['logged_uid'])) {
echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"800\">";
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><input class=\"input\" type=\"text\" name=\"fnew_name\" autocomplete=\"off\" maxlength=\"200\" required autofocus></td>";
+ echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><input class=\"input\" type=\"text\" name=\"new_box\" autocomplete=\"off\" maxlength=\"200\" required autofocus></td>";
echo "<td width=\"197\"><input class=\"button\" type=\"submit\" value=\"create folder\"></td><td></td></tr>";
echo "</form>";
- $fdel_mbox = imap_list($mbox,$host,"*");
- $fdel_mbox = array_diff($fdel_mbox,array("{$host}INBOX","{$host}Sent","{$host}Trash"));
+ $usr_box = imap_list($mbox,$host,"*");
+ $usr_box = array_diff($usr_box,array("{$host}INBOX","{$host}Sent","{$host}Trash"));
- if (count($fdel_mbox) > 0) {
+ if (count($usr_box) > 0) {
- sort($fdel_mbox);
+ sort($usr_box);
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><select class=\"input\" name=\"fdel_name\">";
+ echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><select class=\"input\" name=\"del_box\">";
- foreach ($fdel_mbox as $fdel_name) {
+ foreach ($usr_box as $del_box) {
- $fdel_name = imap_utf7_decode(str_replace($host,"",$fdel_name));
+ $del_box = imap_utf7_decode(str_replace($host,"",$del_box));
- echo "<option value=\"$fdel_name\">$fdel_name</option>";
+ echo "<option value=\"$del_box\">$del_box</option>";
}
- echo "</select></td><td width=\"197\"><input class=\"button\" type=\"submit\" value=\"delete folder\" onclick=\"if (confirm('Delete folder ($fdel_name) and all messages in it?')) {return true;} else {return false;}\"></td><td></td></tr>";
+ echo "</select></td><td width=\"197\"><input class=\"button\" type=\"submit\" value=\"delete folder\" onclick=\"if (confirm('Delete folder and all messages in it?')) {return true;} else {return false;}\"></td><td></td></tr>";
echo "</form>";
}
echo "</table>";
diff --git a/read.php b/read.php
index 2ba6b31..42f760a 100644
--- a/read.php
+++ b/read.php
@@ -104,7 +104,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<div class=\"message\" style=\"padding: 2px;\">";
- echo "<table border=\"0\" cellspacing=\"0\" cellpadidng=\"0\" width=\"100%\"><tr>";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr>";
echo "<form method=\"post\"><td class=\"label\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
@@ -284,10 +284,51 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "</div>";
-
echo "<div class=\"spacer\"></div>";
+
+ $usr_mbox = imap_list($mbox,$host,"*");
+ $usr_mbox = array_diff($usr_mbox,array("{$host}INBOX","{$host}Sent","{$host}Trash"));
+
+ if ((count($usr_mbox) > 0) and ($folder != "Sent") and ($folder != "Trash")) {
+
+ sort($usr_mbox);
+
+ array_unshift($usr_mbox,"{$host}INBOX");
+
+ echo "<div class=\"message\">";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"move_msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+
+ if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
+ echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
+ echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
+ }
+
+ echo "<tr><td><select name=\"move_box\" onchange=\"this.form.submit();\">";
+ echo "<option value=\"\" selected>$folder</option>";
+
+ foreach ($usr_mbox as $move_box) {
+ $move_box = str_replace($host,"",$move_box);
+
+ if ($folder == $move_box) {
+ continue;
+ }
+
+ echo "<option value=\"$move_box\">$move_box</option>";
+ }
+
+ echo "</select></td>";
+ echo "<noscript><td><input type=\"submit\" value=\"move\"></td></noscript>";
+ echo "</tr></form></table>";
+ echo "</div>";
+ echo "<div class=\"spacer\"></div>";
+ }
+
echo "<div class=\"message\">";
$filePath = "attach/o/$fileUsr/$fileDir";