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