Add functions to help diagnose if plugin dependencies are in place
[squirrelmail.git] / src / empty_trash.php
1 <?php
2
3 /**
4 * empty_trash.php
5 *
6 * Handles deleting messages from the trash folder without
7 * deleting subfolders.
8 *
9 * @copyright &copy; 1999-2007 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @version $Id$
12 * @package squirrelmail
13 */
14
15 /**
16 * Include the SquirrelMail initialization file.
17 */
18 require('../include/init.php');
19
20 require(SM_PATH . 'functions/imap_general.php');
21 require(SM_PATH . 'functions/imap_messages.php');
22 require(SM_PATH . 'functions/tree.php');
23
24 /* get those globals */
25
26 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
27
28 /* finished globals */
29
30 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
31
32 $mailbox = $trash_folder;
33 $boxes = sqimap_mailbox_list($imap_stream);
34
35 /*
36 * According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
37 * so lets go through the list of subfolders and remove them before removing the
38 * parent.
39 */
40
41 /** First create the top node in the tree **/
42 $numboxes = count($boxes);
43 for ($i = 0; $i < $numboxes; $i++) {
44 if (($boxes[$i]['unformatted'] == $mailbox) && (strlen($boxes[$i]['unformatted']) == strlen($mailbox))) {
45 $foldersTree[0]['value'] = $mailbox;
46 $foldersTree[0]['doIHaveChildren'] = false;
47 continue;
48 }
49 }
50 /*
51 * Now create the nodes for subfolders of the parent folder
52 * You can tell that it is a subfolder by tacking the mailbox delimiter
53 * on the end of the $mailbox string, and compare to that.
54 */
55 $j = 0;
56 for ($i = 0; $i < $numboxes; $i++) {
57 if (substr($boxes[$i]['unformatted'], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
58 addChildNodeToTree($boxes[$i]['unformatted'], $boxes[$i]['unformatted-dm'], $foldersTree);
59 }
60 }
61
62 // now lets go through the tree and delete the folders
63 walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
64 // update mailbox cache
65 $mailboxes=sqimap_get_mailboxes($imap_stream,true,$show_only_subscribed_folders);
66 sqimap_logout($imap_stream);
67
68 // close session properly before redirecting
69 session_write_close();
70
71 $location = get_location();
72 header ("Location: $location/left_main.php");
73
74 ?>