59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * folders.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Handles all interaction between the user and the other folder |
10 | * scripts which do most of the work. Also handles the Special |
11 | * Folders. |
12 | * |
13 | * $Id$ |
14 | */ |
15 | |
35586184 |
16 | require_once('../src/validate.php'); |
994163eb |
17 | require_once('../functions/imap_utf7_decode_local.php'); |
35586184 |
18 | require_once('../functions/imap.php'); |
19 | require_once('../functions/array.php'); |
20 | require_once('../functions/plugin.php'); |
d3cdb279 |
21 | |
e634431a |
22 | displayPageHeader($color, 'None'); |
aa42fbfb |
23 | |
e7db48af |
24 | ?> |
25 | |
e7db48af |
26 | <br> |
27 | <table bgcolor="<?php echo $color[0] ?>" width="95%" align="center" cellpadding="2" cellspacing="0" border="0"> |
28 | <tr><td align="center"> |
29 | |
c8cc8352 |
30 | <b><?php echo _("Folders"); ?></b> |
e7db48af |
31 | |
32 | <table width="100%" border="0" cellpadding="5" cellspacing="0"> |
33 | <tr><td bgcolor="<?php echo $color[4] ?>" align="center"> |
34 | |
35 | <?php |
aa42fbfb |
36 | |
1c52ba77 |
37 | if ((isset($success) && $success) || |
38 | (isset($sent_create) && $sent_create == 'true') || |
39 | (isset($trash_create) && $trash_create == 'true')) { |
40 | echo "<table width=\"100%\" align=center cellpadding=4 cellspacing=0 border=0>\n" . |
41 | " <tr><td align=center>\n"; |
e634431a |
42 | if ($success == "subscribe") { |
43 | echo "<b>" . _("Subscribed successfully!") . "</b><br>"; |
44 | } else if ($success == "unsubscribe") { |
45 | echo "<b>" . _("Unsubscribed successfully!") . "</b><br>"; |
46 | } else if ($success == "delete") { |
47 | echo "<b>" . _("Deleted folder successfully!") . "</b><br>"; |
48 | } else if ($success == "create") { |
49 | echo "<b>" . _("Created folder successfully!") . "</b><br>"; |
50 | } else if ($success == "rename") { |
51 | echo "<b>" . _("Renamed successfully!") . "</b><br>"; |
52 | } |
53 | |
1c52ba77 |
54 | echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>". |
55 | " </td></tr>\n"; |
56 | "</table><br>\n"; |
e634431a |
57 | } else { |
58 | echo "<br>"; |
59 | } |
60 | $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0); |
61 | $boxes = sqimap_mailbox_list($imapConnection); |
62 | |
63 | /** CREATING FOLDERS **/ |
1c52ba77 |
64 | echo "<TABLE WIDTH=\"70%\" COLS=1 ALIGN=CENTER cellpadding=4 cellspacing=0 border=0>\n". |
65 | "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>". |
66 | _("Create Folder"). |
67 | "</B></TD></TR>". |
68 | "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>". |
69 | "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n". |
70 | "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n". |
71 | _("as a subfolder of"). |
72 | "<BR>". |
73 | "<TT><SELECT NAME=subfolder>\n"; |
e634431a |
74 | if ($default_sub_of_inbox == false) { |
75 | echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n"; |
76 | } else { |
77 | echo '<OPTION VALUE="">[ '._("None")." ]\n"; |
78 | } |
79 | |
80 | for ($i = 0; $i < count($boxes); $i++) { |
81 | if (!in_array('noinferiors', $boxes[$i]['flags'])) { |
1c52ba77 |
82 | if ((strtolower($boxes[$i]['unformatted']) == 'inbox') && |
83 | $default_sub_of_inbox) { |
994163eb |
84 | |
1c52ba77 |
85 | $box = $boxes[$i]['unformatted']; |
994163eb |
86 | $box2 = imap_utf7_decode_local( |
87 | str_replace(' ', ' ', $boxes[$i]['unformatted-disp'])); |
1c52ba77 |
88 | echo "<OPTION SELECTED VALUE=\"$box\">$box2</option>\n"; |
e634431a |
89 | } else { |
1c52ba77 |
90 | $box = $boxes[$i]['unformatted']; |
994163eb |
91 | $box2 = imap_utf7_decode_local( |
92 | str_replace(' ', ' ', $boxes[$i]['unformatted-disp'])); |
1c52ba77 |
93 | if (strtolower($imap_server_type) != 'courier' || |
e634431a |
94 | strtolower($box) != "inbox.trash") |
1c52ba77 |
95 | echo "<OPTION VALUE=\"$box\">$box2</option>\n"; |
e634431a |
96 | } |
97 | } |
98 | } |
99 | echo "</SELECT></TT>\n"; |
100 | if ($show_contain_subfolders_option) { |
101 | echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> "; |
102 | echo _("Let this folder contain subfolders"); |
103 | echo "<BR>"; |
1c52ba77 |
104 | } |
e634431a |
105 | echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n"; |
106 | echo "</FORM></TD></TR>\n"; |
107 | |
108 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
109 | |
0037f048 |
110 | |
111 | /** count special folders **/ |
112 | $count_special_folders = 0; |
113 | $num_max = 1; |
114 | if (strtolower($imap_server_type) == "courier" || $move_to_trash) { |
115 | $num_max++; |
116 | } |
117 | if ($move_to_sent) { |
118 | $num_max++; |
119 | } |
120 | if ($save_as_draft) { |
121 | $num_max++; |
122 | } |
123 | for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++) { |
124 | if (strtolower($boxes[$p]['unformatted']) == 'inbox') |
125 | $count_special_folders++; |
126 | else if (strtolower($imap_server_type) == 'courier' && |
127 | strtolower($boxes[$p]['unformatted']) == 'inbox.trash') |
128 | $count_special_folders++; |
129 | else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder) |
130 | $count_special_folders++; |
131 | else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder) |
132 | $count_special_folders++; |
133 | else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder) |
134 | $count_special_folders++; |
135 | } |
136 | |
137 | |
e634431a |
138 | /** RENAMING FOLDERS **/ |
1c52ba77 |
139 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>". |
140 | _("Rename a Folder"). |
141 | "</B></TD></TR>". |
142 | "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
0037f048 |
143 | if ($count_special_folders < count($boxes)) { |
144 | echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n" |
145 | . "<TT><SELECT NAME=old>\n" |
146 | . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n"; |
e634431a |
147 | for ($i = 0; $i < count($boxes); $i++) { |
148 | $use_folder = true; |
149 | |
1c52ba77 |
150 | if ((strtolower($boxes[$i]['unformatted']) != 'inbox') && |
151 | ($boxes[$i]['unformatted'] != $trash_folder) && |
152 | ($boxes[$i]['unformatted'] != $sent_folder) && |
153 | ($boxes[$i]['unformatted'] != $draft_folder)) { |
154 | $box = $boxes[$i]['unformatted-dm']; |
155 | |
994163eb |
156 | $box2 = imap_utf7_decode_local( |
157 | str_replace(' ', ' ', $boxes[$i]['unformatted-disp'])); |
1c52ba77 |
158 | if (strtolower($imap_server_type) != 'courier' || strtolower($box) != 'inbox.trash') { |
159 | echo "<OPTION VALUE=\"$box\">$box2</option>\n"; |
160 | } |
e634431a |
161 | } |
162 | } |
1c52ba77 |
163 | echo "</SELECT></TT>\n". |
164 | "<INPUT TYPE=SUBMIT VALUE=\"". |
165 | _("Rename"). |
166 | "\">\n". |
167 | "</FORM></TD></TR>\n"; |
e634431a |
168 | } else { |
169 | echo _("No folders found") . "<br><br></td></tr>"; |
170 | } |
171 | $boxes_sub = $boxes; |
172 | |
173 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
174 | |
175 | /** DELETING FOLDERS **/ |
176 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
177 | echo _("Delete Folder"); |
178 | echo "</B></TD></TR>"; |
179 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
180 | |
e634431a |
181 | if ($count_special_folders < count($boxes)) { |
0037f048 |
182 | echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n" |
183 | . "<TT><SELECT NAME=mailbox>\n" |
184 | . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n"; |
e634431a |
185 | for ($i = 0; $i < count($boxes); $i++) { |
186 | $use_folder = true; |
1c52ba77 |
187 | if ((strtolower($boxes[$i]['unformatted']) != 'inbox') && |
188 | ($boxes[$i]['unformatted'] != $trash_folder) && |
189 | ($boxes[$i]['unformatted'] != $sent_folder) && |
190 | ($boxes[$i]['unformatted'] != $draft_folder) && |
11f6f685 |
191 | (!in_array('noselect', $boxes[$i]['flags'])) && |
1c52ba77 |
192 | ((strtolower($imap_server_type) != 'courier') || |
193 | (strtolower($boxes[$i]['unformatted']) != 'inbox.trash'))) { |
194 | $box = $boxes[$i]['unformatted-dm']; |
994163eb |
195 | $box2 = imap_utf7_decode_local( |
196 | str_replace(' ', ' ', $boxes[$i]['unformatted-disp'])); |
1c52ba77 |
197 | echo " <OPTION VALUE=\"$box\">$box2</option>\n"; |
e634431a |
198 | } |
199 | } |
200 | echo "</SELECT></TT>\n"; |
201 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
202 | echo _("Delete"); |
203 | echo "\">\n"; |
204 | echo "</FORM></TD></TR>\n"; |
205 | } else { |
206 | echo _("No folders found") . "<br><br></td><tr>"; |
207 | } |
208 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n"; |
209 | |
210 | /** UNSUBSCRIBE FOLDERS **/ |
211 | echo "<TABLE WIDTH=\"70%\" COLS=2 ALIGN=CENTER cellpadding=4 cellspacing=0 border=0>\n"; |
212 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=2><B>"; |
213 | echo _("Unsubscribe") . "/" . _("Subscribe"); |
214 | echo "</B></TD></TR>\n"; |
215 | echo "<TR><TD BGCOLOR=\"$color[0]\" width=\"50%\" ALIGN=CENTER>\n"; |
216 | if ($count_special_folders < count($boxes)) { |
217 | echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"; |
218 | echo "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n"; |
219 | for ($i = 0; $i < count($boxes); $i++) { |
220 | $use_folder = true; |
221 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
222 | ($boxes[$i]["unformatted"] != $trash_folder) && |
223 | ($boxes[$i]["unformatted"] != $sent_folder) && |
224 | ($boxes[$i]["unformatted"] != $draft_folder)) { |
225 | $box = $boxes[$i]["unformatted-dm"]; |
994163eb |
226 | $box2 = imap_utf7_decode_local( |
227 | str_replace(' ', ' ', $boxes[$i]["unformatted-disp"])); |
e634431a |
228 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
229 | } |
230 | } |
231 | echo "</SELECT></TT><br><br>\n"; |
232 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
233 | echo _("Unsubscribe"); |
234 | echo "\">\n"; |
235 | echo "</FORM></TD>\n"; |
236 | } else { |
237 | echo _("No folders were found to unsubscribe from!") . "</td>"; |
238 | } |
239 | $boxes_sub = $boxes; |
240 | |
241 | /** SUBSCRIBE TO FOLDERS **/ |
242 | echo "<TD BGCOLOR=\"$color[0]\" width=\"50%\" ALIGN=CENTER>"; |
243 | $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1); |
244 | $boxes_all = sqimap_mailbox_list_all ($imap_stream); |
245 | |
246 | $box = ""; |
247 | $box2 = ""; |
248 | for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { |
249 | $use_folder = true; |
250 | for ($p = 0; $p < count ($boxes); $p++) { |
251 | if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) { |
252 | $use_folder = false; |
253 | continue; |
254 | } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) { |
255 | $use_folder = false; |
256 | } |
257 | } |
7e235a1a |
258 | if ($use_folder == true) { |
e634431a |
259 | $box[$q] = $boxes_all[$i]["unformatted-dm"]; |
994163eb |
260 | $box2[$q] = imap_utf7_decode_local($boxes_all[$i]["unformatted-disp"]); |
e634431a |
261 | $q++; |
262 | } |
263 | } |
264 | sqimap_logout($imap_stream); |
265 | |
266 | if ($box && $box2) { |
267 | echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"; |
268 | echo "<tt><select name=\"mailbox[]\" multiple size=8>"; |
269 | |
270 | for ($q = 0; $q < count($box); $q++) { |
271 | echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n"; |
272 | } |
273 | echo "</select></tt><br><br>"; |
274 | echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n"; |
275 | echo "</FORM></TD></TR></TABLE><BR>\n"; |
276 | } else { |
277 | echo _("No folders were found to subscribe to!") . "</td></tr></table>"; |
278 | } |
e7db48af |
279 | |
bd9bbfef |
280 | do_hook("folders_bottom"); |
281 | ?> |
e7db48af |
282 | |
60573cd9 |
283 | |
e7db48af |
284 | </td></tr> |
285 | </table> |
286 | |
287 | </td></tr> |
288 | </table> |
289 | |
290 | <?php |
1195c340 |
291 | sqimap_logout($imapConnection); |
aa42fbfb |
292 | ?> |
e7db48af |
293 | |
0037f048 |
294 | </body></html> |