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