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 * Path for SquirrelMail required files.
19 define('SM_PATH','../');
21 /* SquirrelMail required files. */
22 require_once(SM_PATH
. 'include/validate.php');
23 require_once(SM_PATH
. 'functions/display_messages.php');
24 require_once(SM_PATH
. 'functions/imap.php');
25 require_once(SM_PATH
. 'functions/tree.php');
27 /* get those globals */
29 sqgetGlobalVar('username', $username, SQ_SESSION
);
30 sqgetGlobalVar('key', $key, SQ_COOKIE
);
31 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
32 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
34 /* finished globals */
36 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
38 $mailbox = $trash_folder;
39 $boxes = sqimap_mailbox_list($imap_stream);
42 * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
43 * so lets go through the list of subfolders and remove them before removing the
47 /** First create the top node in the tree **/
48 $numboxes = count($boxes);
49 for ($i = 0; $i < $numboxes; $i++
) {
50 if (($boxes[$i]['unformatted'] == $mailbox) && (strlen($boxes[$i]['unformatted']) == strlen($mailbox))) {
51 $foldersTree[0]['value'] = $mailbox;
52 $foldersTree[0]['doIHaveChildren'] = false;
57 * Now create the nodes for subfolders of the parent folder
58 * You can tell that it is a subfolder by tacking the mailbox delimiter
59 * on the end of the $mailbox string, and compare to that.
62 for ($i = 0; $i < $numboxes; $i++
) {
63 if (substr($boxes[$i]['unformatted'], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
64 addChildNodeToTree($boxes[$i]['unformatted'], $boxes[$i]['unformatted-dm'], $foldersTree);
68 // now lets go through the tree and delete the folders
69 walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
70 sqimap_logout($imap_stream);
72 // close session properly before redirecting
73 session_write_close();
75 $location = get_location();
76 header ("Location: $location/left_main.php");