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