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