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