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 include('../src/validate.php');
16 include("../functions/strings.php");
17 include("../config/config.php");
18 include("../functions/page_header.php");
19 include("../functions/imap.php");
20 include("../functions/array.php");
21 include("../functions/plugin.php");
22 include("../src/load_prefs.php");
24 displayPageHeader($color, _("None"));
27 echo "<TABLE WIDTH=95% COLS=1 ALIGN=CENTER>\n";
28 echo " <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><b>\n";
30 echo " </b></TD></TR>\n";
33 if ((isset($success) && $success) ||
34 (isset($sent_create) && $sent_create == "true") ||
35 (isset($trash_create) && $trash_create == "true")) {
36 echo "<table width=100% align=center cellpadding=3 cellspacing=0 border=0>\n";
37 echo " <tr><td><center>\n";
38 if ($success == "subscribe") {
39 echo "<b>" . _("Subscribed successfully!") . "</b><br>";
40 } else if ($success == "unsubscribe") {
41 echo "<b>" . _("Unsubscribed successfully!") . "</b><br>";
42 } else if ($success == "delete") {
43 echo "<b>" . _("Deleted folder successfully!") . "</b><br>";
44 } else if ($success == "create") {
45 echo "<b>" . _("Created folder successfully!") . "</b><br>";
46 } else if ($success == "rename") {
47 echo "<b>" . _("Renamed successfully!") . "</b><br>";
48 } else if (($sent_create == "true") ||
($trash_create == "true")) {
49 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
50 if ($sent_create == "true") {
51 sqimap_mailbox_create ($imapConnection, $sent_folder, "");
53 if ($trash_create == "true") {
54 sqimap_mailbox_create ($imapConnection, $trash_folder, "");
56 sqimap_logout($imapConnection);
57 echo _("Folders created successfully!");
60 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>";
61 echo " </center></td></tr>\n";
62 echo "</table><br>\n";
64 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
65 $boxes = sqimap_mailbox_list($imapConnection);
67 //display form option for creating Sent and Trash folder
68 if ($imap_server_type == "cyrus" && ($sent_folder != "none" ||
$trash_folder != "none")) {
69 if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) ||
70 (!sqimap_mailbox_exists ($imapConnection, $trash_folder))) {
71 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
72 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
73 echo _("Special Folder Options");
74 echo "</B></TD></TR>";
75 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
76 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.");
77 echo "<FORM ACTION=\"folders.php\" METHOD=\"POST\">\n";
78 if (!sqimap_mailbox_exists ($imapConnection, $sent_folder) && $sent_folder != "none") {
79 echo _("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create value=true><br>\n";
81 if (!sqimap_mailbox_exists ($imapConnection, $trash_folder) && $trash_folder != "none"){
82 echo _("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create value=true><br>\n";
84 echo "<INPUT TYPE=submit VALUE="._("Create").">";
85 echo "</FORM></TD></TR></TABLE><br>";
89 /** DELETING FOLDERS **/
90 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
91 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
92 echo _("Delete Folder");
93 echo "</B></TD></TR>";
94 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
96 $count_special_folders = 0;
98 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash)
103 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
104 if (strtolower($boxes[$p]["unformatted"]) == "inbox")
105 $count_special_folders++
;
106 else if (strtolower($imap_server_type) == "courier" &&
107 strtolower($boxes[$p]["unformatted"]) == "inbox.trash")
108 $count_special_folders++
;
109 else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
110 $count_special_folders++
;
111 else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
112 $count_special_folders++
;
115 if ($count_special_folders < count($boxes)) {
116 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
117 echo "<TT><SELECT NAME=mailbox>\n";
118 for ($i = 0; $i < count($boxes); $i++
) {
120 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
121 ($boxes[$i]["unformatted"] != $trash_folder) &&
122 ($boxes[$i]["unformatted"] != $sent_folder) &&
123 (strtolower($imap_server_type) != "courier" ||
124 strtolower($boxes[$i]["unformatted"]) != "inbox.trash"))
126 $box = $boxes[$i]["unformatted-dm"];
127 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
128 echo " <OPTION VALUE=\"$box\">$box2\n";
131 echo "</SELECT></TT>\n";
132 echo "<INPUT TYPE=SUBMIT VALUE=\"";
135 echo "</FORM></TD></TR>\n";
137 echo _("No folders found") . "<br><br></td><tr>";
140 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
142 /** CREATING FOLDERS **/
143 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
144 echo _("Create Folder");
145 echo "</B></TD></TR>";
146 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
147 echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
148 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
149 echo _("as a subfolder of");
151 echo "<TT><SELECT NAME=subfolder>\n";
152 if (strtolower($imap_server_type) != "courier"){
153 if ($default_sub_of_inbox == false)
154 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
156 echo '<OPTION VALUE="">[ '._("None")." ]\n";
159 for ($i = 0; $i < count($boxes); $i++
) {
160 if (!in_array('noinferiors', $boxes[$i]['flags'])) {
161 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
162 $box = $boxes[$i]["unformatted"];
163 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
164 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
166 $box = $boxes[$i]["unformatted"];
167 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
168 if (strtolower($imap_server_type) != "courier" ||
169 strtolower($box) != "inbox.trash")
170 echo "<OPTION VALUE=\"$box\">$box2\n";
174 echo "</SELECT></TT><BR>\n";
175 if ($show_contain_subfolders_option) {
176 echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
177 echo _("Let this folder contain subfolders");
180 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
181 echo "</FORM></TD></TR>\n";
183 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
185 /** RENAMING FOLDERS **/
186 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
187 echo _("Rename a Folder");
188 echo "</B></TD></TR>";
189 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
190 if ($count_special_folders < count($boxes)) {
191 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
192 echo "<TT><SELECT NAME=old>\n";
193 for ($i = 0; $i < count($boxes); $i++
) {
196 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
197 ($boxes[$i]["unformatted"] != $trash_folder) &&
198 ($boxes[$i]["unformatted"] != $sent_folder))
200 $box = $boxes[$i]["unformatted-dm"];
201 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
202 if (strtolower($imap_server_type) != "courier" ||
strtolower($box) != "inbox.trash")
203 echo "<OPTION VALUE=\"$box\">$box2\n";
206 echo "</SELECT></TT>\n";
207 echo "<INPUT TYPE=SUBMIT VALUE=\"";
210 echo "</FORM></TD></TR>\n";
212 echo _("No folders found") . "<br><br></td></tr>";
216 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n";
218 /** UNSUBSCRIBE FOLDERS **/
219 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
220 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=3><B>";
221 echo _("Unsubscribe") . "/" . _("Subscribe");
222 echo "</B></TD></TR>";
223 echo "<TR><TD BGCOLOR=\"$color[0]\" width=49% ALIGN=CENTER>";
224 if ($count_special_folders < count($boxes)) {
225 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
226 echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n";
227 for ($i = 0; $i < count($boxes); $i++
) {
229 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
230 ($boxes[$i]["unformatted"] != $trash_folder) &&
231 ($boxes[$i]["unformatted"] != $sent_folder))
233 $box = $boxes[$i]["unformatted-dm"];
234 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
235 echo " <OPTION VALUE=\"$box\">$box2\n";
238 echo "</SELECT></TT><br>\n";
239 echo "<INPUT TYPE=SUBMIT VALUE=\"";
240 echo _("Unsubscribe");
242 echo "</FORM></TD>\n";
244 echo _("No folders were found to unsubscribe from!") . "</td>";
248 echo "<td bgcolor=\"$color[9]\" width=2%> </td>";
250 /** SUBSCRIBE TO FOLDERS **/
251 echo "<TD BGCOLOR=\"$color[0]\" widtn=49% ALIGN=CENTER>";
252 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
253 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
257 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
259 for ($p = 0; $p < count ($boxes); $p++
) {
260 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
263 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
267 if ($use_folder == true) {
268 $box[$q] = $boxes_all[$i]["unformatted-dm"];
269 $box2[$q] = $boxes_all[$i]["unformatted-disp"];
273 sqimap_logout($imap_stream);
276 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
277 echo "<tt><select name=mailbox[] multiple size=8>";
279 for ($q = 0; $q < count($box); $q++
) {
280 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
282 echo "</select></tt><br>";
283 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
284 echo "</FORM></TD></TR></TABLE><BR>\n";
286 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
289 do_hook("folders_bottom");
290 sqimap_logout($imapConnection);