fixes for changed attachment handling
[squirrelmail.git] / src / empty_trash.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * empty_trash.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 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 15require_once('../src/validate.php');
16require_once('../functions/display_messages.php');
17require_once('../functions/imap.php');
18require_once('../functions/array.php');
19require_once('../functions/tree.php');
d3cdb279 20
65c3ec94 21$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
22
23sqimap_mailbox_list($imap_stream);
7a783442 24
65c3ec94 25$mailbox = $trash_folder;
26$boxes = sqimap_mailbox_list($imap_stream);
27global $delimiter;
d92b6f31 28
65c3ec94 29/*
30 * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
31 * so lets go through the list of subfolders and remove them before removing the
32 * parent.
33 */
34
35/** First create the top node in the tree **/
36for ($i = 0;$i < count($boxes);$i++) {
37 if (($boxes[$i]["unformatted"] == $mailbox) && (strlen($boxes[$i]["unformatted"]) == strlen($mailbox))) {
38 $foldersTree[0]["value"] = $mailbox;
39 $foldersTree[0]["doIHaveChildren"] = false;
40 continue;
41 }
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 */
48$j = 0;
49for ($i = 0;$i < count($boxes);$i++) {
50 if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
51 addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
52 }
53}
0a1d5f3a 54
65c3ec94 55// now lets go through the tree and delete the folders
56walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
a11899fd 57
65c3ec94 58$location = get_location();
59header ("Location: $location/left_main.php");
e9f8ea4e 60
65c3ec94 61sqimap_logout($imap_stream);
525b7ae6 62?>