Remove &amp usage from Location headers
[squirrelmail.git] / src / folders.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * folders.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Handles all interaction between the user and the other folder
10 * scripts which do most of the work. Also handles the Special
11 * Folders.
12 *
13 * $Id$
14 */
15
35586184 16require_once('../src/validate.php');
17require_once('../functions/imap.php');
18require_once('../functions/array.php');
19require_once('../functions/plugin.php');
d3cdb279 20
e634431a 21displayPageHeader($color, 'None');
aa42fbfb 22
e7db48af 23?>
24
e7db48af 25<br>
26<table bgcolor="<?php echo $color[0] ?>" width="95%" align="center" cellpadding="2" cellspacing="0" border="0">
27<tr><td align="center">
28
c8cc8352 29 <b><?php echo _("Folders"); ?></b>
e7db48af 30
31 <table width="100%" border="0" cellpadding="5" cellspacing="0">
32 <tr><td bgcolor="<?php echo $color[4] ?>" align="center">
33
34<?php
aa42fbfb 35
1c52ba77 36if ((isset($success) && $success) ||
37 (isset($sent_create) && $sent_create == 'true') ||
38 (isset($trash_create) && $trash_create == 'true')) {
39 echo "<table width=\"100%\" align=center cellpadding=4 cellspacing=0 border=0>\n" .
40 " <tr><td align=center>\n";
e634431a 41 if ($success == "subscribe") {
42 echo "<b>" . _("Subscribed successfully!") . "</b><br>";
43 } else if ($success == "unsubscribe") {
44 echo "<b>" . _("Unsubscribed successfully!") . "</b><br>";
45 } else if ($success == "delete") {
46 echo "<b>" . _("Deleted folder successfully!") . "</b><br>";
47 } else if ($success == "create") {
48 echo "<b>" . _("Created folder successfully!") . "</b><br>";
49 } else if ($success == "rename") {
50 echo "<b>" . _("Renamed successfully!") . "</b><br>";
51 }
52
1c52ba77 53 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>".
54 " </td></tr>\n";
55 "</table><br>\n";
e634431a 56} else {
57 echo "<br>";
58}
59$imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
60$boxes = sqimap_mailbox_list($imapConnection);
61
62/** CREATING FOLDERS **/
1c52ba77 63echo "<TABLE WIDTH=\"70%\" COLS=1 ALIGN=CENTER cellpadding=4 cellspacing=0 border=0>\n".
64 "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>".
65 _("Create Folder").
66 "</B></TD></TR>".
67 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>".
68 "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n".
69 "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n".
70 _("as a subfolder of").
71 "<BR>".
72 "<TT><SELECT NAME=subfolder>\n";
e634431a 73if ($default_sub_of_inbox == false) {
74 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
75} else {
76 echo '<OPTION VALUE="">[ '._("None")." ]\n";
77}
78
79for ($i = 0; $i < count($boxes); $i++) {
80 if (!in_array('noinferiors', $boxes[$i]['flags'])) {
1c52ba77 81 if ((strtolower($boxes[$i]['unformatted']) == 'inbox') &&
82 $default_sub_of_inbox) {
83 $box = $boxes[$i]['unformatted'];
84 $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
85 echo "<OPTION SELECTED VALUE=\"$box\">$box2</option>\n";
e634431a 86 } else {
1c52ba77 87 $box = $boxes[$i]['unformatted'];
88 $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
89 if (strtolower($imap_server_type) != 'courier' ||
e634431a 90 strtolower($box) != "inbox.trash")
1c52ba77 91 echo "<OPTION VALUE=\"$box\">$box2</option>\n";
e634431a 92 }
93 }
94}
95echo "</SELECT></TT>\n";
96if ($show_contain_subfolders_option) {
97 echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> &nbsp;";
98 echo _("Let this folder contain subfolders");
99 echo "<BR>";
1c52ba77 100}
e634431a 101echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
102echo "</FORM></TD></TR>\n";
103
104echo "<tr><td bgcolor=\"$color[4]\">&nbsp;</td></tr>\n";
105
106/** RENAMING FOLDERS **/
1c52ba77 107echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>".
108 _("Rename a Folder").
109 "</B></TD></TR>".
110 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
c94361f7 111if (count($boxes)) {
1c52ba77 112 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n".
113 "<TT><SELECT NAME=old>\n";
e634431a 114 for ($i = 0; $i < count($boxes); $i++) {
115 $use_folder = true;
116
1c52ba77 117 if ((strtolower($boxes[$i]['unformatted']) != 'inbox') &&
118 ($boxes[$i]['unformatted'] != $trash_folder) &&
119 ($boxes[$i]['unformatted'] != $sent_folder) &&
120 ($boxes[$i]['unformatted'] != $draft_folder)) {
121 $box = $boxes[$i]['unformatted-dm'];
122
123 $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
124 if (strtolower($imap_server_type) != 'courier' || strtolower($box) != 'inbox.trash') {
125 echo "<OPTION VALUE=\"$box\">$box2</option>\n";
126 }
e634431a 127 }
128 }
1c52ba77 129 echo "</SELECT></TT>\n".
130 "<INPUT TYPE=SUBMIT VALUE=\"".
131 _("Rename").
132 "\">\n".
133 "</FORM></TD></TR>\n";
e634431a 134} else {
135 echo _("No folders found") . "<br><br></td></tr>";
136}
137$boxes_sub = $boxes;
138
139echo "<tr><td bgcolor=\"$color[4]\">&nbsp;</td></tr>\n";
140
141/** DELETING FOLDERS **/
142echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
143echo _("Delete Folder");
144echo "</B></TD></TR>";
145echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
146
147$count_special_folders = 0;
1c52ba77 148$num_max = 1;
149if (strtolower($imap_server_type) == "courier" || $move_to_trash) {
150 $num_max++;
151}
152if ($move_to_sent) {
153 $num_max++;
154}
155if ($save_as_draft) {
156 $num_max++;
157}
e634431a 158for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++) {
1c52ba77 159 if (strtolower($boxes[$p]['unformatted']) == 'inbox')
e634431a 160 $count_special_folders++;
1c52ba77 161 else if (strtolower($imap_server_type) == 'courier' &&
162 strtolower($boxes[$p]['unformatted']) == 'inbox.trash')
e634431a 163 $count_special_folders++;
1c52ba77 164 else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
e634431a 165 $count_special_folders++;
1c52ba77 166 else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
e634431a 167 $count_special_folders++;
1c52ba77 168 else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
e634431a 169 $count_special_folders++;
170}
171
172if ($count_special_folders < count($boxes)) {
173 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
174 echo "<TT><SELECT NAME=mailbox>\n";
175 for ($i = 0; $i < count($boxes); $i++) {
176 $use_folder = true;
1c52ba77 177 if ((strtolower($boxes[$i]['unformatted']) != 'inbox') &&
178 ($boxes[$i]['unformatted'] != $trash_folder) &&
179 ($boxes[$i]['unformatted'] != $sent_folder) &&
180 ($boxes[$i]['unformatted'] != $draft_folder) &&
181 ((strtolower($imap_server_type) != 'courier') ||
182 (strtolower($boxes[$i]['unformatted']) != 'inbox.trash'))) {
183 $box = $boxes[$i]['unformatted-dm'];
184 $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
185 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
e634431a 186 }
187 }
188 echo "</SELECT></TT>\n";
189 echo "<INPUT TYPE=SUBMIT VALUE=\"";
190 echo _("Delete");
191 echo "\">\n";
192 echo "</FORM></TD></TR>\n";
193} else {
194 echo _("No folders found") . "<br><br></td><tr>";
195}
196echo "<tr><td bgcolor=\"$color[4]\">&nbsp;</td></tr></table>\n";
197
198/** UNSUBSCRIBE FOLDERS **/
199echo "<TABLE WIDTH=\"70%\" COLS=2 ALIGN=CENTER cellpadding=4 cellspacing=0 border=0>\n";
200echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=2><B>";
201echo _("Unsubscribe") . "/" . _("Subscribe");
202echo "</B></TD></TR>\n";
203echo "<TR><TD BGCOLOR=\"$color[0]\" width=\"50%\" ALIGN=CENTER>\n";
204if ($count_special_folders < count($boxes)) {
205 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
206 echo "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
207 for ($i = 0; $i < count($boxes); $i++) {
208 $use_folder = true;
209 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
210 ($boxes[$i]["unformatted"] != $trash_folder) &&
211 ($boxes[$i]["unformatted"] != $sent_folder) &&
212 ($boxes[$i]["unformatted"] != $draft_folder)) {
213 $box = $boxes[$i]["unformatted-dm"];
214 $box2 = str_replace(' ', '&nbsp;', $boxes[$i]["unformatted-disp"]);
215 echo " <OPTION VALUE=\"$box\">$box2\n";
216 }
217 }
218 echo "</SELECT></TT><br><br>\n";
219 echo "<INPUT TYPE=SUBMIT VALUE=\"";
220 echo _("Unsubscribe");
221 echo "\">\n";
222 echo "</FORM></TD>\n";
223} else {
224 echo _("No folders were found to unsubscribe from!") . "</td>";
225}
226$boxes_sub = $boxes;
227
228/** SUBSCRIBE TO FOLDERS **/
229echo "<TD BGCOLOR=\"$color[0]\" width=\"50%\" ALIGN=CENTER>";
230$imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
231$boxes_all = sqimap_mailbox_list_all ($imap_stream);
232
233$box = "";
234$box2 = "";
235for ($i = 0, $q = 0; $i < count($boxes_all); $i++) {
236 $use_folder = true;
237 for ($p = 0; $p < count ($boxes); $p++) {
238 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
239 $use_folder = false;
240 continue;
241 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
242 $use_folder = false;
243 }
244 }
245 if ($use_folder == true) {
246 $box[$q] = $boxes_all[$i]["unformatted-dm"];
247 $box2[$q] = $boxes_all[$i]["unformatted-disp"];
248 $q++;
249 }
250}
251sqimap_logout($imap_stream);
252
253if ($box && $box2) {
254 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
255 echo "<tt><select name=\"mailbox[]\" multiple size=8>";
256
257 for ($q = 0; $q < count($box); $q++) {
258 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
259 }
260 echo "</select></tt><br><br>";
261 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
262 echo "</FORM></TD></TR></TABLE><BR>\n";
263} else {
264 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
265}
e7db48af 266
bd9bbfef 267do_hook("folders_bottom");
268?>
e7db48af 269
60573cd9 270
e7db48af 271 </td></tr>
272 </table>
273
274</td></tr>
275</table>
276
277<?php
1195c340 278 sqimap_logout($imapConnection);
aa42fbfb 279?>
e7db48af 280
1c52ba77 281</body></html>