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