59177427 |
1 | <?php |
ef870322 |
2 | /** |
3 | ** empty_trash.php |
4 | ** |
5 | ** Copyright (c) 1999-2000 The SquirrelMail development team |
6 | ** Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | ** |
8 | ** Handles deleting messages from the trash folder without |
9 | ** deleting subfolders. |
245a6892 |
10 | ** |
11 | ** $Id$ |
ef870322 |
12 | **/ |
13 | |
ff8a98e7 |
14 | require_once('../src/validate.php'); |
15 | require_once('../functions/display_messages.php'); |
16 | require_once('../functions/imap.php'); |
17 | require_once('../functions/array.php'); |
18 | require_once('../functions/tree.php'); |
d3cdb279 |
19 | |
e1469126 |
20 | $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
7a783442 |
21 | |
b954b6fa |
22 | sqimap_mailbox_list($imap_stream); |
d92b6f31 |
23 | |
24 | $mailbox = $trash_folder; |
97dd6a62 |
25 | $boxes = sqimap_mailbox_list($imap_stream); |
26 | $dm = sqimap_get_delimiter($imap_stream); |
7cad6205 |
27 | |
0a1d5f3a |
28 | // According to RFC2060, a DELETE command should NOT remove inferiors (sub folders) |
29 | // so lets go through the list of subfolders and remove them before removing the |
30 | // parent. |
0a1d5f3a |
31 | |
97dd6a62 |
32 | /** First create the top node in the tree **/ |
33 | for ($i = 0;$i < count($boxes);$i++) { |
34 | if (($boxes[$i]["unformatted"] == $mailbox) && (strlen($boxes[$i]["unformatted"]) == strlen($mailbox))) { |
35 | $foldersTree[0]["value"] = $mailbox; |
36 | $foldersTree[0]["doIHaveChildren"] = false; |
37 | continue; |
38 | } |
39 | } |
40 | // Now create the nodes for subfolders of the parent folder |
41 | // You can tell that it is a subfolder by tacking the mailbox delimiter |
42 | // on the end of the $mailbox string, and compare to that. |
43 | $j = 0; |
44 | for ($i = 0;$i < count($boxes);$i++) { |
45 | if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == ($mailbox . $dm)) { |
c5f5cd59 |
46 | addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree); |
97dd6a62 |
47 | } |
48 | } |
49 | |
50 | // now lets go through the tree and delete the folders |
294bf31a |
51 | walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree); |
a11899fd |
52 | |
e9f8ea4e |
53 | $location = get_location(); |
54 | header ("Location: $location/left_main.php"); |
55 | |
97dd6a62 |
56 | sqimap_logout($imap_stream); |
ff8a98e7 |
57 | ?> |