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/imap.php");
17 include("../functions/array.php");
18 include("../functions/plugin.php");
20 displayPageHeader($color, _("None"));
25 <table bgcolor
="<?php echo $color[0] ?>" width
="95%" align
="center" cellpadding
="2" cellspacing
="0" border
="0">
26 <tr
><td align
="center">
28 <b
><?php
echo _("Folders"); ?
></b
>
30 <table width
="100%" border
="0" cellpadding
="5" cellspacing
="0">
31 <tr
><td bgcolor
="<?php echo $color[4] ?>" align
="center">
35 if ((isset($success) && $success) ||
36 (isset($sent_create) && $sent_create == "true") ||
37 (isset($trash_create) && $trash_create == "true")) {
38 echo "<table width=100% align=center cellpadding=2 cellspacing=0 border=0>\n";
39 echo " <tr><td align=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>";
50 } else if (($sent_create == "true") ||
($trash_create == "true")) {
51 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
52 if ($sent_create == "true") {
53 sqimap_mailbox_create ($imapConnection, $sent_folder, "");
55 if ($trash_create == "true") {
56 sqimap_mailbox_create ($imapConnection, $trash_folder, "");
58 sqimap_logout($imapConnection);
59 echo _("Folders created successfully!");
62 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>";
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)) ||
72 (!sqimap_mailbox_exists ($imapConnection, $trash_folder))) {
73 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
74 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
75 echo _("Special Folder Options");
76 echo "</B></TD></TR>";
77 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
78 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.");
79 echo "<FORM ACTION=\"folders.php\" METHOD=\"POST\">\n";
80 if (!sqimap_mailbox_exists ($imapConnection, $sent_folder) && $sent_folder != "none") {
81 echo _("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create value=true><br>\n";
83 if (!sqimap_mailbox_exists ($imapConnection, $trash_folder) && $trash_folder != "none"){
84 echo _("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create value=true><br>\n";
86 echo "<INPUT TYPE=submit VALUE="._("Create").">";
87 echo "</FORM></TD></TR></TABLE><br>";
91 /** DELETING FOLDERS **/
92 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
93 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
94 echo _("Delete Folder");
95 echo "</B></TD></TR>";
96 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
98 $count_special_folders = 0;
100 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash)
105 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
106 if (strtolower($boxes[$p]["unformatted"]) == "inbox")
107 $count_special_folders++
;
108 else if (strtolower($imap_server_type) == "courier" &&
109 strtolower($boxes[$p]["unformatted"]) == "inbox.trash")
110 $count_special_folders++
;
111 else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
112 $count_special_folders++
;
113 else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
114 $count_special_folders++
;
117 if ($count_special_folders < count($boxes)) {
118 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
119 echo "<TT><SELECT NAME=mailbox>\n";
120 for ($i = 0; $i < count($boxes); $i++
) {
122 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
123 ($boxes[$i]["unformatted"] != $trash_folder) &&
124 ($boxes[$i]["unformatted"] != $sent_folder) &&
125 (strtolower($imap_server_type) != "courier" ||
126 strtolower($boxes[$i]["unformatted"]) != "inbox.trash"))
128 $box = $boxes[$i]["unformatted-dm"];
129 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
130 echo " <OPTION VALUE=\"$box\">$box2\n";
133 echo "</SELECT></TT>\n";
134 echo "<INPUT TYPE=SUBMIT VALUE=\"";
137 echo "</FORM></TD></TR>\n";
139 echo _("No folders found") . "<br><br></td><tr>";
142 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
144 /** CREATING FOLDERS **/
145 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
146 echo _("Create Folder");
147 echo "</B></TD></TR>";
148 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
149 echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
150 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
151 echo _("as a subfolder of");
153 echo "<TT><SELECT NAME=subfolder>\n";
154 if (strtolower($imap_server_type) != "courier"){
155 if ($default_sub_of_inbox == false)
156 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
158 echo '<OPTION VALUE="">[ '._("None")." ]\n";
161 for ($i = 0; $i < count($boxes); $i++
) {
162 if (!in_array('noinferiors', $boxes[$i]['flags'])) {
163 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
164 $box = $boxes[$i]["unformatted"];
165 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
166 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
168 $box = $boxes[$i]["unformatted"];
169 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
170 if (strtolower($imap_server_type) != "courier" ||
171 strtolower($box) != "inbox.trash")
172 echo "<OPTION VALUE=\"$box\">$box2\n";
176 echo "</SELECT></TT>\n";
177 if ($show_contain_subfolders_option) {
178 echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
179 echo _("Let this folder contain subfolders");
182 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
183 echo "</FORM></TD></TR>\n";
185 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
187 /** RENAMING FOLDERS **/
188 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
189 echo _("Rename a Folder");
190 echo "</B></TD></TR>";
191 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
192 if ($count_special_folders < count($boxes)) {
193 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
194 echo "<TT><SELECT NAME=old>\n";
195 for ($i = 0; $i < count($boxes); $i++
) {
198 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
199 ($boxes[$i]["unformatted"] != $trash_folder) &&
200 ($boxes[$i]["unformatted"] != $sent_folder))
202 $box = $boxes[$i]["unformatted-dm"];
203 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
204 if (strtolower($imap_server_type) != "courier" ||
strtolower($box) != "inbox.trash")
205 echo "<OPTION VALUE=\"$box\">$box2\n";
208 echo "</SELECT></TT>\n";
209 echo "<INPUT TYPE=SUBMIT VALUE=\"";
212 echo "</FORM></TD></TR>\n";
214 echo _("No folders found") . "<br><br></td></tr>";
218 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n";
220 /** UNSUBSCRIBE FOLDERS **/
221 echo "<TABLE WIDTH=70% COLS=2 ALIGN=CENTER cellpadding=2 cellspacing=1 border=0>\n";
222 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=2><B>";
223 echo _("Unsubscribe") . "/" . _("Subscribe");
224 echo "</B></TD></TR>\n";
225 echo "<TR><TD BGCOLOR=\"$color[0]\" width=50% ALIGN=CENTER>\n";
226 if ($count_special_folders < count($boxes)) {
227 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
228 echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n";
229 for ($i = 0; $i < count($boxes); $i++
) {
231 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
232 ($boxes[$i]["unformatted"] != $trash_folder) &&
233 ($boxes[$i]["unformatted"] != $sent_folder))
235 $box = $boxes[$i]["unformatted-dm"];
236 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
237 echo " <OPTION VALUE=\"$box\">$box2\n";
240 echo "</SELECT></TT><br>\n";
241 echo "<INPUT TYPE=SUBMIT VALUE=\"";
242 echo _("Unsubscribe");
244 echo "</FORM></TD>\n";
246 echo _("No folders were found to unsubscribe from!") . "</td>";
250 /** SUBSCRIBE TO FOLDERS **/
251 echo "<TD BGCOLOR=\"$color[0]\" widtn=50% 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>";
291 <?php
do_hook("folders_bottom"); ?
>
301 sqimap_logout($imapConnection);