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