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