deleting folders is now recursive and should work more reliably
[squirrelmail.git] / src / empty_trash.php
CommitLineData
7a783442 1<?
2 include("../config/config.php");
3 include("../functions/mailbox.php");
4 include("../functions/strings.php");
5 include("../functions/page_header.php");
6 include("../functions/display_messages.php");
2aa12d5e 7 include("../functions/imap.php");
7ce342dc 8 include("../functions/array.php");
7a783442 9
d3cdb279 10 include("../src/load_prefs.php");
11
b235d629 12 $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
7a783442 13
7ce342dc 14 getFolderList($imapConnection, $boxes);
d92b6f31 15
16 $mailbox = $trash_folder;
17 fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
18 $data = imapReadData($imapConnection , "1", false, $response, $message);
0a1d5f3a 19
7cad6205 20 $dm = findMailboxDelimeter($imapConnection);
21
0a1d5f3a 22 // According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
23 // so lets go through the list of subfolders and remove them before removing the
24 // parent.
25 // BUG??? - what if a subfolder has a subfolder?? need to start at lowest level
26 // and work up.
27
28
7cad6205 29// for ($i = 0; $i < count($boxes); $i++) {
0a1d5f3a 30// if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
31// (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
7cad6205 32// if (($boxes[$i]["UNFORMATTED"] != $mailbox) && (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
33// removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"], $dm);
34// }
35// }
36
37 // lets remove the trash folder
38 removeFolder($imapConnection, $mailbox, $dm);
a11899fd 39
d92b6f31 40 createFolder($imapConnection, "$trash_folder", "");
7a783442 41
ad6787f0 42 selectMailbox($imapConnection, $trash_folder, $numMessages);
f8f9bed9 43 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
44 displayPageHeader($color, $mailbox);
d92b6f31 45 messages_deleted_message($trash_folder, $sort, $startMessage, $color);
ad6787f0 46 fputs($imapConnection, "1 logout");
2aa12d5e 47?>