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