59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * empty_trash.php |
5 | * |
35586184 |
6 | * Handles deleting messages from the trash folder without |
7 | * deleting subfolders. |
8 | * |
4b5049de |
9 | * @copyright © 1999-2007 The SquirrelMail Project Team |
4b4abf93 |
10 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
30967a1e |
11 | * @version $Id$ |
8f6f9ba5 |
12 | * @package squirrelmail |
35586184 |
13 | */ |
ef870322 |
14 | |
30967a1e |
15 | /** |
202bcbcc |
16 | * Include the SquirrelMail initialization file. |
30967a1e |
17 | */ |
202bcbcc |
18 | require('../include/init.php'); |
86725763 |
19 | |
202bcbcc |
20 | require(SM_PATH . 'functions/imap_general.php'); |
21 | require(SM_PATH . 'functions/imap_messages.php'); |
22 | require(SM_PATH . 'functions/tree.php'); |
d3cdb279 |
23 | |
a32985a5 |
24 | /* get those globals */ |
25 | |
f38b7cf0 |
26 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
a32985a5 |
27 | |
28 | /* finished globals */ |
29 | |
906f7e9f |
30 | $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0); |
65c3ec94 |
31 | |
65c3ec94 |
32 | $mailbox = $trash_folder; |
33 | $boxes = sqimap_mailbox_list($imap_stream); |
d92b6f31 |
34 | |
65c3ec94 |
35 | /* |
36 | * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders) |
37 | * so lets go through the list of subfolders and remove them before removing the |
38 | * parent. |
39 | */ |
40 | |
41 | /** First create the top node in the tree **/ |
c9acef51 |
42 | $numboxes = count($boxes); |
43 | for ($i = 0; $i < $numboxes; $i++) { |
44 | if (($boxes[$i]['unformatted'] == $mailbox) && (strlen($boxes[$i]['unformatted']) == strlen($mailbox))) { |
45 | $foldersTree[0]['value'] = $mailbox; |
46 | $foldersTree[0]['doIHaveChildren'] = false; |
65c3ec94 |
47 | continue; |
48 | } |
49 | } |
50 | /* |
51 | * Now create the nodes for subfolders of the parent folder |
52 | * You can tell that it is a subfolder by tacking the mailbox delimiter |
53 | * on the end of the $mailbox string, and compare to that. |
54 | */ |
55 | $j = 0; |
c9acef51 |
56 | for ($i = 0; $i < $numboxes; $i++) { |
57 | if (substr($boxes[$i]['unformatted'], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) { |
58 | addChildNodeToTree($boxes[$i]['unformatted'], $boxes[$i]['unformatted-dm'], $foldersTree); |
65c3ec94 |
59 | } |
60 | } |
0a1d5f3a |
61 | |
65c3ec94 |
62 | // now lets go through the tree and delete the folders |
63 | walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree); |
0d2130f5 |
64 | // update mailbox cache |
65 | $mailboxes=sqimap_get_mailboxes($imap_stream,true,$show_only_subscribed_folders); |
a1eb6f89 |
66 | sqimap_logout($imap_stream); |
67 | |
68 | // close session properly before redirecting |
69 | session_write_close(); |
a11899fd |
70 | |
65c3ec94 |
71 | $location = get_location(); |
dcc1cc82 |
72 | header ("Location: $location/left_main.php"); |
e9f8ea4e |
73 | |
906f7e9f |
74 | ?> |