6 * Handles deleting messages from the trash folder without
9 * @copyright © 1999-2006 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
16 * Include the SquirrelMail initialization file.
18 require('../include/init.php');
20 require(SM_PATH
. 'functions/imap_general.php');
21 require(SM_PATH
. 'functions/imap_messages.php');
22 require(SM_PATH
. 'functions/tree.php');
24 /* get those globals */
26 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
28 /* finished globals */
30 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
32 $mailbox = $trash_folder;
33 $boxes = sqimap_mailbox_list($imap_stream);
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
41 /** First create the top node in the tree **/
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;
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.
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);
62 // now lets go through the tree and delete the folders
63 walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
64 // update mailbox cache
65 $mailboxes=sqimap_get_mailboxes($imap_stream,true,$show_only_subscribed_folders);
66 sqimap_logout($imap_stream);
68 // close session properly before redirecting
69 session_write_close();
71 $location = get_location();
72 header ("Location: $location/left_main.php");