6 * $mailbox - selected mailbox from the form
9 if (!isset($config_php))
10 include("../config/config.php");
11 if (!isset($strings_php))
12 include("../functions/strings.php");
13 if (!isset($page_header_php))
14 include("../functions/page_header.php");
15 if (!isset($imap_php))
16 include("../functions/imap.php");
17 if (!isset($array_php))
18 include("../functions/array.php");
19 if (!isset($tree_php))
20 include("../functions/tree.php");
22 include("../src/load_prefs.php");
25 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
26 displayPageHeader($color, "None");
29 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
30 $boxes = sqimap_mailbox_list ($imap_stream);
31 $dm = sqimap_get_delimiter($imap_stream);
32 $mailbox = stripslashes($mailbox);
34 if (substr($mailbox, -1) == $dm)
35 $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1);
37 $mailbox_no_dm = $mailbox;
39 /** lets see if we CAN move folders to the trash.. otherwise, just delete them **/
40 for ($i = 0; $i < count($boxes); $i++
) {
41 if ($boxes[$i]["unformatted"] == $trash_folder) {
42 $can_move_to_trash = true;
43 for ($j = 0; $j < count($boxes[$i]["flags"]); $j++
) {
44 if (strtolower($boxes[$i]["flags"][$j]) == "noinferiors")
45 $can_move_to_trash = false;
51 /** First create the top node in the tree **/
52 for ($i = 0;$i < count($boxes);$i++
) {
53 if (($boxes[$i]["unformatted-dm"] == $mailbox) && (strlen($boxes[$i]["unformatted-dm"]) == strlen($mailbox))) {
54 $foldersTree[0]["value"] = $mailbox;
55 $foldersTree[0]["doIHaveChildren"] = false;
59 // Now create the nodes for subfolders of the parent folder
60 // You can tell that it is a subfolder by tacking the mailbox delimiter
61 // on the end of the $mailbox string, and compare to that.
63 for ($i = 0;$i < count($boxes);$i++
) {
64 if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $dm)) == ($mailbox_no_dm . $dm)) {
65 addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
68 // simpleWalkTreePre(0, $foldersTree);
70 /** Lets start removing the folders and messages **/
71 if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/
72 walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $dm, $mailbox);
73 walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
74 } else { /** if they do NOT wish to move messages to the trash (or cannot)**/
75 walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
78 /** Log out this session **/
79 sqimap_logout($imap_stream);
81 echo "<BR><BR><BR><CENTER><B>";
82 echo _("Folder Deleted!");
84 echo _("The folder has been successfully deleted.");
85 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
88 echo _("to continue.");
91 echo "</BODY></HTML>";