Added option to do data and attachment directory hashing, up to four levels. Will...
[squirrelmail.git] / src / empty_trash.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * empty_trash.php
5 *
6 * Copyright (c) 1999-2001 The Squirrelmail Development Team
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 *
12 * $Id$
13 */
ef870322 14
35586184 15/*****************************************************************/
16/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
17/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
18/*** + Base level indent should begin at left margin, as ***/
19/*** the require_once below looks. ***/
20/*** + All identation should consist of four space blocks ***/
21/*** + Tab characters are evil. ***/
22/*** + all comments should use "slash-star ... star-slash" ***/
23/*** style -- no pound characters, no slash-slash style ***/
24/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
25/*** ALWAYS USE { AND } CHARACTERS!!! ***/
26/*** + Please use ' instead of ", when possible. Note " ***/
27/*** should always be used in _( ) function calls. ***/
28/*** Thank you for your help making the SM code more readable. ***/
29/*****************************************************************/
30
31require_once('../src/validate.php');
32require_once('../functions/display_messages.php');
33require_once('../functions/imap.php');
34require_once('../functions/array.php');
35require_once('../functions/tree.php');
d3cdb279 36
e1469126 37 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
7a783442 38
b954b6fa 39 sqimap_mailbox_list($imap_stream);
d92b6f31 40
41 $mailbox = $trash_folder;
97dd6a62 42 $boxes = sqimap_mailbox_list($imap_stream);
525b7ae6 43 global $delimiter;
7cad6205 44
0a1d5f3a 45 // According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
46 // so lets go through the list of subfolders and remove them before removing the
47 // parent.
0a1d5f3a 48
97dd6a62 49 /** First create the top node in the tree **/
50 for ($i = 0;$i < count($boxes);$i++) {
51 if (($boxes[$i]["unformatted"] == $mailbox) && (strlen($boxes[$i]["unformatted"]) == strlen($mailbox))) {
52 $foldersTree[0]["value"] = $mailbox;
53 $foldersTree[0]["doIHaveChildren"] = false;
54 continue;
55 }
56 }
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.
60 $j = 0;
61 for ($i = 0;$i < count($boxes);$i++) {
525b7ae6 62 if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
c5f5cd59 63 addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
97dd6a62 64 }
65 }
66
67 // now lets go through the tree and delete the folders
294bf31a 68 walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
a11899fd 69
e9f8ea4e 70 $location = get_location();
71 header ("Location: $location/left_main.php");
72
97dd6a62 73 sqimap_logout($imap_stream);
525b7ae6 74?>