Spanish Update
[squirrelmail.git] / src / empty_trash.php
... / ...
CommitLineData
1<?php
2
3/**
4 * empty_trash.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project 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 */
14
15/* Path for SquirrelMail required files. */
16define('SM_PATH','../');
17
18/* SquirrelMail required files. */
19require_once(SM_PATH . 'include/validate.php');
20require_once(SM_PATH . 'functions/display_messages.php');
21require_once(SM_PATH . 'functions/imap.php');
22require_once(SM_PATH . 'functions/array.php');
23require_once(SM_PATH . 'functions/tree.php');
24
25$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
26
27sqimap_mailbox_list($imap_stream);
28
29$mailbox = $trash_folder;
30$boxes = sqimap_mailbox_list($imap_stream);
31global $delimiter;
32
33/*
34 * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
35 * so lets go through the list of subfolders and remove them before removing the
36 * parent.
37 */
38
39/** First create the top node in the tree **/
40for ($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/*
48 * Now create the nodes for subfolders of the parent folder
49 * You can tell that it is a subfolder by tacking the mailbox delimiter
50 * on the end of the $mailbox string, and compare to that.
51 */
52$j = 0;
53for ($i = 0;$i < count($boxes);$i++) {
54 if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
55 addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
56 }
57}
58
59// now lets go through the tree and delete the folders
60walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
61
62$location = get_location();
63header ("Location: $location/left_main.php");
64
65sqimap_logout($imap_stream);
66?>