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