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