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