5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
8 ** Handles all interaction between the user and the other folder
9 ** scripts which do most of the work. Also handles the Special
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");
25 if (!isset($plugin_php))
26 include("../functions/plugin.php");
28 include("../src/load_prefs.php");
30 displayPageHeader($color, "None");
33 echo "<TABLE WIDTH=95% COLS=1 ALIGN=CENTER>\n";
34 echo " <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><b>\n";
36 echo " </b></TD></TR>\n";
40 echo "<table width=100% align=center cellpadding=3 cellspacing=0 border=0>\n";
41 echo " <tr><td><center>\n";
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>";
52 } else if (($sent_create == "true") ||
($trash_create == "true")) {
53 if ($sent_create == "true") {
54 sqimap_mailbox_create ($imapConnection, $sent_folder, "");
56 if ($trash_create == "true") {
57 sqimap_mailbox_create ($imapConnection, $trash_folder, "");
59 echo _("Folders created successfully!");
62 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>";
63 echo " </center></td></tr>\n";
64 echo "</table><br>\n";
66 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
67 $boxes = sqimap_mailbox_list($imapConnection);
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";
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";
85 echo "<INPUT TYPE=submit VALUE="._("Create").">";
86 echo "</FORM></TD></TR></TABLE><br>";
90 /** DELETING FOLDERS **/
91 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
92 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
93 echo _("Delete Folder");
94 echo "</B></TD></TR>";
95 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
97 $count_special_folders = 0;
99 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash)
104 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
105 if (strtolower($boxes[$p]["unformatted"]) == "inbox")
106 $count_special_folders++
;
107 else if (strtolower($imap_server_type) == "courier" &&
108 strtolower($boxes[$p]["unformatted"]) == "inbox.trash")
109 $count_special_folders++
;
110 else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
111 $count_special_folders++
;
112 else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
113 $count_special_folders++
;
116 if ($count_special_folders < count($boxes)) {
117 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
118 echo "<TT><SELECT NAME=mailbox>\n";
119 for ($i = 0; $i < count($boxes); $i++
) {
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"))
127 $box = $boxes[$i]["unformatted-dm"];
128 $box2 = replace_spaces($boxes[$i]["formatted"]);
129 echo " <OPTION VALUE=\"$box\">$box2\n";
132 echo "</SELECT></TT>\n";
133 echo "<INPUT TYPE=SUBMIT VALUE=\"";
136 echo "</FORM></TD></TR>\n";
138 echo _("No folders found") . "<br><br></td><tr>";
141 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
143 /** CREATING FOLDERS **/
144 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
145 echo _("Create Folder");
146 echo "</B></TD></TR>";
147 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
148 echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
149 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
150 echo _("as a subfolder of");
152 echo "<TT><SELECT NAME=subfolder>\n";
153 if (strtolower($imap_server_type) != "courier"){
154 if ($default_sub_of_inbox == false)
155 echo "<OPTION SELECTED>[ None ]\n";
157 echo "<OPTION>[ None ]\n";
160 for ($i = 0; $i < count($boxes); $i++
) {
161 if (count($boxes[$i]["flags"]) > 0) {
163 for ($j = 0; $j < count($boxes[$i]["flags"]); $j++
) {
164 if ($boxes[$i]["flags"][$j] == "noinferiors") {
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";
175 $box = $boxes[$i]["unformatted"];
176 $box2 = replace_spaces($boxes[$i]["formatted"]);
177 if (strtolower($imap_server_type) != "courier" ||
178 strtolower($box) != "inbox.trash")
179 echo "<OPTION VALUE=\"$box\">$box2\n";
183 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
184 $box = $boxes[$i]["unformatted"];
185 $box2 = replace_spaces($boxes[$i]["formatted"]);
186 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
188 $box = $boxes[$i]["unformatted"];
189 $box2 = replace_spaces($boxes[$i]["formatted"]);
190 if (strtolower($imap_server_type) != "courier" ||
191 strtolower($box) != "inbox.trash")
192 echo "<OPTION VALUE=\"$box\">$box2\n";
196 echo "</SELECT></TT><BR>\n";
197 if ($show_contain_subfolders_option) {
198 echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
199 echo _("Let this folder contain subfolders");
202 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
203 echo "</FORM></TD></TR>\n";
205 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
207 /** RENAMING FOLDERS **/
208 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
209 echo _("Rename a Folder");
210 echo "</B></TD></TR>";
211 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
212 if ($count_special_folders < count($boxes)) {
213 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
214 echo "<TT><SELECT NAME=old>\n";
215 for ($i = 0; $i < count($boxes); $i++
) {
218 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
219 ($boxes[$i]["unformatted"] != $trash_folder) &&
220 ($boxes[$i]["unformatted"] != $sent_folder))
222 $box = $boxes[$i]["unformatted-dm"];
223 $box2 = replace_spaces($boxes[$i]["formatted"]);
224 if (strtolower($imap_server_type) != "courier" ||
strtolower($box) != "inbox.trash")
225 echo "<OPTION VALUE=\"$box\">$box2\n";
228 echo "</SELECT></TT>\n";
229 echo "<INPUT TYPE=SUBMIT VALUE=\"";
232 echo "</FORM></TD></TR>\n";
234 echo _("No folders found") . "<br><br></td></tr>";
238 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n";
240 /** UNSUBSCRIBE FOLDERS **/
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><B>";
243 echo _("Unsubscribe") . "/" . _("Subscribe");
244 echo "</B></TD></TR>";
245 echo "<TR><TD BGCOLOR=\"$color[0]\" width=49% ALIGN=CENTER>";
246 if ($count_special_folders < count($boxes)) {
247 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
248 echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n";
249 for ($i = 0; $i < count($boxes); $i++
) {
251 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
252 ($boxes[$i]["unformatted"] != $trash_folder) &&
253 ($boxes[$i]["unformatted"] != $sent_folder))
255 $box = $boxes[$i]["unformatted-dm"];
256 $box2 = replace_spaces($boxes[$i]["formatted"]);
257 echo " <OPTION VALUE=\"$box\">$box2\n";
260 echo "</SELECT></TT><br>\n";
261 echo "<INPUT TYPE=SUBMIT VALUE=\"";
262 echo _("Unsubscribe");
264 echo "</FORM></TD>\n";
266 echo _("No folders were found to unsubscribe from!") . "</td>";
270 echo "<td bgcolor=\"$color[9]\" width=2%> </td>";
272 /** SUBSCRIBE TO FOLDERS **/
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);
279 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
281 for ($p = 0; $p < count ($boxes); $p++
) {
282 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
285 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
289 if ($use_folder == true) {
290 $box[$q] = $boxes_all[$i]["unformatted-dm"];
291 $box2[$q] = $boxes_all[$i]["formatted"];
295 sqimap_logout($imap_stream);
298 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
299 echo "<tt><select name=mailbox[] multiple size=8>";
301 for ($q = 0; $q < count($box); $q++
) {
302 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
304 echo "</select></tt><br>";
305 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
306 echo "</FORM></TD></TR></TABLE><BR>\n";
308 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
311 do_hook("folders_bottom");
312 sqimap_logout($imapConnection);