6 * Handles deleting messages from the trash folder without
9 * @copyright © 1999-2007 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
15 /** This is the empty_trash page */
16 define('PAGE_NAME', 'empty_trash');
19 * Include the SquirrelMail initialization file.
21 require('../include/init.php');
23 require(SM_PATH
. 'functions/imap_general.php');
24 require(SM_PATH
. 'functions/imap_messages.php');
25 require(SM_PATH
. 'functions/tree.php');
27 /* get those globals */
29 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
31 /* finished globals */
33 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
35 $mailbox = $trash_folder;
36 $boxes = sqimap_mailbox_list($imap_stream);
39 * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
40 * so lets go through the list of subfolders and remove them before removing the
44 /** First create the top node in the tree **/
45 $numboxes = count($boxes);
46 for ($i = 0; $i < $numboxes; $i++
) {
47 if (($boxes[$i]['unformatted'] == $mailbox) && (strlen($boxes[$i]['unformatted']) == strlen($mailbox))) {
48 $foldersTree[0]['value'] = $mailbox;
49 $foldersTree[0]['doIHaveChildren'] = false;
54 * Now create the nodes for subfolders of the parent folder
55 * You can tell that it is a subfolder by tacking the mailbox delimiter
56 * on the end of the $mailbox string, and compare to that.
59 for ($i = 0; $i < $numboxes; $i++
) {
60 if (substr($boxes[$i]['unformatted'], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
61 addChildNodeToTree($boxes[$i]['unformatted'], $boxes[$i]['unformatted-dm'], $foldersTree);
65 // now lets go through the tree and delete the folders
66 walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
67 // update mailbox cache
68 $mailboxes=sqimap_get_mailboxes($imap_stream,true,$show_only_subscribed_folders);
69 sqimap_logout($imap_stream);
71 // close session properly before redirecting
72 session_write_close();
74 $location = get_location();
75 header ("Location: $location/left_main.php");