59177427 |
1 | <?php |
ef870322 |
2 | /** |
3 | ** folders.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 | ** Handles all interaction between the user and the other folder |
9 | ** scripts which do most of the work. Also handles the Special |
10 | ** Folders. |
245a6892 |
11 | ** |
12 | ** $Id$ |
ef870322 |
13 | **/ |
14 | |
2a32fc83 |
15 | session_start(); |
16 | |
d068c0ec |
17 | if (!isset($strings_php)) |
18 | include("../functions/strings.php"); |
245a6892 |
19 | if (!isset($config_php)) |
20 | include("../config/config.php"); |
d068c0ec |
21 | if (!isset($page_header_php)) |
22 | include("../functions/page_header.php"); |
23 | if (!isset($imap_php)) |
24 | include("../functions/imap.php"); |
25 | if (!isset($array_php)) |
26 | include("../functions/array.php"); |
d7d3c4d4 |
27 | if (!isset($plugin_php)) |
28 | include("../functions/plugin.php"); |
aa42fbfb |
29 | |
d3cdb279 |
30 | include("../src/load_prefs.php"); |
31 | |
1181f3bf |
32 | displayPageHeader($color, _("None")); |
aa42fbfb |
33 | |
1195c340 |
34 | echo "<br>"; |
35 | echo "<TABLE WIDTH=95% COLS=1 ALIGN=CENTER>\n"; |
e9f8ea4e |
36 | echo " <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><b>\n"; |
036a8a9d |
37 | echo _("Folders"); |
e9f8ea4e |
38 | echo " </b></TD></TR>\n"; |
aa42fbfb |
39 | echo "</TABLE>\n"; |
40 | |
245a6892 |
41 | if ((isset($success) && $success) || |
42 | (isset($sent_create) && $sent_create == "true") || |
43 | (isset($trash_create) && $trash_create == "true")) { |
1195c340 |
44 | echo "<table width=100% align=center cellpadding=3 cellspacing=0 border=0>\n"; |
e9f8ea4e |
45 | echo " <tr><td><center>\n"; |
1195c340 |
46 | if ($success == "subscribe") { |
47 | echo "<b>" . _("Subscribed successfully!") . "</b><br>"; |
48 | } else if ($success == "unsubscribe") { |
49 | echo "<b>" . _("Unsubscribed successfully!") . "</b><br>"; |
50 | } else if ($success == "delete") { |
51 | echo "<b>" . _("Deleted folder successfully!") . "</b><br>"; |
52 | } else if ($success == "create") { |
53 | echo "<b>" . _("Created folder successfully!") . "</b><br>"; |
54 | } else if ($success == "rename") { |
55 | echo "<b>" . _("Renamed successfully!") . "</b><br>"; |
0e743004 |
56 | } else if (($sent_create == "true") || ($trash_create == "true")) { |
1f936c98 |
57 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
0e743004 |
58 | if ($sent_create == "true") { |
59 | sqimap_mailbox_create ($imapConnection, $sent_folder, ""); |
60 | } |
61 | if ($trash_create == "true") { |
62 | sqimap_mailbox_create ($imapConnection, $trash_folder, ""); |
63 | } |
1f936c98 |
64 | sqimap_logout($imapConnection); |
0e743004 |
65 | echo _("Folders created successfully!"); |
1195c340 |
66 | } |
0e743004 |
67 | |
e9f8ea4e |
68 | echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>"; |
1195c340 |
69 | echo " </center></td></tr>\n"; |
70 | echo "</table><br>\n"; |
71 | } |
e1469126 |
72 | $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0); |
813eba2f |
73 | $boxes = sqimap_mailbox_list($imapConnection); |
60573cd9 |
74 | |
0e743004 |
75 | //display form option for creating Sent and Trash folder |
76 | if ($imap_server_type == "cyrus" && ($sent_folder != "none" || $trash_folder != "none")) { |
5bdd7223 |
77 | if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) || |
78 | (!sqimap_mailbox_exists ($imapConnection, $trash_folder))) { |
0e743004 |
79 | echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n"; |
80 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
81 | echo _("Special Folder Options"); |
82 | echo "</B></TD></TR>"; |
83 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
84 | echo _("In order for SquirrelMail to provide the full set of options you need to create the special folders listed below. Just click the check box and hit the create button."); |
85 | echo "<FORM ACTION=\"folders.php\" METHOD=\"POST\">\n"; |
86 | if (!sqimap_mailbox_exists ($imapConnection, $sent_folder) && $sent_folder != "none") { |
87 | echo _("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create value=true><br>\n"; |
88 | } |
89 | if (!sqimap_mailbox_exists ($imapConnection, $trash_folder) && $trash_folder != "none"){ |
90 | echo _("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create value=true><br>\n"; |
91 | } |
32f4685b |
92 | echo "<INPUT TYPE=submit VALUE="._("Create").">"; |
0e743004 |
93 | echo "</FORM></TD></TR></TABLE><br>"; |
90790bd4 |
94 | } |
90790bd4 |
95 | } |
96 | |
60573cd9 |
97 | /** DELETING FOLDERS **/ |
1195c340 |
98 | echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n"; |
32f4685b |
99 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
036a8a9d |
100 | echo _("Delete Folder"); |
32f4685b |
101 | echo "</B></TD></TR>"; |
1195c340 |
102 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
1e0628fb |
103 | |
225ce239 |
104 | $count_special_folders = 0; |
2c1dc652 |
105 | $num_max = 1; |
106 | if (strtolower($imap_server_type) == "courier" || $move_to_trash) |
107 | $num_max++; |
108 | if ($move_to_sent) |
109 | $num_max++; |
4bbba0d8 |
110 | |
2c1dc652 |
111 | for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++) { |
c36ed9cf |
112 | if (strtolower($boxes[$p]["unformatted"]) == "inbox") |
1e0628fb |
113 | $count_special_folders++; |
2c1dc652 |
114 | else if (strtolower($imap_server_type) == "courier" && |
5bdd7223 |
115 | strtolower($boxes[$p]["unformatted"]) == "inbox.trash") |
1e0628fb |
116 | $count_special_folders++; |
5bdd7223 |
117 | else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder) |
1e0628fb |
118 | $count_special_folders++; |
b93e186d |
119 | else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder) |
120 | $count_special_folders++; |
1e0628fb |
121 | } |
225ce239 |
122 | |
123 | if ($count_special_folders < count($boxes)) { |
9f2215a1 |
124 | echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"; |
225ce239 |
125 | echo "<TT><SELECT NAME=mailbox>\n"; |
126 | for ($i = 0; $i < count($boxes); $i++) { |
127 | $use_folder = true; |
5bdd7223 |
128 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
129 | ($boxes[$i]["unformatted"] != $trash_folder) && |
130 | ($boxes[$i]["unformatted"] != $sent_folder) && |
131 | (strtolower($imap_server_type) != "courier" || |
132 | strtolower($boxes[$i]["unformatted"]) != "inbox.trash")) |
133 | { |
134 | $box = $boxes[$i]["unformatted-dm"]; |
2752bb16 |
135 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
5bdd7223 |
136 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
137 | } |
60573cd9 |
138 | } |
225ce239 |
139 | echo "</SELECT></TT>\n"; |
140 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
141 | echo _("Delete"); |
142 | echo "\">\n"; |
1195c340 |
143 | echo "</FORM></TD></TR>\n"; |
225ce239 |
144 | } else { |
0e743004 |
145 | echo _("No folders found") . "<br><br></td><tr>"; |
60573cd9 |
146 | } |
7ce342dc |
147 | |
1195c340 |
148 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
60573cd9 |
149 | |
150 | /** CREATING FOLDERS **/ |
32f4685b |
151 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
036a8a9d |
152 | echo _("Create Folder"); |
32f4685b |
153 | echo "</B></TD></TR>"; |
1195c340 |
154 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
d7d3c4d4 |
155 | echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n"; |
907165ca |
156 | echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n"; |
036a8a9d |
157 | echo _("as a subfolder of"); |
aae41ae9 |
158 | echo "<BR>"; |
159 | echo "<TT><SELECT NAME=subfolder>\n"; |
2c1dc652 |
160 | if (strtolower($imap_server_type) != "courier"){ |
161 | if ($default_sub_of_inbox == false) |
1181f3bf |
162 | echo '<OPTION SELECTED>[ '._("None")." ]\n"; |
2c1dc652 |
163 | else |
1181f3bf |
164 | echo '<OPTION>[ '._("None")." ]\n"; |
2c1dc652 |
165 | } |
d92b6f31 |
166 | |
7ce342dc |
167 | for ($i = 0; $i < count($boxes); $i++) { |
1f97f59a |
168 | if (count($boxes[$i]["flags"]) > 0) { |
390372b4 |
169 | $noinf = false; |
1f97f59a |
170 | for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) { |
390372b4 |
171 | if ($boxes[$i]["flags"][$j] == "noinferiors") { |
172 | $noinf = true; |
173 | continue; |
174 | } |
1f97f59a |
175 | } |
390372b4 |
176 | if ($noinf == false) { |
177 | if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) { |
178 | $box = $boxes[$i]["unformatted"]; |
2752bb16 |
179 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
390372b4 |
180 | echo "<OPTION SELECTED VALUE=\"$box\">$box2\n"; |
181 | } else { |
182 | $box = $boxes[$i]["unformatted"]; |
2752bb16 |
183 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
2c1dc652 |
184 | if (strtolower($imap_server_type) != "courier" || |
185 | strtolower($box) != "inbox.trash") |
186 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
390372b4 |
187 | } |
188 | } |
1f97f59a |
189 | } else { |
1e0628fb |
190 | if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) { |
1f97f59a |
191 | $box = $boxes[$i]["unformatted"]; |
2752bb16 |
192 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
1f97f59a |
193 | echo "<OPTION SELECTED VALUE=\"$box\">$box2\n"; |
194 | } else { |
195 | $box = $boxes[$i]["unformatted"]; |
2752bb16 |
196 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
2c1dc652 |
197 | if (strtolower($imap_server_type) != "courier" || |
198 | strtolower($box) != "inbox.trash") |
199 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
1f97f59a |
200 | } |
201 | } |
60573cd9 |
202 | } |
7ce342dc |
203 | echo "</SELECT></TT><BR>\n"; |
813eba2f |
204 | if ($show_contain_subfolders_option) { |
aae41ae9 |
205 | echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> "; |
036a8a9d |
206 | echo _("Let this folder contain subfolders"); |
aae41ae9 |
207 | echo "<BR>"; |
813eba2f |
208 | } |
88c81396 |
209 | echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n"; |
1195c340 |
210 | echo "</FORM></TD></TR>\n"; |
211 | |
212 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
60573cd9 |
213 | |
214 | /** RENAMING FOLDERS **/ |
32f4685b |
215 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
036a8a9d |
216 | echo _("Rename a Folder"); |
32f4685b |
217 | echo "</B></TD></TR>"; |
1195c340 |
218 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
225ce239 |
219 | if ($count_special_folders < count($boxes)) { |
9f2215a1 |
220 | echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"; |
225ce239 |
221 | echo "<TT><SELECT NAME=old>\n"; |
222 | for ($i = 0; $i < count($boxes); $i++) { |
223 | $use_folder = true; |
1e0628fb |
224 | |
5bdd7223 |
225 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
226 | ($boxes[$i]["unformatted"] != $trash_folder) && |
227 | ($boxes[$i]["unformatted"] != $sent_folder)) |
228 | { |
229 | $box = $boxes[$i]["unformatted-dm"]; |
2752bb16 |
230 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
5bdd7223 |
231 | if (strtolower($imap_server_type) != "courier" || strtolower($box) != "inbox.trash") |
232 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
233 | } |
60573cd9 |
234 | } |
225ce239 |
235 | echo "</SELECT></TT>\n"; |
236 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
237 | echo _("Rename"); |
238 | echo "\">\n"; |
37578167 |
239 | echo "</FORM></TD></TR>\n"; |
240 | } else { |
0e743004 |
241 | echo _("No folders found") . "<br><br></td></tr>"; |
37578167 |
242 | } |
243 | $boxes_sub = $boxes; |
1195c340 |
244 | |
e9f8ea4e |
245 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n"; |
37578167 |
246 | |
247 | /** UNSUBSCRIBE FOLDERS **/ |
e9f8ea4e |
248 | echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n"; |
32f4685b |
249 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=3><B>"; |
88c81396 |
250 | echo _("Unsubscribe") . "/" . _("Subscribe"); |
32f4685b |
251 | echo "</B></TD></TR>"; |
e9f8ea4e |
252 | echo "<TR><TD BGCOLOR=\"$color[0]\" width=49% ALIGN=CENTER>"; |
37578167 |
253 | if ($count_special_folders < count($boxes)) { |
9f2215a1 |
254 | echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"; |
e9f8ea4e |
255 | echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n"; |
37578167 |
256 | for ($i = 0; $i < count($boxes); $i++) { |
257 | $use_folder = true; |
5bdd7223 |
258 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
259 | ($boxes[$i]["unformatted"] != $trash_folder) && |
260 | ($boxes[$i]["unformatted"] != $sent_folder)) |
261 | { |
262 | $box = $boxes[$i]["unformatted-dm"]; |
2752bb16 |
263 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
5bdd7223 |
264 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
265 | } |
37578167 |
266 | } |
e9f8ea4e |
267 | echo "</SELECT></TT><br>\n"; |
37578167 |
268 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
269 | echo _("Unsubscribe"); |
270 | echo "\">\n"; |
e9f8ea4e |
271 | echo "</FORM></TD>\n"; |
37578167 |
272 | } else { |
e9f8ea4e |
273 | echo _("No folders were found to unsubscribe from!") . "</td>"; |
37578167 |
274 | } |
275 | $boxes_sub = $boxes; |
e9f8ea4e |
276 | |
277 | echo "<td bgcolor=\"$color[9]\" width=2%> </td>"; |
37578167 |
278 | |
279 | /** SUBSCRIBE TO FOLDERS **/ |
e9f8ea4e |
280 | echo "<TD BGCOLOR=\"$color[0]\" widtn=49% ALIGN=CENTER>"; |
281 | $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1); |
282 | $boxes_all = sqimap_mailbox_list_all ($imap_stream); |
283 | |
5bdd7223 |
284 | $box = ""; |
285 | $box2 = ""; |
286 | for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { |
287 | $use_folder = true; |
288 | for ($p = 0; $p < count ($boxes); $p++) { |
289 | if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) { |
290 | $use_folder = false; |
291 | continue; |
292 | } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) { |
293 | $use_folder = false; |
294 | } |
32b3d87e |
295 | } |
5bdd7223 |
296 | if ($use_folder == true) { |
297 | $box[$q] = $boxes_all[$i]["unformatted-dm"]; |
2752bb16 |
298 | $box2[$q] = $boxes_all[$i]["unformatted-disp"]; |
5bdd7223 |
299 | $q++; |
300 | } |
301 | } |
302 | sqimap_logout($imap_stream); |
e9f8ea4e |
303 | |
304 | if ($box && $box2) { |
305 | echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"; |
306 | echo "<tt><select name=mailbox[] multiple size=8>"; |
307 | |
308 | for ($q = 0; $q < count($box); $q++) { |
309 | echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n"; |
310 | } |
311 | echo "</select></tt><br>"; |
312 | echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n"; |
225ce239 |
313 | echo "</FORM></TD></TR></TABLE><BR>\n"; |
314 | } else { |
e9f8ea4e |
315 | echo _("No folders were found to subscribe to!") . "</td></tr></table>"; |
60573cd9 |
316 | } |
60573cd9 |
317 | |
d7d3c4d4 |
318 | do_hook("folders_bottom"); |
1195c340 |
319 | sqimap_logout($imapConnection); |
aa42fbfb |
320 | ?> |
2aa12d5e |
321 | </BODY></HTML> |