changed Hernan Collazo <hernan_collazo@salutia.com> as spanish translator
[squirrelmail.git] / src / folders.php
CommitLineData
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");
d7d3c4d4 25 if (!isset($plugin_php))
26 include("../functions/plugin.php");
aa42fbfb 27
d3cdb279 28 include("../src/load_prefs.php");
29
f8f9bed9 30 displayPageHeader($color, "None");
aa42fbfb 31
1195c340 32 echo "<br>";
33 echo "<TABLE WIDTH=95% COLS=1 ALIGN=CENTER>\n";
e9f8ea4e 34 echo " <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><b>\n";
036a8a9d 35 echo _("Folders");
e9f8ea4e 36 echo " </b></TD></TR>\n";
aa42fbfb 37 echo "</TABLE>\n";
38
1195c340 39 if ($success) {
40 echo "<table width=100% align=center cellpadding=3 cellspacing=0 border=0>\n";
e9f8ea4e 41 echo " <tr><td><center>\n";
1195c340 42 if ($success == "subscribe") {
43 echo "<b>" . _("Subscribed successfully!") . "</b><br>";
44 } else if ($success == "unsubscribe") {
45 echo "<b>" . _("Unsubscribed successfully!") . "</b><br>";
46 } else if ($success == "delete") {
47 echo "<b>" . _("Deleted folder successfully!") . "</b><br>";
48 } else if ($success == "create") {
49 echo "<b>" . _("Created folder successfully!") . "</b><br>";
50 } else if ($success == "rename") {
51 echo "<b>" . _("Renamed successfully!") . "</b><br>";
0e743004 52 } else if (($sent_create == "true") || ($trash_create == "true")) {
53 if ($sent_create == "true") {
54 sqimap_mailbox_create ($imapConnection, $sent_folder, "");
55 }
56 if ($trash_create == "true") {
57 sqimap_mailbox_create ($imapConnection, $trash_folder, "");
58 }
59 echo _("Folders created successfully!");
1195c340 60 }
0e743004 61
e9f8ea4e 62 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>";
1195c340 63 echo " </center></td></tr>\n";
64 echo "</table><br>\n";
65 }
e1469126 66 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
813eba2f 67 $boxes = sqimap_mailbox_list($imapConnection);
60573cd9 68
0e743004 69 //display form option for creating Sent and Trash folder
70 if ($imap_server_type == "cyrus" && ($sent_folder != "none" || $trash_folder != "none")) {
71 if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) || (!sqimap_mailbox_exists ($imapConnection, $trash_folder))) {
72 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
73 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
74 echo _("Special Folder Options");
75 echo "</B></TD></TR>";
76 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
77 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.");
78 echo "<FORM ACTION=\"folders.php\" METHOD=\"POST\">\n";
79 if (!sqimap_mailbox_exists ($imapConnection, $sent_folder) && $sent_folder != "none") {
80 echo _("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create value=true><br>\n";
81 }
82 if (!sqimap_mailbox_exists ($imapConnection, $trash_folder) && $trash_folder != "none"){
83 echo _("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create value=true><br>\n";
84 }
85 echo "<INPUT TYPE=submit VALUE=Create>";
86 echo "</FORM></TD></TR></TABLE><br>";
90790bd4 87 }
90790bd4 88 }
89
60573cd9 90 /** DELETING FOLDERS **/
1195c340 91 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
e9f8ea4e 92 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER>";
036a8a9d 93 echo _("Delete Folder");
e9f8ea4e 94 echo "</TD></TR>";
1195c340 95 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
1e0628fb 96
225ce239 97 $count_special_folders = 0;
2c1dc652 98 $num_max = 1;
99 if (strtolower($imap_server_type) == "courier" || $move_to_trash)
100 $num_max++;
101 if ($move_to_sent)
102 $num_max++;
4bbba0d8 103
2c1dc652 104 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++) {
c36ed9cf 105 if (strtolower($boxes[$p]["unformatted"]) == "inbox")
1e0628fb 106 $count_special_folders++;
2c1dc652 107 else if (strtolower($imap_server_type) == "courier" &&
108 strtolower($boxes[$p]["unformatted"]) == "inbox.trash")
1e0628fb 109 $count_special_folders++;
2c1dc652 110 else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
1e0628fb 111 $count_special_folders++;
b93e186d 112 else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
113 $count_special_folders++;
1e0628fb 114 }
225ce239 115
116 if ($count_special_folders < count($boxes)) {
9f2215a1 117 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
225ce239 118 echo "<TT><SELECT NAME=mailbox>\n";
119 for ($i = 0; $i < count($boxes); $i++) {
120 $use_folder = true;
2c1dc652 121 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
122 ($boxes[$i]["unformatted"] != $trash_folder) &&
123 ($boxes[$i]["unformatted"] != $sent_folder) &&
124 (strtolower($imap_server_type) != "courier" ||
125 strtolower($boxes[$i]["unformatted"]) != "inbox.trash"))
126 {
225ce239 127 $box = $boxes[$i]["unformatted-dm"];
128 $box2 = replace_spaces($boxes[$i]["formatted"]);
129 echo " <OPTION VALUE=\"$box\">$box2\n";
e457e585 130 }
60573cd9 131 }
225ce239 132 echo "</SELECT></TT>\n";
133 echo "<INPUT TYPE=SUBMIT VALUE=\"";
134 echo _("Delete");
135 echo "\">\n";
1195c340 136 echo "</FORM></TD></TR>\n";
225ce239 137 } else {
0e743004 138 echo _("No folders found") . "<br><br></td><tr>";
60573cd9 139 }
7ce342dc 140
1195c340 141 echo "<tr><td bgcolor=\"$color[4]\">&nbsp;</td></tr>\n";
60573cd9 142
143 /** CREATING FOLDERS **/
e9f8ea4e 144 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER>";
036a8a9d 145 echo _("Create Folder");
e9f8ea4e 146 echo "</TD></TR>";
1195c340 147 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
d7d3c4d4 148 echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
907165ca 149 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
036a8a9d 150 echo _("as a subfolder of");
aae41ae9 151 echo "<BR>";
152 echo "<TT><SELECT NAME=subfolder>\n";
2c1dc652 153 if (strtolower($imap_server_type) != "courier"){
154 if ($default_sub_of_inbox == false)
155 echo "<OPTION SELECTED>[ None ]\n";
156 else
157 echo "<OPTION>[ None ]\n";
158 }
d92b6f31 159
7ce342dc 160 for ($i = 0; $i < count($boxes); $i++) {
1f97f59a 161 if (count($boxes[$i]["flags"]) > 0) {
390372b4 162 $noinf = false;
1f97f59a 163 for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
390372b4 164 if ($boxes[$i]["flags"][$j] == "noinferiors") {
165 $noinf = true;
166 continue;
167 }
1f97f59a 168 }
390372b4 169 if ($noinf == false) {
170 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
171 $box = $boxes[$i]["unformatted"];
172 $box2 = replace_spaces($boxes[$i]["formatted"]);
173 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
174 } else {
175 $box = $boxes[$i]["unformatted"];
176 $box2 = replace_spaces($boxes[$i]["formatted"]);
2c1dc652 177 if (strtolower($imap_server_type) != "courier" ||
178 strtolower($box) != "inbox.trash")
179 echo "<OPTION VALUE=\"$box\">$box2\n";
390372b4 180 }
181 }
1f97f59a 182 } else {
1e0628fb 183 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
1f97f59a 184 $box = $boxes[$i]["unformatted"];
185 $box2 = replace_spaces($boxes[$i]["formatted"]);
186 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
187 } else {
188 $box = $boxes[$i]["unformatted"];
189 $box2 = replace_spaces($boxes[$i]["formatted"]);
2c1dc652 190 if (strtolower($imap_server_type) != "courier" ||
191 strtolower($box) != "inbox.trash")
192 echo "<OPTION VALUE=\"$box\">$box2\n";
1f97f59a 193 }
194 }
60573cd9 195 }
7ce342dc 196 echo "</SELECT></TT><BR>\n";
813eba2f 197 if ($show_contain_subfolders_option) {
aae41ae9 198 echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> &nbsp;";
036a8a9d 199 echo _("Let this folder contain subfolders");
aae41ae9 200 echo "<BR>";
813eba2f 201 }
88c81396 202 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
1195c340 203 echo "</FORM></TD></TR>\n";
204
205 echo "<tr><td bgcolor=\"$color[4]\">&nbsp;</td></tr>\n";
60573cd9 206
207 /** RENAMING FOLDERS **/
e9f8ea4e 208 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER>";
036a8a9d 209 echo _("Rename a Folder");
e9f8ea4e 210 echo "</TD></TR>";
1195c340 211 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
225ce239 212 if ($count_special_folders < count($boxes)) {
9f2215a1 213 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
225ce239 214 echo "<TT><SELECT NAME=old>\n";
215 for ($i = 0; $i < count($boxes); $i++) {
216 $use_folder = true;
1e0628fb 217
218 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
219 ($boxes[$i]["unformatted"] != $trash_folder) &&
220 ($boxes[$i]["unformatted"] != $sent_folder))
221 {
693ccbc9 222 $box = $boxes[$i]["unformatted-dm"];
225ce239 223 $box2 = replace_spaces($boxes[$i]["formatted"]);
b93e186d 224 if (strtolower($imap_server_type) != "courier" || strtolower($box) != "inbox.trash")
225 echo "<OPTION VALUE=\"$box\">$box2\n";
907165ca 226 }
60573cd9 227 }
225ce239 228 echo "</SELECT></TT>\n";
229 echo "<INPUT TYPE=SUBMIT VALUE=\"";
230 echo _("Rename");
231 echo "\">\n";
37578167 232 echo "</FORM></TD></TR>\n";
233 } else {
0e743004 234 echo _("No folders found") . "<br><br></td></tr>";
37578167 235 }
236 $boxes_sub = $boxes;
1195c340 237
e9f8ea4e 238 echo "<tr><td bgcolor=\"$color[4]\">&nbsp;</td></tr></table>\n";
37578167 239
240 /** UNSUBSCRIBE FOLDERS **/
e9f8ea4e 241 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
242 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=3>";
88c81396 243 echo _("Unsubscribe") . "/" . _("Subscribe");
e9f8ea4e 244 echo "</TD></TR>";
245 echo "<TR><TD BGCOLOR=\"$color[0]\" width=49% ALIGN=CENTER>";
37578167 246 if ($count_special_folders < count($boxes)) {
9f2215a1 247 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
e9f8ea4e 248 echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n";
37578167 249 for ($i = 0; $i < count($boxes); $i++) {
250 $use_folder = true;
1e0628fb 251 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
252 ($boxes[$i]["unformatted"] != $trash_folder) &&
253 ($boxes[$i]["unformatted"] != $sent_folder))
254 {
37578167 255 $box = $boxes[$i]["unformatted-dm"];
256 $box2 = replace_spaces($boxes[$i]["formatted"]);
257 echo " <OPTION VALUE=\"$box\">$box2\n";
258 }
259 }
e9f8ea4e 260 echo "</SELECT></TT><br>\n";
37578167 261 echo "<INPUT TYPE=SUBMIT VALUE=\"";
262 echo _("Unsubscribe");
263 echo "\">\n";
e9f8ea4e 264 echo "</FORM></TD>\n";
37578167 265 } else {
e9f8ea4e 266 echo _("No folders were found to unsubscribe from!") . "</td>";
37578167 267 }
268 $boxes_sub = $boxes;
e9f8ea4e 269
270 echo "<td bgcolor=\"$color[9]\" width=2%>&nbsp;</td>";
37578167 271
272 /** SUBSCRIBE TO FOLDERS **/
e9f8ea4e 273 echo "<TD BGCOLOR=\"$color[0]\" widtn=49% ALIGN=CENTER>";
274 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
275 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
276
277 $box = "";
278 $box2 = "";
279 for ($i = 0, $q = 0; $i < count($boxes_all); $i++) {
32b3d87e 280 $use_folder = true;
1e0628fb 281 for ($p = 0; $p < count ($boxes); $p++) {
282 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
283 $use_folder = false;
284 continue;
285 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
286 $use_folder = false;
287 }
288 }
289 if ($use_folder == true) {
e9f8ea4e 290 $box[$q] = $boxes_all[$i]["unformatted-dm"];
291 $box2[$q] = $boxes_all[$i]["formatted"];
292 $q++;
32b3d87e 293 }
294 }
1195c340 295 sqimap_logout($imap_stream);
e9f8ea4e 296
297 if ($box && $box2) {
298 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
299 echo "<tt><select name=mailbox[] multiple size=8>";
300
301 for ($q = 0; $q < count($box); $q++) {
302 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
303 }
304 echo "</select></tt><br>";
305 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
225ce239 306 echo "</FORM></TD></TR></TABLE><BR>\n";
307 } else {
e9f8ea4e 308 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
60573cd9 309 }
60573cd9 310
d7d3c4d4 311 do_hook("folders_bottom");
1195c340 312 sqimap_logout($imapConnection);
aa42fbfb 313?>
2aa12d5e 314</BODY></HTML>