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