- include("../functions/mailbox.php");
-
- $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
-
- // switch to the mailbox, and get the number of messages in it.
- echo "$mailbox<BR>";
- exit;
- selectMailbox($imapConnection, $mailbox, $numMessages);
-
- $folder = getFolderNameMinusINBOX($mailbox);
- $trash = getFolderNameMinusINBOX($trash_folder);
-
- /** check if they would like to move it to the trash folder or not */
- if ($move_to_trash == true) {
- createFolder($imapConnection, "user.$username.$trash.$folder");
- echo "CREATING FOLDER: user.$username.$trash.$folder<BR>";
- if ($numMessages > 0)
- $success = copyMessages($imapConnection, 1, $numMessages, $trash_folder);
- else
- $success = true;
-
- if ($success == true)
- removeFolder($imapConnection, "user.$username.$folder");
- } else {
- removeFolder($imapConnection, "user.$username.$folder");
+ include("../functions/array.php");
+ include("../functions/tree.php");
+
+ /*
+ * Incoming values:
+ * $mailbox - selected mailbox from the form
+ */
+
+ $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+ $boxes = sqimap_mailbox_list ($imap_stream);
+ $dm = sqimap_get_delimiter($imap_stream);
+
+ if (substr($mailbox, -1) == $dm)
+ $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1);
+ else
+ $mailbox_no_dm = $mailbox;
+
+ /** lets see if we CAN move folders to the trash.. otherwise,
+ ** just delete them **/
+
+ // Courier IMAP doesn't like subfolders of Trash
+ if (strtolower($imap_server_type) == "courier") {
+ $can_move_to_trash = false;
+ }
+
+ // If it's already a subfolder of trash, we'll have to delete it
+ else if(eregi("^".$trash_folder.".+", $mailbox)) {
+
+ $can_move_to_trash = false;
+