From aa4c3749e589871cd930b3cd2e94ccaeb5a71bc5 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Tue, 23 Nov 1999 23:00:34 +0000 Subject: [PATCH] Added deleting of messages git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@24 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- config/config.php | 18 +++++++++++++++++- functions/display_messages.php | 18 ++++++++++++++++++ functions/mailbox.php | 26 ++++++++++++++++++++++++++ functions/mailbox_display.php | 30 ++++++++++++++++++++++++------ 4 files changed, 85 insertions(+), 7 deletions(-) diff --git a/config/config.php b/config/config.php index e9741910..24a8d58b 100644 --- a/config/config.php +++ b/config/config.php @@ -11,6 +11,22 @@ $imapServerAddress = "adam.usa.om.org"; /* This is displayed right after they log in */ $motd = " Welcome to OM's webmail system, SquirrelMail. We are currently in beta, and have not yet released a full version of SquirrelMail. Please feel free to look around, and please report any bugs to Nathan or Luke."; -/* SquirrelMail version number */ +/* SquirrelMail version number -- DO NOT CHANGE */ $version = "0.0.1"; + +/* The following are related to deleting messages. + * $move_to_trash + * - if this is set to "true", when "delete" is pressed, it will attempt + * to move the selected messages to the folder named $trash_folder. If + * it's set to "false", we won't even attempt to move the messages, just + * delete them. + * $trash_folder + * - This is the path to the default trash folder. For Cyrus IMAP, it + * would be "INBOX.Trash", but for UW it would be "Trash". We need the + * full path name here. + */ + +$move_to_trash = true; +$trash_folder = "INBOX.Trash"; + ?> diff --git a/functions/display_messages.php b/functions/display_messages.php index fef1fc31..6fb18005 100644 --- a/functions/display_messages.php +++ b/functions/display_messages.php @@ -47,4 +47,22 @@ echo ""; echo ""; } + + function messages_deleted_message($mailbox, $sort, $startMessage) { + $urlMailbox = urlencode($mailbox); + echo "
"; + echo ""; + echo " "; + echo " "; + echo "
"; + echo "
Messages Deleted
"; + echo "
"; + echo "

The selected messages were deleted successfully.
\n"; + echo " "; + echo " Click here to return to $mailbox"; + echo " ."; + echo "
"; + echo "
"; + echo ""; + } ?> diff --git a/functions/mailbox.php b/functions/mailbox.php index 3b6af280..1bcc6340 100644 --- a/functions/mailbox.php +++ b/functions/mailbox.php @@ -48,9 +48,14 @@ } } + function setMessageFlag($imapConnection, $i, $flag) { + fputs($imapConnection, "messageStore STORE $i:$i +FLAGS (\\$flag)\n"); + } + function getMessageFlags($imapConnection, $i, &$flags) { /** * 2 FETCH (FLAGS (\Answered \Seen)) */ fputs($imapConnection, "messageFetch FETCH $i:$i FLAGS\n"); + $read = fgets($imapConnection, 1024); while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) { if (strpos($read, "FLAGS")) { $read = ereg_replace("\(", "", $read); @@ -120,4 +125,25 @@ return $from; } + + /** returns "true" if the copy was completed successfully. + ** returns "false" with an error message if unsuccessful. + **/ + function copyMessages($imapConnection, $from_id, $to_id, $folder) { + fputs($imapConnection, "mailboxStore COPY $from_id:$to_id \"$folder\"\n"); + $read = fgets($imapConnection, 1024); + while ((substr($read, 0, 15) != "mailboxStore OK") && (substr($read, 0, 15) != "mailboxStore NO")) { + $read = fgets($imapConnection, 1024); + } + + if (substr($read, 0, 15) == "mailboxStore NO") { + echo "ERROR... $read
"; + return false; + } else if (substr($read, 0, 15) == "mailboxStore OK") { + return true; + } + + echo "UNKNOWN ERROR copying messages $from_id to $to_id to folder $folder.
"; + return false; + } ?> diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 437cfb82..27ff6da2 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -7,19 +7,19 @@ ** **/ - function printMessageInfo($imapConnection, $i, $from, $subject, $dateString, $answered, $seen) { + function printMessageInfo($imapConnection, $t, $i, $from, $subject, $dateString, $answered, $seen) { $senderName = getSenderName($from); if (strlen(Chop($subject)) == 0) $subject = "(no subject)"; echo "\n"; if ($seen == false) { - echo " $i\n"; + echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; echo " $subject\n"; } else { - echo " $i\n"; + echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; echo " $subject\n"; @@ -114,12 +114,20 @@ } else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) { echo "Previous\n"; + echo "Next\n"; } else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) { + echo "Previous\n"; echo "Next\n"; } echo "\n"; + /** The "DELETE" button */ + echo ""; + echo "
"; + echo " selected messages"; + echo ""; + echo ""; echo ""; echo ""; @@ -134,12 +142,20 @@ echo ""; // loop through and display the info for each message. + $t = 0; // $t is used for the checkbox number for ($i = $startMessage - 1;$i <= $endMessage - 1; $i++) { - printMessageInfo($imapConnection, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"]); + printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"]); + $t++; } - echo "
\n"; - + echo "
\n"; echo "\n"; + + /** The "DELETE" button */ + echo ""; + echo "
"; + echo " selected messages"; + echo ""; + echo ""; if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) { echo "Previous\n"; @@ -147,8 +163,10 @@ } else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) { echo "Previous\n"; + echo "Next\n"; } else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) { + echo "Previous\n"; echo "Next\n"; } echo ""; /** End of message-list table */ -- 2.25.1