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