95d938cb4b51157d041293ceae19e246ed6d7164
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/page_header.php");
17 include("../functions/imap.php");
18 include("../functions/array.php");
19 include("../functions/plugin.php");
20 include("../src/load_prefs.php");
22 displayPageHeader($color, _("None"));
25 echo "<TABLE WIDTH=95% COLS=1 ALIGN=CENTER>\n";
26 echo " <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><b>\n";
28 echo " </b></TD></TR>\n";
31 if ((isset($success) && $success) ||
32 (isset($sent_create) && $sent_create == "true") ||
33 (isset($trash_create) && $trash_create == "true")) {
34 echo "<table width=100% align=center cellpadding=3 cellspacing=0 border=0>\n";
35 echo " <tr><td><center>\n";
36 if ($success == "subscribe") {
37 echo "<b>" . _("Subscribed successfully!") . "</b><br>";
38 } else if ($success == "unsubscribe") {
39 echo "<b>" . _("Unsubscribed successfully!") . "</b><br>";
40 } else if ($success == "delete") {
41 echo "<b>" . _("Deleted folder successfully!") . "</b><br>";
42 } else if ($success == "create") {
43 echo "<b>" . _("Created folder successfully!") . "</b><br>";
44 } else if ($success == "rename") {
45 echo "<b>" . _("Renamed successfully!") . "</b><br>";
46 } else if (($sent_create == "true") ||
($trash_create == "true")) {
47 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
48 if ($sent_create == "true") {
49 sqimap_mailbox_create ($imapConnection, $sent_folder, "");
51 if ($trash_create == "true") {
52 sqimap_mailbox_create ($imapConnection, $trash_folder, "");
54 sqimap_logout($imapConnection);
55 echo _("Folders created successfully!");
58 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>";
59 echo " </center></td></tr>\n";
60 echo "</table><br>\n";
62 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
63 $boxes = sqimap_mailbox_list($imapConnection);
65 //display form option for creating Sent and Trash folder
66 if ($imap_server_type == "cyrus" && ($sent_folder != "none" ||
$trash_folder != "none")) {
67 if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) ||
68 (!sqimap_mailbox_exists ($imapConnection, $trash_folder))) {
69 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
70 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
71 echo _("Special Folder Options");
72 echo "</B></TD></TR>";
73 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
74 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.");
75 echo "<FORM ACTION=\"folders.php\" METHOD=\"POST\">\n";
76 if (!sqimap_mailbox_exists ($imapConnection, $sent_folder) && $sent_folder != "none") {
77 echo _("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create value=true><br>\n";
79 if (!sqimap_mailbox_exists ($imapConnection, $trash_folder) && $trash_folder != "none"){
80 echo _("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create value=true><br>\n";
82 echo "<INPUT TYPE=submit VALUE="._("Create").">";
83 echo "</FORM></TD></TR></TABLE><br>";
87 /** DELETING FOLDERS **/
88 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
89 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
90 echo _("Delete Folder");
91 echo "</B></TD></TR>";
92 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
94 $count_special_folders = 0;
96 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash)
101 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
102 if (strtolower($boxes[$p]["unformatted"]) == "inbox")
103 $count_special_folders++
;
104 else if (strtolower($imap_server_type) == "courier" &&
105 strtolower($boxes[$p]["unformatted"]) == "inbox.trash")
106 $count_special_folders++
;
107 else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
108 $count_special_folders++
;
109 else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
110 $count_special_folders++
;
113 if ($count_special_folders < count($boxes)) {
114 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
115 echo "<TT><SELECT NAME=mailbox>\n";
116 for ($i = 0; $i < count($boxes); $i++
) {
118 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
119 ($boxes[$i]["unformatted"] != $trash_folder) &&
120 ($boxes[$i]["unformatted"] != $sent_folder) &&
121 (strtolower($imap_server_type) != "courier" ||
122 strtolower($boxes[$i]["unformatted"]) != "inbox.trash"))
124 $box = $boxes[$i]["unformatted-dm"];
125 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
126 echo " <OPTION VALUE=\"$box\">$box2\n";
129 echo "</SELECT></TT>\n";
130 echo "<INPUT TYPE=SUBMIT VALUE=\"";
133 echo "</FORM></TD></TR>\n";
135 echo _("No folders found") . "<br><br></td><tr>";
138 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
140 /** CREATING FOLDERS **/
141 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
142 echo _("Create Folder");
143 echo "</B></TD></TR>";
144 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
145 echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
146 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
147 echo _("as a subfolder of");
149 echo "<TT><SELECT NAME=subfolder>\n";
150 if (strtolower($imap_server_type) != "courier"){
151 if ($default_sub_of_inbox == false)
152 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
154 echo '<OPTION VALUE="">[ '._("None")." ]\n";
157 for ($i = 0; $i < count($boxes); $i++
) {
158 if (!in_array('noinferiors', $boxes[$i]['flags'])) {
159 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
160 $box = $boxes[$i]["unformatted"];
161 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
162 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
164 $box = $boxes[$i]["unformatted"];
165 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
166 if (strtolower($imap_server_type) != "courier" ||
167 strtolower($box) != "inbox.trash")
168 echo "<OPTION VALUE=\"$box\">$box2\n";
172 echo "</SELECT></TT><BR>\n";
173 if ($show_contain_subfolders_option) {
174 echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
175 echo _("Let this folder contain subfolders");
178 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
179 echo "</FORM></TD></TR>\n";
181 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
183 /** RENAMING FOLDERS **/
184 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
185 echo _("Rename a Folder");
186 echo "</B></TD></TR>";
187 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
188 if ($count_special_folders < count($boxes)) {
189 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
190 echo "<TT><SELECT NAME=old>\n";
191 for ($i = 0; $i < count($boxes); $i++
) {
194 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
195 ($boxes[$i]["unformatted"] != $trash_folder) &&
196 ($boxes[$i]["unformatted"] != $sent_folder))
198 $box = $boxes[$i]["unformatted-dm"];
199 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
200 if (strtolower($imap_server_type) != "courier" ||
strtolower($box) != "inbox.trash")
201 echo "<OPTION VALUE=\"$box\">$box2\n";
204 echo "</SELECT></TT>\n";
205 echo "<INPUT TYPE=SUBMIT VALUE=\"";
208 echo "</FORM></TD></TR>\n";
210 echo _("No folders found") . "<br><br></td></tr>";
214 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n";
216 /** UNSUBSCRIBE FOLDERS **/
217 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
218 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=3><B>";
219 echo _("Unsubscribe") . "/" . _("Subscribe");
220 echo "</B></TD></TR>";
221 echo "<TR><TD BGCOLOR=\"$color[0]\" width=49% ALIGN=CENTER>";
222 if ($count_special_folders < count($boxes)) {
223 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
224 echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n";
225 for ($i = 0; $i < count($boxes); $i++
) {
227 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
228 ($boxes[$i]["unformatted"] != $trash_folder) &&
229 ($boxes[$i]["unformatted"] != $sent_folder))
231 $box = $boxes[$i]["unformatted-dm"];
232 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
233 echo " <OPTION VALUE=\"$box\">$box2\n";
236 echo "</SELECT></TT><br>\n";
237 echo "<INPUT TYPE=SUBMIT VALUE=\"";
238 echo _("Unsubscribe");
240 echo "</FORM></TD>\n";
242 echo _("No folders were found to unsubscribe from!") . "</td>";
246 echo "<td bgcolor=\"$color[9]\" width=2%> </td>";
248 /** SUBSCRIBE TO FOLDERS **/
249 echo "<TD BGCOLOR=\"$color[0]\" widtn=49% ALIGN=CENTER>";
250 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
251 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
255 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
257 for ($p = 0; $p < count ($boxes); $p++
) {
258 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
261 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
265 if ($use_folder == true) {
266 $box[$q] = $boxes_all[$i]["unformatted-dm"];
267 $box2[$q] = $boxes_all[$i]["unformatted-disp"];
271 sqimap_logout($imap_stream);
274 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
275 echo "<tt><select name=mailbox[] multiple size=8>";
277 for ($q = 0; $q < count($box); $q++
) {
278 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
280 echo "</select></tt><br>";
281 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
282 echo "</FORM></TD></TR></TABLE><BR>\n";
284 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
287 do_hook("folders_bottom");
288 sqimap_logout($imapConnection);