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++) { |
e54e0b89 |
168 | if (!in_array('noinferiors', $boxes[$i]['flags'])) { |
1e0628fb |
169 | if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) { |
1f97f59a |
170 | $box = $boxes[$i]["unformatted"]; |
2752bb16 |
171 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
1f97f59a |
172 | echo "<OPTION SELECTED VALUE=\"$box\">$box2\n"; |
173 | } else { |
174 | $box = $boxes[$i]["unformatted"]; |
2752bb16 |
175 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
2c1dc652 |
176 | if (strtolower($imap_server_type) != "courier" || |
177 | strtolower($box) != "inbox.trash") |
178 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
1f97f59a |
179 | } |
180 | } |
60573cd9 |
181 | } |
7ce342dc |
182 | echo "</SELECT></TT><BR>\n"; |
813eba2f |
183 | if ($show_contain_subfolders_option) { |
aae41ae9 |
184 | echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> "; |
036a8a9d |
185 | echo _("Let this folder contain subfolders"); |
aae41ae9 |
186 | echo "<BR>"; |
813eba2f |
187 | } |
88c81396 |
188 | echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n"; |
1195c340 |
189 | echo "</FORM></TD></TR>\n"; |
190 | |
191 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
60573cd9 |
192 | |
193 | /** RENAMING FOLDERS **/ |
32f4685b |
194 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
036a8a9d |
195 | echo _("Rename a Folder"); |
32f4685b |
196 | echo "</B></TD></TR>"; |
1195c340 |
197 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
225ce239 |
198 | if ($count_special_folders < count($boxes)) { |
9f2215a1 |
199 | echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"; |
225ce239 |
200 | echo "<TT><SELECT NAME=old>\n"; |
201 | for ($i = 0; $i < count($boxes); $i++) { |
202 | $use_folder = true; |
1e0628fb |
203 | |
5bdd7223 |
204 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
205 | ($boxes[$i]["unformatted"] != $trash_folder) && |
206 | ($boxes[$i]["unformatted"] != $sent_folder)) |
207 | { |
208 | $box = $boxes[$i]["unformatted-dm"]; |
2752bb16 |
209 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
5bdd7223 |
210 | if (strtolower($imap_server_type) != "courier" || strtolower($box) != "inbox.trash") |
211 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
212 | } |
60573cd9 |
213 | } |
225ce239 |
214 | echo "</SELECT></TT>\n"; |
215 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
216 | echo _("Rename"); |
217 | echo "\">\n"; |
37578167 |
218 | echo "</FORM></TD></TR>\n"; |
219 | } else { |
0e743004 |
220 | echo _("No folders found") . "<br><br></td></tr>"; |
37578167 |
221 | } |
222 | $boxes_sub = $boxes; |
1195c340 |
223 | |
e9f8ea4e |
224 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n"; |
37578167 |
225 | |
226 | /** UNSUBSCRIBE FOLDERS **/ |
e9f8ea4e |
227 | echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n"; |
32f4685b |
228 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=3><B>"; |
88c81396 |
229 | echo _("Unsubscribe") . "/" . _("Subscribe"); |
32f4685b |
230 | echo "</B></TD></TR>"; |
e9f8ea4e |
231 | echo "<TR><TD BGCOLOR=\"$color[0]\" width=49% ALIGN=CENTER>"; |
37578167 |
232 | if ($count_special_folders < count($boxes)) { |
9f2215a1 |
233 | echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"; |
e9f8ea4e |
234 | echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n"; |
37578167 |
235 | for ($i = 0; $i < count($boxes); $i++) { |
236 | $use_folder = true; |
5bdd7223 |
237 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
238 | ($boxes[$i]["unformatted"] != $trash_folder) && |
239 | ($boxes[$i]["unformatted"] != $sent_folder)) |
240 | { |
241 | $box = $boxes[$i]["unformatted-dm"]; |
2752bb16 |
242 | $box2 = replace_spaces($boxes[$i]["unformatted-disp"]); |
5bdd7223 |
243 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
244 | } |
37578167 |
245 | } |
e9f8ea4e |
246 | echo "</SELECT></TT><br>\n"; |
37578167 |
247 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
248 | echo _("Unsubscribe"); |
249 | echo "\">\n"; |
e9f8ea4e |
250 | echo "</FORM></TD>\n"; |
37578167 |
251 | } else { |
e9f8ea4e |
252 | echo _("No folders were found to unsubscribe from!") . "</td>"; |
37578167 |
253 | } |
254 | $boxes_sub = $boxes; |
e9f8ea4e |
255 | |
256 | echo "<td bgcolor=\"$color[9]\" width=2%> </td>"; |
37578167 |
257 | |
258 | /** SUBSCRIBE TO FOLDERS **/ |
e9f8ea4e |
259 | echo "<TD BGCOLOR=\"$color[0]\" widtn=49% ALIGN=CENTER>"; |
260 | $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1); |
261 | $boxes_all = sqimap_mailbox_list_all ($imap_stream); |
262 | |
5bdd7223 |
263 | $box = ""; |
264 | $box2 = ""; |
265 | for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { |
266 | $use_folder = true; |
267 | for ($p = 0; $p < count ($boxes); $p++) { |
268 | if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) { |
269 | $use_folder = false; |
270 | continue; |
271 | } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) { |
272 | $use_folder = false; |
273 | } |
32b3d87e |
274 | } |
5bdd7223 |
275 | if ($use_folder == true) { |
276 | $box[$q] = $boxes_all[$i]["unformatted-dm"]; |
2752bb16 |
277 | $box2[$q] = $boxes_all[$i]["unformatted-disp"]; |
5bdd7223 |
278 | $q++; |
279 | } |
280 | } |
281 | sqimap_logout($imap_stream); |
e9f8ea4e |
282 | |
283 | if ($box && $box2) { |
284 | echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"; |
285 | echo "<tt><select name=mailbox[] multiple size=8>"; |
286 | |
287 | for ($q = 0; $q < count($box); $q++) { |
288 | echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n"; |
289 | } |
290 | echo "</select></tt><br>"; |
291 | echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n"; |
225ce239 |
292 | echo "</FORM></TD></TR></TABLE><BR>\n"; |
293 | } else { |
e9f8ea4e |
294 | echo _("No folders were found to subscribe to!") . "</td></tr></table>"; |
60573cd9 |
295 | } |
60573cd9 |
296 | |
d7d3c4d4 |
297 | do_hook("folders_bottom"); |
1195c340 |
298 | sqimap_logout($imapConnection); |
aa42fbfb |
299 | ?> |
2aa12d5e |
300 | </BODY></HTML> |