Added use of $imapPort
[squirrelmail.git] / src / empty_trash.php
CommitLineData
7a783442 1<?
2 include("../config/config.php");
7a783442 3 include("../functions/strings.php");
4 include("../functions/page_header.php");
5 include("../functions/display_messages.php");
2aa12d5e 6 include("../functions/imap.php");
7ce342dc 7 include("../functions/array.php");
7a783442 8
97dd6a62 9 if (!isset($tree_php))
10 include("../functions/tree.php");
11
d3cdb279 12 include("../src/load_prefs.php");
13
e1469126 14 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
7a783442 15
97dd6a62 16 sqimap_mailbox_list($imap_stream, $boxes);
d92b6f31 17
18 $mailbox = $trash_folder;
97dd6a62 19 $boxes = sqimap_mailbox_list($imap_stream);
20 $dm = sqimap_get_delimiter($imap_stream);
7cad6205 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.
0a1d5f3a 25
97dd6a62 26 /** First create the top node in the tree **/
27 for ($i = 0;$i < count($boxes);$i++) {
28 if (($boxes[$i]["unformatted"] == $mailbox) && (strlen($boxes[$i]["unformatted"]) == strlen($mailbox))) {
29 $foldersTree[0]["value"] = $mailbox;
30 $foldersTree[0]["doIHaveChildren"] = false;
31 continue;
32 }
33 }
34 // Now create the nodes for subfolders of the parent folder
35 // You can tell that it is a subfolder by tacking the mailbox delimiter
36 // on the end of the $mailbox string, and compare to that.
37 $j = 0;
38 for ($i = 0;$i < count($boxes);$i++) {
39 if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == ($mailbox . $dm)) {
c5f5cd59 40 addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
97dd6a62 41 }
42 }
43
44 // now lets go through the tree and delete the folders
45 walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
46 // now lets create a new, fresh trash folder
47 sqimap_mailbox_create($imap_stream, "$trash_folder", "");
a11899fd 48
97dd6a62 49 sqimap_mailbox_select($imap_stream, $trash_folder, $numMessages);
f8f9bed9 50 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
51 displayPageHeader($color, $mailbox);
d92b6f31 52 messages_deleted_message($trash_folder, $sort, $startMessage, $color);
97dd6a62 53 sqimap_logout($imap_stream);
2aa12d5e 54?>