added patch to allow use of sendmail instead of connecting to SMTP port
[squirrelmail.git] / src / empty_trash.php
index bc554d636e71037f6b36a475387775510aeb05dd..e4d230fea53e82c69635bc734a36647c572315a0 100644 (file)
@@ -5,51 +5,33 @@
    include("../functions/page_header.php");
    include("../functions/display_messages.php");
    include("../functions/imap.php");
+   include("../functions/array.php");
 
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
-
-   // switch to the mailbox, and get the number of messages in it.
-   selectMailbox($imapConnection, $mailbox, $numMessages);
-
-   if ($mailbox != $trash_folder) {
-      echo "ERROR -- I'm not in the trash folder!<BR>";
-      exit;
-   }
-
-
-   /** GET FOLDER ARRAY OF TRASH SUBFOLDERS **/
-   fputs($imapConnection, "1 list \"\" *\n");
-   $str = imapReadData($imapConnection);
+   include("../src/load_prefs.php");
 
-   for ($i = 0;$i < count($str); $i++) {
-      $box = Chop($str[$i]);
-      $mailbox = findMailboxName($box);
+   $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
 
-      if (strpos($box, $trash_folder) > 0) {
-         $folders[$i] = $mailbox;
-      } else {
-         $folders[$i] = "NOPE";
+   getFolderList($imapConnection, $boxes);
+
+   $mailbox = $trash_folder;
+   fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
+   $data = imapReadData($imapConnection , "1", false, $response, $message);
+   while (substr($data[0], strpos($data[0], " ")+1, 4) == "LIST") {
+      for ($i = 0; $i < count($boxes); $i++) {
+         if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
+             (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+            removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"]);
+         }
       }
+      fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
+      $data = imapReadData($imapConnection , "1", false, $response, $message);
    }
 
-   // mark them as deleted
-   setMessageFlag($imapConnection, 1, $numMessages, "Deleted");
-   expungeBox($imapConnection, $mailbox);
+   createFolder($imapConnection, "$trash_folder", "");
 
-   // remove subfolders
-   for ($i = 0; $i < count($folders); $i++) {
-      if (($folders[$i] == "NOPE") || ($folders[$i] == "$trash_folder")) {
-      } else {
-         $thisfolder = getFolderNameMinusINBOX($folders[$i]);
-         $thisfolder = "user.$username.$thisfolder";
-         removeFolder($imapConnection, $thisfolder);
-      }
-   }
-   // Log out this session
+   selectMailbox($imapConnection, $trash_folder, $numMessages);
+   echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+   displayPageHeader($color, $mailbox);
+   messages_deleted_message($trash_folder, $sort, $startMessage, $color);
    fputs($imapConnection, "1 logout");
-
-   echo "<HTML><BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#0000EE\" ALINK=\"#0000EE\">";
-   displayPageHeader($mailbox);
-
-   messages_deleted_message("INBOX", $sort, $startMessage);
 ?>