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");
30 echo "<TABLE WIDTH=100% COLS=1 ALIGN=CENTER>\n";
31 echo " <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>\n";
36 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
37 $boxes = sqimap_mailbox_list($imapConnection);
39 /** Cyrus Folder Options**/
40 //Creates the Sent and Trash folder
41 if (($sent_create == "true") ||
($trash_create == "true")) {
42 if ($sent_create == "true") {
43 sqimap_mailbox_create ($imapConnection, $sent_folder, "");
45 if ($trash_create == "true") {
46 sqimap_mailbox_create ($imapConnection, $trash_folder, "");
48 echo "<BR><BR><CENTER><b>";
49 echo _("Mailboxes Created Successfully!");
50 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
53 echo _("to continue.");
55 echo "</BODY></HTML>";
60 //display form option for creating Sent and Trash folder
61 if ($imap_server_type == "cyrus") {
62 if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) ||
(!sqimap_mailbox_exists ($imapConnection, $trash_folder))) {
63 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
64 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
65 echo _("Special Folder Options");
66 echo "</B></TD></TR>";
67 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
68 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.");
69 echo "<FORM ACTION=\"folders.php\" METHOD=\"POST\">\n";
70 if (!sqimap_mailbox_exists ($imapConnection, $sent_folder)) {
71 echo _("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create value=true><br>\n";
73 if (!sqimap_mailbox_exists ($imapConnection, $trash_folder)){
74 echo _("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create value=true><br>\n";
75 echo "<INPUT TYPE=submit VALUE=Create>";
76 echo "</FORM></TD></TR>\n";
81 /** DELETING FOLDERS **/
82 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
83 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
84 echo _("Delete Folder");
85 echo "</B></TD></TR>";
86 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
88 $count_special_folders = 0;
95 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
96 if (strtolower($boxes[$i]["unformatted"]) == "inbox")
97 $count_special_folders++
;
98 else if ($boxes[$i]["unformatted"] == $trash_folder)
99 $count_special_folders++
;
100 else if ($boxes[$i]["unformatted"] == $sent_folder)
101 $count_special_folders++
;
104 if ($count_special_folders < count($boxes)) {
105 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
106 echo "<TT><SELECT NAME=mailbox>\n";
107 for ($i = 0; $i < count($boxes); $i++
) {
109 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
110 ($boxes[$i]["unformatted"] != $trash_folder) &&
111 ($boxes[$i]["unformatted"] != $sent_folder))
113 $box = $boxes[$i]["unformatted-dm"];
114 $box2 = replace_spaces($boxes[$i]["formatted"]);
115 echo " <OPTION VALUE=\"$box\">$box2\n";
118 echo "</SELECT></TT>\n";
119 echo "<INPUT TYPE=SUBMIT VALUE=\"";
122 echo "</FORM><BR></TD></TR>\n";
124 echo _("No mailboxes found") . "<br><br></td><tr>";
128 /** CREATING FOLDERS **/
129 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
130 echo _("Create Folder");
131 echo "</B></TD></TR>";
132 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
133 echo "<FORM ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
134 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
135 echo _("as a subfolder of");
137 echo "<TT><SELECT NAME=subfolder>\n";
138 if ($default_sub_of_inbox == false)
139 echo "<OPTION SELECTED>[ None ]\n";
141 echo "<OPTION>[ None ]\n";
143 for ($i = 0; $i < count($boxes); $i++
) {
144 if (count($boxes[$i]["flags"]) > 0) {
145 for ($j = 0; $j < count($boxes[$i]["flags"]); $j++
) {
146 if ($boxes[$i]["flags"][$j] != "noinferiors") {
147 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
148 $box = $boxes[$i]["unformatted"];
149 $box2 = replace_spaces($boxes[$i]["formatted"]);
150 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
152 $box = $boxes[$i]["unformatted"];
153 $box2 = replace_spaces($boxes[$i]["formatted"]);
154 echo "<OPTION VALUE=\"$box\">$box2\n";
159 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
160 $box = $boxes[$i]["unformatted"];
161 $box2 = replace_spaces($boxes[$i]["formatted"]);
162 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
164 $box = $boxes[$i]["unformatted"];
165 $box2 = replace_spaces($boxes[$i]["formatted"]);
166 echo "<OPTION VALUE=\"$box\">$box2\n";
170 echo "</SELECT></TT><BR>\n";
171 if ($show_contain_subfolders_option) {
172 echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
173 echo _("Let this folder contain subfolders");
176 echo "<INPUT TYPE=SUBMIT VALUE=Create>\n";
177 echo "</FORM><BR></TD></TR><BR>\n";
179 /** RENAMING FOLDERS **/
180 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
181 echo _("Rename a Folder");
182 echo "</B></TD></TR>";
183 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
184 if ($count_special_folders < count($boxes)) {
185 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
186 echo "<TT><SELECT NAME=old>\n";
187 for ($i = 0; $i < count($boxes); $i++
) {
190 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
191 ($boxes[$i]["unformatted"] != $trash_folder) &&
192 ($boxes[$i]["unformatted"] != $sent_folder))
194 $box = $boxes[$i]["unformatted-dm"];
195 $box2 = replace_spaces($boxes[$i]["formatted"]);
196 echo " <OPTION VALUE=\"$box\">$box2\n";
199 echo "</SELECT></TT>\n";
200 echo "<INPUT TYPE=SUBMIT VALUE=\"";
203 echo "</FORM></TD></TR>\n";
205 echo _("No mailboxes found") . "<br><br></td></tr>";
209 /** UNSUBSCRIBE FOLDERS **/
210 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
211 echo _("Unsubscribe/Subscribe");
212 echo "</B></TD></TR>";
213 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
214 if ($count_special_folders < count($boxes)) {
215 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
216 echo "<TT><SELECT NAME=mailbox>\n";
217 for ($i = 0; $i < count($boxes); $i++
) {
219 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
220 ($boxes[$i]["unformatted"] != $trash_folder) &&
221 ($boxes[$i]["unformatted"] != $sent_folder))
223 $box = $boxes[$i]["unformatted-dm"];
224 $box2 = replace_spaces($boxes[$i]["formatted"]);
225 echo " <OPTION VALUE=\"$box\">$box2\n";
228 echo "</SELECT></TT>\n";
229 echo "<INPUT TYPE=SUBMIT VALUE=\"";
230 echo _("Unsubscribe");
232 echo "</FORM></TD></TR>\n";
234 echo _("No mailboxes found") . "<br><br></td></tr>";
238 /** SUBSCRIBE TO FOLDERS **/
240 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
241 if ($count_special_folders <= count($boxes)) {
242 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
243 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
245 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
246 echo "<tt><select name=mailbox>";
247 for ($i = 0; $i < count($boxes_all); $i++
) {
249 for ($p = 0; $p < count ($boxes); $p++
) {
250 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
253 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
257 if ($use_folder == true) {
258 $box = $boxes_all[$i]["unformatted-dm"];
259 $box2 = replace_spaces($boxes_all[$i]["formatted"]);
260 echo " <OPTION VALUE=\"$box\">$box2\n";
263 echo "</select></tt>";
264 echo "<INPUT TYPE=SUBMIT VALUE=\"";
267 echo "</FORM></TD></TR></TABLE><BR>\n";
269 echo _("No mailboxes found") . "<br><br></td></tr></table>";