59177427 |
1 | <?php |
895905c0 |
2 | |
ef870322 |
3 | /** |
4 | ** folders.php |
5 | ** |
895905c0 |
6 | ** Copyright (c) 1999-2001 The SquirrelMail development team |
ef870322 |
7 | ** Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | ** |
9 | ** Handles all interaction between the user and the other folder |
10 | ** scripts which do most of the work. Also handles the Special |
11 | ** Folders. |
245a6892 |
12 | ** |
13 | ** $Id$ |
ef870322 |
14 | **/ |
15 | |
ff8a98e7 |
16 | require_once('../src/validate.php'); |
17 | require_once('../functions/imap.php'); |
18 | require_once('../functions/array.php'); |
19 | require_once('../functions/plugin.php'); |
d3cdb279 |
20 | |
2d367c68 |
21 | displayPageHeader($color, 'None'); |
aa42fbfb |
22 | |
e7db48af |
23 | ?> |
24 | |
e7db48af |
25 | <br> |
26 | <table bgcolor="<?php echo $color[0] ?>" width="95%" align="center" cellpadding="2" cellspacing="0" border="0"> |
27 | <tr><td align="center"> |
28 | |
29 | <b><?php echo _("Folders"); ?></b> |
30 | |
31 | <table width="100%" border="0" cellpadding="5" cellspacing="0"> |
32 | <tr><td bgcolor="<?php echo $color[4] ?>" align="center"> |
33 | |
34 | <?php |
aa42fbfb |
35 | |
245a6892 |
36 | if ((isset($success) && $success) || |
37 | (isset($sent_create) && $sent_create == "true") || |
38 | (isset($trash_create) && $trash_create == "true")) { |
e7db48af |
39 | echo "<table width=100% align=center cellpadding=2 cellspacing=0 border=0>\n"; |
40 | echo " <tr><td align=center>\n"; |
1195c340 |
41 | if ($success == "subscribe") { |
42 | echo "<b>" . _("Subscribed successfully!") . "</b><br>"; |
43 | } else if ($success == "unsubscribe") { |
44 | echo "<b>" . _("Unsubscribed successfully!") . "</b><br>"; |
45 | } else if ($success == "delete") { |
46 | echo "<b>" . _("Deleted folder successfully!") . "</b><br>"; |
47 | } else if ($success == "create") { |
48 | echo "<b>" . _("Created folder successfully!") . "</b><br>"; |
49 | } else if ($success == "rename") { |
50 | echo "<b>" . _("Renamed successfully!") . "</b><br>"; |
51 | } |
0e743004 |
52 | |
e9f8ea4e |
53 | echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>"; |
e7db48af |
54 | echo " </td></tr>\n"; |
1195c340 |
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 | |
60 | /** DELETING FOLDERS **/ |
1195c340 |
61 | echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n"; |
32f4685b |
62 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
036a8a9d |
63 | echo _("Delete Folder"); |
32f4685b |
64 | echo "</B></TD></TR>"; |
1195c340 |
65 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
1e0628fb |
66 | |
225ce239 |
67 | $count_special_folders = 0; |
2c1dc652 |
68 | $num_max = 1; |
69 | if (strtolower($imap_server_type) == "courier" || $move_to_trash) |
70 | $num_max++; |
71 | if ($move_to_sent) |
72 | $num_max++; |
4bbba0d8 |
73 | |
2c1dc652 |
74 | for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++) { |
c36ed9cf |
75 | if (strtolower($boxes[$p]["unformatted"]) == "inbox") |
1e0628fb |
76 | $count_special_folders++; |
2c1dc652 |
77 | else if (strtolower($imap_server_type) == "courier" && |
5bdd7223 |
78 | strtolower($boxes[$p]["unformatted"]) == "inbox.trash") |
1e0628fb |
79 | $count_special_folders++; |
5bdd7223 |
80 | else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder) |
1e0628fb |
81 | $count_special_folders++; |
b93e186d |
82 | else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder) |
83 | $count_special_folders++; |
1e0628fb |
84 | } |
225ce239 |
85 | |
86 | if ($count_special_folders < count($boxes)) { |
9f2215a1 |
87 | echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"; |
225ce239 |
88 | echo "<TT><SELECT NAME=mailbox>\n"; |
89 | for ($i = 0; $i < count($boxes); $i++) { |
90 | $use_folder = true; |
5bdd7223 |
91 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
92 | ($boxes[$i]["unformatted"] != $trash_folder) && |
93 | ($boxes[$i]["unformatted"] != $sent_folder) && |
94 | (strtolower($imap_server_type) != "courier" || |
95 | strtolower($boxes[$i]["unformatted"]) != "inbox.trash")) |
96 | { |
97 | $box = $boxes[$i]["unformatted-dm"]; |
0cd84d75 |
98 | $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]); |
5bdd7223 |
99 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
100 | } |
60573cd9 |
101 | } |
225ce239 |
102 | echo "</SELECT></TT>\n"; |
103 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
104 | echo _("Delete"); |
105 | echo "\">\n"; |
1195c340 |
106 | echo "</FORM></TD></TR>\n"; |
225ce239 |
107 | } else { |
0e743004 |
108 | echo _("No folders found") . "<br><br></td><tr>"; |
60573cd9 |
109 | } |
7ce342dc |
110 | |
1195c340 |
111 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
60573cd9 |
112 | |
113 | /** CREATING FOLDERS **/ |
32f4685b |
114 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
036a8a9d |
115 | echo _("Create Folder"); |
32f4685b |
116 | echo "</B></TD></TR>"; |
1195c340 |
117 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
d7d3c4d4 |
118 | echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n"; |
907165ca |
119 | echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n"; |
036a8a9d |
120 | echo _("as a subfolder of"); |
aae41ae9 |
121 | echo "<BR>"; |
122 | echo "<TT><SELECT NAME=subfolder>\n"; |
2c1dc652 |
123 | if (strtolower($imap_server_type) != "courier"){ |
124 | if ($default_sub_of_inbox == false) |
4c75ba81 |
125 | echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n"; |
2c1dc652 |
126 | else |
4c75ba81 |
127 | echo '<OPTION VALUE="">[ '._("None")." ]\n"; |
2c1dc652 |
128 | } |
d92b6f31 |
129 | |
7ce342dc |
130 | for ($i = 0; $i < count($boxes); $i++) { |
e54e0b89 |
131 | if (!in_array('noinferiors', $boxes[$i]['flags'])) { |
1e0628fb |
132 | if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) { |
1f97f59a |
133 | $box = $boxes[$i]["unformatted"]; |
0cd84d75 |
134 | $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]); |
1f97f59a |
135 | echo "<OPTION SELECTED VALUE=\"$box\">$box2\n"; |
136 | } else { |
137 | $box = $boxes[$i]["unformatted"]; |
0cd84d75 |
138 | $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]); |
2c1dc652 |
139 | if (strtolower($imap_server_type) != "courier" || |
140 | strtolower($box) != "inbox.trash") |
141 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
1f97f59a |
142 | } |
143 | } |
60573cd9 |
144 | } |
e7db48af |
145 | echo "</SELECT></TT>\n"; |
813eba2f |
146 | if ($show_contain_subfolders_option) { |
e7db48af |
147 | echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> "; |
036a8a9d |
148 | echo _("Let this folder contain subfolders"); |
aae41ae9 |
149 | echo "<BR>"; |
813eba2f |
150 | } |
88c81396 |
151 | echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n"; |
1195c340 |
152 | echo "</FORM></TD></TR>\n"; |
153 | |
154 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
60573cd9 |
155 | |
156 | /** RENAMING FOLDERS **/ |
32f4685b |
157 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
036a8a9d |
158 | echo _("Rename a Folder"); |
32f4685b |
159 | echo "</B></TD></TR>"; |
1195c340 |
160 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
225ce239 |
161 | if ($count_special_folders < count($boxes)) { |
9f2215a1 |
162 | echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"; |
225ce239 |
163 | echo "<TT><SELECT NAME=old>\n"; |
164 | for ($i = 0; $i < count($boxes); $i++) { |
165 | $use_folder = true; |
1e0628fb |
166 | |
5bdd7223 |
167 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
168 | ($boxes[$i]["unformatted"] != $trash_folder) && |
169 | ($boxes[$i]["unformatted"] != $sent_folder)) |
170 | { |
171 | $box = $boxes[$i]["unformatted-dm"]; |
0cd84d75 |
172 | $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]); |
5bdd7223 |
173 | if (strtolower($imap_server_type) != "courier" || strtolower($box) != "inbox.trash") |
174 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
175 | } |
60573cd9 |
176 | } |
225ce239 |
177 | echo "</SELECT></TT>\n"; |
178 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
179 | echo _("Rename"); |
180 | echo "\">\n"; |
37578167 |
181 | echo "</FORM></TD></TR>\n"; |
182 | } else { |
0e743004 |
183 | echo _("No folders found") . "<br><br></td></tr>"; |
37578167 |
184 | } |
185 | $boxes_sub = $boxes; |
1195c340 |
186 | |
e9f8ea4e |
187 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n"; |
37578167 |
188 | |
189 | /** UNSUBSCRIBE FOLDERS **/ |
e7db48af |
190 | echo "<TABLE WIDTH=70% COLS=2 ALIGN=CENTER cellpadding=2 cellspacing=1 border=0>\n"; |
191 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=2><B>"; |
88c81396 |
192 | echo _("Unsubscribe") . "/" . _("Subscribe"); |
e7db48af |
193 | echo "</B></TD></TR>\n"; |
194 | echo "<TR><TD BGCOLOR=\"$color[0]\" width=50% ALIGN=CENTER>\n"; |
37578167 |
195 | if ($count_special_folders < count($boxes)) { |
9f2215a1 |
196 | echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"; |
e9f8ea4e |
197 | echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n"; |
37578167 |
198 | for ($i = 0; $i < count($boxes); $i++) { |
199 | $use_folder = true; |
5bdd7223 |
200 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
201 | ($boxes[$i]["unformatted"] != $trash_folder) && |
202 | ($boxes[$i]["unformatted"] != $sent_folder)) |
203 | { |
204 | $box = $boxes[$i]["unformatted-dm"]; |
0cd84d75 |
205 | $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]); |
5bdd7223 |
206 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
207 | } |
37578167 |
208 | } |
e9f8ea4e |
209 | echo "</SELECT></TT><br>\n"; |
37578167 |
210 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
211 | echo _("Unsubscribe"); |
212 | echo "\">\n"; |
e9f8ea4e |
213 | echo "</FORM></TD>\n"; |
37578167 |
214 | } else { |
e9f8ea4e |
215 | echo _("No folders were found to unsubscribe from!") . "</td>"; |
37578167 |
216 | } |
217 | $boxes_sub = $boxes; |
e9f8ea4e |
218 | |
37578167 |
219 | /** SUBSCRIBE TO FOLDERS **/ |
76f9855e |
220 | echo "<TD BGCOLOR=\"$color[0]\" width=50% ALIGN=CENTER>"; |
e9f8ea4e |
221 | $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1); |
222 | $boxes_all = sqimap_mailbox_list_all ($imap_stream); |
223 | |
5bdd7223 |
224 | $box = ""; |
225 | $box2 = ""; |
226 | for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { |
227 | $use_folder = true; |
228 | for ($p = 0; $p < count ($boxes); $p++) { |
229 | if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) { |
230 | $use_folder = false; |
231 | continue; |
232 | } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) { |
233 | $use_folder = false; |
234 | } |
32b3d87e |
235 | } |
5bdd7223 |
236 | if ($use_folder == true) { |
237 | $box[$q] = $boxes_all[$i]["unformatted-dm"]; |
2752bb16 |
238 | $box2[$q] = $boxes_all[$i]["unformatted-disp"]; |
5bdd7223 |
239 | $q++; |
240 | } |
241 | } |
242 | sqimap_logout($imap_stream); |
e9f8ea4e |
243 | |
244 | if ($box && $box2) { |
245 | echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"; |
246 | echo "<tt><select name=mailbox[] multiple size=8>"; |
247 | |
248 | for ($q = 0; $q < count($box); $q++) { |
249 | echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n"; |
250 | } |
251 | echo "</select></tt><br>"; |
252 | echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n"; |
225ce239 |
253 | echo "</FORM></TD></TR></TABLE><BR>\n"; |
254 | } else { |
e9f8ea4e |
255 | echo _("No folders were found to subscribe to!") . "</td></tr></table>"; |
60573cd9 |
256 | } |
e7db48af |
257 | ?> |
258 | |
259 | |
260 | <?php do_hook("folders_bottom"); ?> |
261 | |
60573cd9 |
262 | |
e7db48af |
263 | </td></tr> |
264 | </table> |
265 | |
266 | </td></tr> |
267 | </table> |
268 | |
269 | <?php |
1195c340 |
270 | sqimap_logout($imapConnection); |
aa42fbfb |
271 | ?> |
e7db48af |
272 | |
ff8a98e7 |
273 | </body></html> |