59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * empty_trash.php |
5 | * |
82d304a0 |
6 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
35586184 |
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. |
11 | * |
30967a1e |
12 | * @version $Id$ |
8f6f9ba5 |
13 | * @package squirrelmail |
35586184 |
14 | */ |
ef870322 |
15 | |
30967a1e |
16 | /** |
17 | * Path for SquirrelMail required files. |
18 | * @ignore |
19 | */ |
86725763 |
20 | define('SM_PATH','../'); |
21 | |
22 | /* SquirrelMail required files. */ |
08185f2a |
23 | require_once(SM_PATH . 'include/validate.php'); |
86725763 |
24 | require_once(SM_PATH . 'functions/display_messages.php'); |
25 | require_once(SM_PATH . 'functions/imap.php'); |
86725763 |
26 | require_once(SM_PATH . 'functions/tree.php'); |
d3cdb279 |
27 | |
a32985a5 |
28 | /* get those globals */ |
29 | |
f38b7cf0 |
30 | sqgetGlobalVar('username', $username, SQ_SESSION); |
31 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
32 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
33 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
a32985a5 |
34 | |
35 | /* finished globals */ |
36 | |
65c3ec94 |
37 | $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
38 | |
65c3ec94 |
39 | $mailbox = $trash_folder; |
40 | $boxes = sqimap_mailbox_list($imap_stream); |
d92b6f31 |
41 | |
65c3ec94 |
42 | /* |
43 | * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders) |
44 | * so lets go through the list of subfolders and remove them before removing the |
45 | * parent. |
46 | */ |
47 | |
48 | /** First create the top node in the tree **/ |
c9acef51 |
49 | $numboxes = count($boxes); |
50 | for ($i = 0; $i < $numboxes; $i++) { |
51 | if (($boxes[$i]['unformatted'] == $mailbox) && (strlen($boxes[$i]['unformatted']) == strlen($mailbox))) { |
52 | $foldersTree[0]['value'] = $mailbox; |
53 | $foldersTree[0]['doIHaveChildren'] = false; |
65c3ec94 |
54 | continue; |
55 | } |
56 | } |
57 | /* |
58 | * Now create the nodes for subfolders of the parent folder |
59 | * You can tell that it is a subfolder by tacking the mailbox delimiter |
60 | * on the end of the $mailbox string, and compare to that. |
61 | */ |
62 | $j = 0; |
c9acef51 |
63 | for ($i = 0; $i < $numboxes; $i++) { |
64 | if (substr($boxes[$i]['unformatted'], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) { |
65 | addChildNodeToTree($boxes[$i]['unformatted'], $boxes[$i]['unformatted-dm'], $foldersTree); |
65c3ec94 |
66 | } |
67 | } |
0a1d5f3a |
68 | |
65c3ec94 |
69 | // now lets go through the tree and delete the folders |
70 | walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree); |
a11899fd |
71 | |
65c3ec94 |
72 | $location = get_location(); |
dcc1cc82 |
73 | header ("Location: $location/left_main.php"); |
e9f8ea4e |
74 | |
65c3ec94 |
75 | sqimap_logout($imap_stream); |
525b7ae6 |
76 | ?> |