59177427 |
1 | <?php |
2a32fc83 |
2 | session_start(); |
3 | |
97dd6a62 |
4 | /* |
5 | * Incoming values: |
6 | * $mailbox - selected mailbox from the form |
7 | */ |
8 | |
d068c0ec |
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"); |
97dd6a62 |
19 | if (!isset($tree_php)) |
20 | include("../functions/tree.php"); |
b40316f9 |
21 | |
d3cdb279 |
22 | include("../src/load_prefs.php"); |
23 | |
91f999f6 |
24 | displayPageHeader($color, "None"); |
97dd6a62 |
25 | |
91f999f6 |
26 | |
e1469126 |
27 | $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
97dd6a62 |
28 | $boxes = sqimap_mailbox_list ($imap_stream); |
29 | $dm = sqimap_get_delimiter($imap_stream); |
cdee225a |
30 | $mailbox = stripslashes($mailbox); |
31 | |
abddc974 |
32 | if (substr($mailbox, -1) == $dm) |
33 | $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1); |
34 | else |
35 | $mailbox_no_dm = $mailbox; |
d92b6f31 |
36 | |
d92b6f31 |
37 | /** lets see if we CAN move folders to the trash.. otherwise, just delete them **/ |
97dd6a62 |
38 | for ($i = 0; $i < count($boxes); $i++) { |
813eba2f |
39 | if ($boxes[$i]["unformatted"] == $trash_folder) { |
40 | $can_move_to_trash = true; |
97dd6a62 |
41 | for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) { |
42 | if (strtolower($boxes[$i]["flags"][$j]) == "noinferiors") |
813eba2f |
43 | $can_move_to_trash = false; |
44 | } |
45 | } |
d92b6f31 |
46 | } |
54e3c1d8 |
47 | |
54e3c1d8 |
48 | |
97dd6a62 |
49 | /** First create the top node in the tree **/ |
50 | for ($i = 0;$i < count($boxes);$i++) { |
abddc974 |
51 | if (($boxes[$i]["unformatted-dm"] == $mailbox) && (strlen($boxes[$i]["unformatted-dm"]) == strlen($mailbox))) { |
97dd6a62 |
52 | $foldersTree[0]["value"] = $mailbox; |
53 | $foldersTree[0]["doIHaveChildren"] = false; |
54 | continue; |
54e3c1d8 |
55 | } |
97dd6a62 |
56 | } |
57 | // Now create the nodes for subfolders of the parent folder |
58 | // You can tell that it is a subfolder by tacking the mailbox delimiter |
59 | // on the end of the $mailbox string, and compare to that. |
60 | $j = 0; |
61 | for ($i = 0;$i < count($boxes);$i++) { |
abddc974 |
62 | if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $dm)) == ($mailbox_no_dm . $dm)) { |
abddc974 |
63 | addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree); |
54e3c1d8 |
64 | } |
8c7dfc99 |
65 | } |
abddc974 |
66 | // simpleWalkTreePre(0, $foldersTree); |
b40316f9 |
67 | |
97dd6a62 |
68 | /** Lets start removing the folders and messages **/ |
69 | if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/ |
70 | walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $dm, $mailbox); |
71 | walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree); |
72 | } else { /** if they do NOT wish to move messages to the trash (or cannot)**/ |
73 | walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree); |
74 | } |
75 | |
54e3c1d8 |
76 | /** Log out this session **/ |
97dd6a62 |
77 | sqimap_logout($imap_stream); |
b40316f9 |
78 | |
aff57ea5 |
79 | echo "<BR><BR><BR><CENTER><B>"; |
80 | echo _("Folder Deleted!"); |
81 | echo "</B><BR><BR>"; |
82 | echo _("The folder has been successfully deleted."); |
9f2215a1 |
83 | echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>"; |
aff57ea5 |
84 | echo _("Click here"); |
bd8bf491 |
85 | echo "</A> "; |
aff57ea5 |
86 | echo _("to continue."); |
aae41ae9 |
87 | echo "</CENTER>"; |
91f999f6 |
88 | |
f8f9bed9 |
89 | echo "</BODY></HTML>"; |
b40316f9 |
90 | ?> |