updated docs
[squirrelmail.git] / src / empty_trash.php
1 <?php
2 /**
3 ** empty_trash.php
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** Handles deleting messages from the trash folder without
9 ** deleting subfolders.
10 **
11 ** $Id$
12 **/
13
14 include('../src/validate.php');
15 include("../functions/strings.php");
16 include("../config/config.php");
17 include("../functions/page_header.php");
18 include("../functions/display_messages.php");
19 include("../functions/imap.php");
20 include("../functions/array.php");
21 include("../functions/tree.php");
22 include("../src/load_prefs.php");
23
24 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
25
26 sqimap_mailbox_list($imap_stream);
27
28 $mailbox = $trash_folder;
29 $boxes = sqimap_mailbox_list($imap_stream);
30 $dm = sqimap_get_delimiter($imap_stream);
31
32 // According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
33 // so lets go through the list of subfolders and remove them before removing the
34 // parent.
35
36 /** First create the top node in the tree **/
37 for ($i = 0;$i < count($boxes);$i++) {
38 if (($boxes[$i]["unformatted"] == $mailbox) && (strlen($boxes[$i]["unformatted"]) == strlen($mailbox))) {
39 $foldersTree[0]["value"] = $mailbox;
40 $foldersTree[0]["doIHaveChildren"] = false;
41 continue;
42 }
43 }
44 // Now create the nodes for subfolders of the parent folder
45 // You can tell that it is a subfolder by tacking the mailbox delimiter
46 // on the end of the $mailbox string, and compare to that.
47 $j = 0;
48 for ($i = 0;$i < count($boxes);$i++) {
49 if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == ($mailbox . $dm)) {
50 addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
51 }
52 }
53
54 // now lets go through the tree and delete the folders
55 walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
56
57 $location = get_location();
58 header ("Location: $location/left_main.php");
59
60 sqimap_logout($imap_stream);
61 ?>