fixed an HTML rendering bug in search display
[squirrelmail.git] / src / empty_trash.php
CommitLineData
59177427 1<?php
ef870322 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
2a32fc83 12 session_start();
13
7a783442 14 include("../config/config.php");
7a783442 15 include("../functions/strings.php");
16 include("../functions/page_header.php");
17 include("../functions/display_messages.php");
2aa12d5e 18 include("../functions/imap.php");
8a777b6b 19 if (!function_exists("ary_sort"))
20 include("../functions/array.php");
7a783442 21
97dd6a62 22 if (!isset($tree_php))
23 include("../functions/tree.php");
24
d3cdb279 25 include("../src/load_prefs.php");
26
e1469126 27 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
7a783442 28
97dd6a62 29 sqimap_mailbox_list($imap_stream, $boxes);
d92b6f31 30
31 $mailbox = $trash_folder;
97dd6a62 32 $boxes = sqimap_mailbox_list($imap_stream);
33 $dm = sqimap_get_delimiter($imap_stream);
7cad6205 34
0a1d5f3a 35 // According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
36 // so lets go through the list of subfolders and remove them before removing the
37 // parent.
0a1d5f3a 38
97dd6a62 39 /** First create the top node in the tree **/
40 for ($i = 0;$i < count($boxes);$i++) {
41 if (($boxes[$i]["unformatted"] == $mailbox) && (strlen($boxes[$i]["unformatted"]) == strlen($mailbox))) {
42 $foldersTree[0]["value"] = $mailbox;
43 $foldersTree[0]["doIHaveChildren"] = false;
44 continue;
45 }
46 }
47 // Now create the nodes for subfolders of the parent folder
48 // You can tell that it is a subfolder by tacking the mailbox delimiter
49 // on the end of the $mailbox string, and compare to that.
50 $j = 0;
51 for ($i = 0;$i < count($boxes);$i++) {
52 if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == ($mailbox . $dm)) {
c5f5cd59 53 addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
97dd6a62 54 }
55 }
56
57 // now lets go through the tree and delete the folders
294bf31a 58 walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
a11899fd 59
e9f8ea4e 60 $location = get_location();
61 header ("Location: $location/left_main.php");
62
97dd6a62 63 sqimap_logout($imap_stream);
2aa12d5e 64?>