fixed bug with "boundary" maybe being uppercase (pine)
[squirrelmail.git] / src / folders_delete.php
CommitLineData
b40316f9 1<?
97dd6a62 2 /*
3 * Incoming values:
4 * $mailbox - selected mailbox from the form
5 */
6
d068c0ec 7 if (!isset($config_php))
8 include("../config/config.php");
9 if (!isset($strings_php))
10 include("../functions/strings.php");
11 if (!isset($page_header_php))
12 include("../functions/page_header.php");
13 if (!isset($imap_php))
14 include("../functions/imap.php");
15 if (!isset($array_php))
16 include("../functions/array.php");
97dd6a62 17 if (!isset($tree_php))
18 include("../functions/tree.php");
b40316f9 19
d3cdb279 20 include("../src/load_prefs.php");
21
aff57ea5 22 echo "<HTML>";
23 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
91f999f6 24 displayPageHeader($color, "None");
97dd6a62 25
91f999f6 26
97dd6a62 27 $imap_stream = sqimap_login($username, $key, $imapServerAddress, 0);
28 $boxes = sqimap_mailbox_list ($imap_stream);
29 $dm = sqimap_get_delimiter($imap_stream);
abddc974 30 if (substr($mailbox, -1) == $dm)
31 $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1);
32 else
33 $mailbox_no_dm = $mailbox;
d92b6f31 34
d92b6f31 35 /** lets see if we CAN move folders to the trash.. otherwise, just delete them **/
97dd6a62 36 for ($i = 0; $i < count($boxes); $i++) {
813eba2f 37 if ($boxes[$i]["unformatted"] == $trash_folder) {
38 $can_move_to_trash = true;
97dd6a62 39 for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
40 if (strtolower($boxes[$i]["flags"][$j]) == "noinferiors")
813eba2f 41 $can_move_to_trash = false;
42 }
43 }
d92b6f31 44 }
54e3c1d8 45
54e3c1d8 46
97dd6a62 47 /** First create the top node in the tree **/
48 for ($i = 0;$i < count($boxes);$i++) {
abddc974 49 if (($boxes[$i]["unformatted-dm"] == $mailbox) && (strlen($boxes[$i]["unformatted-dm"]) == strlen($mailbox))) {
97dd6a62 50 $foldersTree[0]["value"] = $mailbox;
51 $foldersTree[0]["doIHaveChildren"] = false;
52 continue;
54e3c1d8 53 }
97dd6a62 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 $j = 0;
59 for ($i = 0;$i < count($boxes);$i++) {
abddc974 60 if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $dm)) == ($mailbox_no_dm . $dm)) {
abddc974 61 addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
54e3c1d8 62 }
8c7dfc99 63 }
abddc974 64// simpleWalkTreePre(0, $foldersTree);
b40316f9 65
97dd6a62 66 /** Lets start removing the folders and messages **/
67 if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/
68 walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $dm, $mailbox);
69 walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
70 } else { /** if they do NOT wish to move messages to the trash (or cannot)**/
71 walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
72 }
73
54e3c1d8 74 /** Log out this session **/
97dd6a62 75 sqimap_logout($imap_stream);
b40316f9 76
aff57ea5 77 echo "<BR><BR><BR><CENTER><B>";
78 echo _("Folder Deleted!");
79 echo "</B><BR><BR>";
80 echo _("The folder has been successfully deleted.");
bd8bf491 81 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
aff57ea5 82 echo _("Click here");
bd8bf491 83 echo "</A> ";
aff57ea5 84 echo _("to continue.");
aae41ae9 85 echo "</CENTER>";
91f999f6 86
f8f9bed9 87 echo "</BODY></HTML>";
b40316f9 88?>