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