bugfix. table was incorrectly closed when system had more than one backend listing.
[squirrelmail.git] / src / empty_trash.php
... / ...
CommitLineData
1<?php
2
3/**
4 * empty_trash.php
5 *
6 * Copyright (c) 1999-2004 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 * @package squirrelmail
14 */
15
16/** Path for SquirrelMail required files. */
17define('SM_PATH','../');
18
19/* SquirrelMail required files. */
20require_once(SM_PATH . 'include/validate.php');
21require_once(SM_PATH . 'functions/display_messages.php');
22require_once(SM_PATH . 'functions/imap.php');
23require_once(SM_PATH . 'functions/tree.php');
24
25/* get those globals */
26
27sqgetGlobalVar('username', $username, SQ_SESSION);
28sqgetGlobalVar('key', $key, SQ_COOKIE);
29sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
30sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
31
32/* finished globals */
33
34$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
35
36$mailbox = $trash_folder;
37$boxes = sqimap_mailbox_list($imap_stream);
38
39/*
40 * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
41 * so lets go through the list of subfolders and remove them before removing the
42 * parent.
43 */
44
45/** First create the top node in the tree **/
46$numboxes = count($boxes);
47for ($i = 0; $i < $numboxes; $i++) {
48 if (($boxes[$i]['unformatted'] == $mailbox) && (strlen($boxes[$i]['unformatted']) == strlen($mailbox))) {
49 $foldersTree[0]['value'] = $mailbox;
50 $foldersTree[0]['doIHaveChildren'] = false;
51 continue;
52 }
53}
54/*
55 * Now create the nodes for subfolders of the parent folder
56 * You can tell that it is a subfolder by tacking the mailbox delimiter
57 * on the end of the $mailbox string, and compare to that.
58 */
59$j = 0;
60for ($i = 0; $i < $numboxes; $i++) {
61 if (substr($boxes[$i]['unformatted'], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
62 addChildNodeToTree($boxes[$i]['unformatted'], $boxes[$i]['unformatted-dm'], $foldersTree);
63 }
64}
65
66// now lets go through the tree and delete the folders
67walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
68
69$location = get_location();
70header ("Location: $location/left_main.php");
71
72sqimap_logout($imap_stream);
73?>