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"; |
32 | echo " <TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER>\n"; |
036a8a9d |
33 | echo _("Folders"); |
aa42fbfb |
34 | echo " </TD></TR>\n"; |
35 | echo "</TABLE>\n"; |
36 | |
1195c340 |
37 | if ($success) { |
38 | echo "<table width=100% align=center cellpadding=3 cellspacing=0 border=0>\n"; |
39 | echo " <tr><td><center><font color=\"$color[1]\">\n"; |
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 | } |
51 | echo "</font><a href=\"../src/left_main.php\" target=left><font color=\"$color[1]\">" . _("refresh folder list") . "</font></a>"; |
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 | |
76 | exit; |
77 | } |
78 | |
d7e3602c |
79 | //display form option for creating Sent and Trash folder |
80 | if ($imap_server_type == "cyrus") { |
90790bd4 |
81 | if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) || (!sqimap_mailbox_exists ($imapConnection, $trash_folder))) { |
82 | echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n"; |
1195c340 |
83 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
90790bd4 |
84 | echo _("Special Folder Options"); |
85 | echo "</B></TD></TR>"; |
1195c340 |
86 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
90790bd4 |
87 | 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 |
88 | echo "<FORM ACTION=\"folders.php\" METHOD=\"POST\">\n"; |
90790bd4 |
89 | if (!sqimap_mailbox_exists ($imapConnection, $sent_folder)) { |
90 | echo _("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create value=true><br>\n"; |
91 | } |
92 | if (!sqimap_mailbox_exists ($imapConnection, $trash_folder)){ |
93 | echo _("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create value=true><br>\n"; |
94 | echo "<INPUT TYPE=submit VALUE=Create>"; |
95 | echo "</FORM></TD></TR>\n"; |
96 | } |
97 | } |
98 | } |
99 | |
60573cd9 |
100 | /** DELETING FOLDERS **/ |
1195c340 |
101 | echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n"; |
102 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
036a8a9d |
103 | echo _("Delete Folder"); |
aae41ae9 |
104 | echo "</B></TD></TR>"; |
1195c340 |
105 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
1e0628fb |
106 | |
225ce239 |
107 | $count_special_folders = 0; |
4bbba0d8 |
108 | $num_max = 1; |
109 | if ($move_to_trash) |
110 | $num_max++; |
111 | if ($move_to_sent) |
112 | $num_max++; |
113 | |
114 | for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++) { |
c36ed9cf |
115 | if (strtolower($boxes[$p]["unformatted"]) == "inbox") |
1e0628fb |
116 | $count_special_folders++; |
c36ed9cf |
117 | else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder) |
1e0628fb |
118 | $count_special_folders++; |
c36ed9cf |
119 | else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder) |
1e0628fb |
120 | $count_special_folders++; |
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; |
1e0628fb |
128 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
129 | ($boxes[$i]["unformatted"] != $trash_folder) && |
130 | ($boxes[$i]["unformatted"] != $sent_folder)) |
131 | { |
225ce239 |
132 | $box = $boxes[$i]["unformatted-dm"]; |
133 | $box2 = replace_spaces($boxes[$i]["formatted"]); |
134 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
e457e585 |
135 | } |
60573cd9 |
136 | } |
225ce239 |
137 | echo "</SELECT></TT>\n"; |
138 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
139 | echo _("Delete"); |
140 | echo "\">\n"; |
1195c340 |
141 | echo "</FORM></TD></TR>\n"; |
225ce239 |
142 | } else { |
143 | echo _("No mailboxes found") . "<br><br></td><tr>"; |
60573cd9 |
144 | } |
7ce342dc |
145 | |
1195c340 |
146 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
60573cd9 |
147 | |
148 | /** CREATING FOLDERS **/ |
1195c340 |
149 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
036a8a9d |
150 | echo _("Create Folder"); |
aae41ae9 |
151 | echo "</B></TD></TR>"; |
1195c340 |
152 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
9f2215a1 |
153 | echo "<FORM ACTION=\"folders_create.php\" METHOD=\"POST\">\n"; |
907165ca |
154 | echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n"; |
036a8a9d |
155 | echo _("as a subfolder of"); |
aae41ae9 |
156 | echo "<BR>"; |
157 | echo "<TT><SELECT NAME=subfolder>\n"; |
d92b6f31 |
158 | if ($default_sub_of_inbox == false) |
159 | echo "<OPTION SELECTED>[ None ]\n"; |
160 | else |
161 | echo "<OPTION>[ None ]\n"; |
162 | |
7ce342dc |
163 | for ($i = 0; $i < count($boxes); $i++) { |
1f97f59a |
164 | if (count($boxes[$i]["flags"]) > 0) { |
165 | for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) { |
166 | if ($boxes[$i]["flags"][$j] != "noinferiors") { |
1e0628fb |
167 | if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) { |
1f97f59a |
168 | $box = $boxes[$i]["unformatted"]; |
169 | $box2 = replace_spaces($boxes[$i]["formatted"]); |
170 | echo "<OPTION SELECTED VALUE=\"$box\">$box2\n"; |
171 | } else { |
172 | $box = $boxes[$i]["unformatted"]; |
173 | $box2 = replace_spaces($boxes[$i]["formatted"]); |
174 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
175 | } |
176 | } |
177 | } |
178 | } else { |
1e0628fb |
179 | if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) { |
1f97f59a |
180 | $box = $boxes[$i]["unformatted"]; |
181 | $box2 = replace_spaces($boxes[$i]["formatted"]); |
182 | echo "<OPTION SELECTED VALUE=\"$box\">$box2\n"; |
183 | } else { |
184 | $box = $boxes[$i]["unformatted"]; |
185 | $box2 = replace_spaces($boxes[$i]["formatted"]); |
186 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
187 | } |
188 | } |
60573cd9 |
189 | } |
7ce342dc |
190 | echo "</SELECT></TT><BR>\n"; |
813eba2f |
191 | if ($show_contain_subfolders_option) { |
aae41ae9 |
192 | echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> "; |
036a8a9d |
193 | echo _("Let this folder contain subfolders"); |
aae41ae9 |
194 | echo "<BR>"; |
813eba2f |
195 | } |
aae41ae9 |
196 | echo "<INPUT TYPE=SUBMIT VALUE=Create>\n"; |
1195c340 |
197 | echo "</FORM></TD></TR>\n"; |
198 | |
199 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
60573cd9 |
200 | |
201 | /** RENAMING FOLDERS **/ |
1195c340 |
202 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
036a8a9d |
203 | echo _("Rename a Folder"); |
aae41ae9 |
204 | echo "</B></TD></TR>"; |
1195c340 |
205 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
225ce239 |
206 | if ($count_special_folders < count($boxes)) { |
9f2215a1 |
207 | echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"; |
225ce239 |
208 | echo "<TT><SELECT NAME=old>\n"; |
209 | for ($i = 0; $i < count($boxes); $i++) { |
210 | $use_folder = true; |
1e0628fb |
211 | |
212 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
213 | ($boxes[$i]["unformatted"] != $trash_folder) && |
214 | ($boxes[$i]["unformatted"] != $sent_folder)) |
215 | { |
693ccbc9 |
216 | $box = $boxes[$i]["unformatted-dm"]; |
225ce239 |
217 | $box2 = replace_spaces($boxes[$i]["formatted"]); |
218 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
907165ca |
219 | } |
60573cd9 |
220 | } |
225ce239 |
221 | echo "</SELECT></TT>\n"; |
222 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
223 | echo _("Rename"); |
224 | echo "\">\n"; |
37578167 |
225 | echo "</FORM></TD></TR>\n"; |
226 | } else { |
227 | echo _("No mailboxes found") . "<br><br></td></tr>"; |
228 | } |
229 | $boxes_sub = $boxes; |
1195c340 |
230 | |
231 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
37578167 |
232 | |
233 | /** UNSUBSCRIBE FOLDERS **/ |
1195c340 |
234 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
37578167 |
235 | echo _("Unsubscribe/Subscribe"); |
236 | echo "</B></TD></TR>"; |
1195c340 |
237 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
37578167 |
238 | if ($count_special_folders < count($boxes)) { |
9f2215a1 |
239 | echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"; |
37578167 |
240 | echo "<TT><SELECT NAME=mailbox>\n"; |
241 | for ($i = 0; $i < count($boxes); $i++) { |
242 | $use_folder = true; |
1e0628fb |
243 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
244 | ($boxes[$i]["unformatted"] != $trash_folder) && |
245 | ($boxes[$i]["unformatted"] != $sent_folder)) |
246 | { |
37578167 |
247 | $box = $boxes[$i]["unformatted-dm"]; |
248 | $box2 = replace_spaces($boxes[$i]["formatted"]); |
249 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
250 | } |
251 | } |
252 | echo "</SELECT></TT>\n"; |
253 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
254 | echo _("Unsubscribe"); |
255 | echo "\">\n"; |
256 | echo "</FORM></TD></TR>\n"; |
257 | } else { |
258 | echo _("No mailboxes found") . "<br><br></td></tr>"; |
259 | } |
260 | $boxes_sub = $boxes; |
261 | |
262 | /** SUBSCRIBE TO FOLDERS **/ |
1195c340 |
263 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
24f6a107 |
264 | if ($count_special_folders <= count($boxes)) { |
37578167 |
265 | $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1); |
32b3d87e |
266 | $boxes_all = sqimap_mailbox_list_all ($imap_stream); |
37578167 |
267 | |
9f2215a1 |
268 | echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"; |
32b3d87e |
269 | echo "<tt><select name=mailbox>"; |
270 | for ($i = 0; $i < count($boxes_all); $i++) { |
271 | $use_folder = true; |
1e0628fb |
272 | for ($p = 0; $p < count ($boxes); $p++) { |
273 | if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) { |
274 | $use_folder = false; |
275 | continue; |
276 | } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) { |
277 | $use_folder = false; |
278 | } |
279 | } |
280 | if ($use_folder == true) { |
32b3d87e |
281 | $box = $boxes_all[$i]["unformatted-dm"]; |
282 | $box2 = replace_spaces($boxes_all[$i]["formatted"]); |
283 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
284 | } |
285 | } |
1195c340 |
286 | sqimap_logout($imap_stream); |
32b3d87e |
287 | echo "</select></tt>"; |
37578167 |
288 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
289 | echo _("Subscribe"); |
290 | echo "\">\n"; |
225ce239 |
291 | echo "</FORM></TD></TR></TABLE><BR>\n"; |
292 | } else { |
293 | echo _("No mailboxes found") . "<br><br></td></tr></table>"; |
60573cd9 |
294 | } |
60573cd9 |
295 | |
1195c340 |
296 | sqimap_logout($imapConnection); |
aa42fbfb |
297 | ?> |
2aa12d5e |
298 | </BODY></HTML> |