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