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");
26 include("../src/load_prefs.php");
28 displayPageHeader($color, "None");
31 echo "<TABLE WIDTH=95% COLS=1 ALIGN=CENTER>\n";
32 echo " <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><b>\n";
34 echo " </b></TD></TR>\n";
38 echo "<table width=100% align=center cellpadding=3 cellspacing=0 border=0>\n";
39 echo " <tr><td><center>\n";
40 if ($success == "subscribe") {
41 echo "<b>" . _("Subscribed successfully!") . "</b><br>";
42 } else if ($success == "unsubscribe") {
43 echo "<b>" . _("Unsubscribed successfully!") . "</b><br>";
44 } else if ($success == "delete") {
45 echo "<b>" . _("Deleted folder successfully!") . "</b><br>";
46 } else if ($success == "create") {
47 echo "<b>" . _("Created folder successfully!") . "</b><br>";
48 } else if ($success == "rename") {
49 echo "<b>" . _("Renamed successfully!") . "</b><br>";
51 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>";
52 echo " </center></td></tr>\n";
53 echo "</table><br>\n";
55 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
56 $boxes = sqimap_mailbox_list($imapConnection);
58 /** Cyrus Folder Options**/
59 //Creates the Sent and Trash folder
60 if (($sent_create == "true") ||
($trash_create == "true")) {
61 if ($sent_create == "true") {
62 sqimap_mailbox_create ($imapConnection, $sent_folder, "");
64 if ($trash_create == "true") {
65 sqimap_mailbox_create ($imapConnection, $trash_folder, "");
67 echo "<BR><BR><CENTER><b>";
68 echo _("Mailboxes Created Successfully!");
69 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
72 echo _("to continue.");
74 echo "</BODY></HTML>";
79 //display form option for creating Sent and Trash folder
80 if ($imap_server_type == "cyrus") {
81 if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) ||
(!sqimap_mailbox_exists ($imapConnection, $trash_folder))) {
82 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
83 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
84 echo _("Special Folder Options");
85 echo "</B></TD></TR>";
86 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
87 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.");
88 echo "<FORM ACTION=\"folders.php\" METHOD=\"POST\">\n";
89 if (!sqimap_mailbox_exists ($imapConnection, $sent_folder)) {
90 echo _("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create value=true><br>\n";
92 if (!sqimap_mailbox_exists ($imapConnection, $trash_folder)){
93 echo _("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create value=true><br>\n";
94 echo "<INPUT TYPE=submit VALUE=Create>";
95 echo "</FORM></TD></TR>\n";
100 /** DELETING FOLDERS **/
101 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
102 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER>";
103 echo _("Delete Folder");
105 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
107 $count_special_folders = 0;
114 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
115 if (strtolower($boxes[$p]["unformatted"]) == "inbox")
116 $count_special_folders++
;
117 else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
118 $count_special_folders++
;
119 else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
120 $count_special_folders++
;
123 if ($count_special_folders < count($boxes)) {
124 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
125 echo "<TT><SELECT NAME=mailbox>\n";
126 for ($i = 0; $i < count($boxes); $i++
) {
128 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
129 ($boxes[$i]["unformatted"] != $trash_folder) &&
130 ($boxes[$i]["unformatted"] != $sent_folder))
132 $box = $boxes[$i]["unformatted-dm"];
133 $box2 = replace_spaces($boxes[$i]["formatted"]);
134 echo " <OPTION VALUE=\"$box\">$box2\n";
137 echo "</SELECT></TT>\n";
138 echo "<INPUT TYPE=SUBMIT VALUE=\"";
141 echo "</FORM></TD></TR>\n";
143 echo _("No mailboxes found") . "<br><br></td><tr>";
146 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
148 /** CREATING FOLDERS **/
149 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER>";
150 echo _("Create Folder");
152 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
153 echo "<FORM ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
154 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
155 echo _("as a subfolder of");
157 echo "<TT><SELECT NAME=subfolder>\n";
158 if ($default_sub_of_inbox == false)
159 echo "<OPTION SELECTED>[ None ]\n";
161 echo "<OPTION>[ None ]\n";
163 for ($i = 0; $i < count($boxes); $i++
) {
164 if (count($boxes[$i]["flags"]) > 0) {
166 for ($j = 0; $j < count($boxes[$i]["flags"]); $j++
) {
167 if ($boxes[$i]["flags"][$j] == "noinferiors") {
172 if ($noinf == false) {
173 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
174 $box = $boxes[$i]["unformatted"];
175 $box2 = replace_spaces($boxes[$i]["formatted"]);
176 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
178 $box = $boxes[$i]["unformatted"];
179 $box2 = replace_spaces($boxes[$i]["formatted"]);
180 echo "<OPTION VALUE=\"$box\">$box2\n";
184 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
185 $box = $boxes[$i]["unformatted"];
186 $box2 = replace_spaces($boxes[$i]["formatted"]);
187 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
189 $box = $boxes[$i]["unformatted"];
190 $box2 = replace_spaces($boxes[$i]["formatted"]);
191 echo "<OPTION VALUE=\"$box\">$box2\n";
195 echo "</SELECT></TT><BR>\n";
196 if ($show_contain_subfolders_option) {
197 echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
198 echo _("Let this folder contain subfolders");
201 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
202 echo "</FORM></TD></TR>\n";
204 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
206 /** RENAMING FOLDERS **/
207 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER>";
208 echo _("Rename a Folder");
210 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
211 if ($count_special_folders < count($boxes)) {
212 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
213 echo "<TT><SELECT NAME=old>\n";
214 for ($i = 0; $i < count($boxes); $i++
) {
217 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
218 ($boxes[$i]["unformatted"] != $trash_folder) &&
219 ($boxes[$i]["unformatted"] != $sent_folder))
221 $box = $boxes[$i]["unformatted-dm"];
222 $box2 = replace_spaces($boxes[$i]["formatted"]);
223 echo " <OPTION VALUE=\"$box\">$box2\n";
226 echo "</SELECT></TT>\n";
227 echo "<INPUT TYPE=SUBMIT VALUE=\"";
230 echo "</FORM></TD></TR>\n";
232 echo _("No mailboxes found") . "<br><br></td></tr>";
236 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n";
238 /** UNSUBSCRIBE FOLDERS **/
239 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
240 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=3>";
241 echo _("Unsubscribe") . "/" . _("Subscribe");
243 echo "<TR><TD BGCOLOR=\"$color[0]\" width=49% ALIGN=CENTER>";
244 if ($count_special_folders < count($boxes)) {
245 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
246 echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n";
247 for ($i = 0; $i < count($boxes); $i++
) {
249 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
250 ($boxes[$i]["unformatted"] != $trash_folder) &&
251 ($boxes[$i]["unformatted"] != $sent_folder))
253 $box = $boxes[$i]["unformatted-dm"];
254 $box2 = replace_spaces($boxes[$i]["formatted"]);
255 echo " <OPTION VALUE=\"$box\">$box2\n";
258 echo "</SELECT></TT><br>\n";
259 echo "<INPUT TYPE=SUBMIT VALUE=\"";
260 echo _("Unsubscribe");
262 echo "</FORM></TD>\n";
264 echo _("No folders were found to unsubscribe from!") . "</td>";
268 echo "<td bgcolor=\"$color[9]\" width=2%> </td>";
270 /** SUBSCRIBE TO FOLDERS **/
271 echo "<TD BGCOLOR=\"$color[0]\" widtn=49% ALIGN=CENTER>";
272 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
273 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
277 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
279 for ($p = 0; $p < count ($boxes); $p++
) {
280 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
283 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
287 if ($use_folder == true) {
288 $box[$q] = $boxes_all[$i]["unformatted-dm"];
289 $box2[$q] = $boxes_all[$i]["formatted"];
293 sqimap_logout($imap_stream);
296 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
297 echo "<tt><select name=mailbox[] multiple size=8>";
299 for ($q = 0; $q < count($box); $q++
) {
300 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
302 echo "</select></tt><br>";
303 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
304 echo "</FORM></TD></TR></TABLE><BR>\n";
306 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
309 sqimap_logout($imapConnection);