a1f2f426634a09129821278a6aee5dac206488c0
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"));
29 <table bgcolor
="<?php echo $color[0] ?>" width
="95%" align
="center" cellpadding
="2" cellspacing
="0" border
="0">
30 <tr
><td align
="center">
32 <b
><?php
echo _("Folders"); ?
></b
>
34 <table width
="100%" border
="0" cellpadding
="5" cellspacing
="0">
35 <tr
><td bgcolor
="<?php echo $color[4] ?>" align
="center">
39 if ((isset($success) && $success) ||
40 (isset($sent_create) && $sent_create == "true") ||
41 (isset($trash_create) && $trash_create == "true")) {
42 echo "<table width=100% align=center cellpadding=2 cellspacing=0 border=0>\n";
43 echo " <tr><td align=center>\n";
44 if ($success == "subscribe") {
45 echo "<b>" . _("Subscribed successfully!") . "</b><br>";
46 } else if ($success == "unsubscribe") {
47 echo "<b>" . _("Unsubscribed successfully!") . "</b><br>";
48 } else if ($success == "delete") {
49 echo "<b>" . _("Deleted folder successfully!") . "</b><br>";
50 } else if ($success == "create") {
51 echo "<b>" . _("Created folder successfully!") . "</b><br>";
52 } else if ($success == "rename") {
53 echo "<b>" . _("Renamed successfully!") . "</b><br>";
54 } else if (($sent_create == "true") ||
($trash_create == "true")) {
55 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
56 if ($sent_create == "true") {
57 sqimap_mailbox_create ($imapConnection, $sent_folder, "");
59 if ($trash_create == "true") {
60 sqimap_mailbox_create ($imapConnection, $trash_folder, "");
62 sqimap_logout($imapConnection);
63 echo _("Folders created successfully!");
66 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>";
68 echo "</table><br>\n";
70 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
71 $boxes = sqimap_mailbox_list($imapConnection);
73 //display form option for creating Sent and Trash folder
74 if ($imap_server_type == "cyrus" && ($sent_folder != "none" ||
$trash_folder != "none")) {
75 if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) ||
76 (!sqimap_mailbox_exists ($imapConnection, $trash_folder))) {
77 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
78 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
79 echo _("Special Folder Options");
80 echo "</B></TD></TR>";
81 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
82 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.");
83 echo "<FORM ACTION=\"folders.php\" METHOD=\"POST\">\n";
84 if (!sqimap_mailbox_exists ($imapConnection, $sent_folder) && $sent_folder != "none") {
85 echo _("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create value=true><br>\n";
87 if (!sqimap_mailbox_exists ($imapConnection, $trash_folder) && $trash_folder != "none"){
88 echo _("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create value=true><br>\n";
90 echo "<INPUT TYPE=submit VALUE="._("Create").">";
91 echo "</FORM></TD></TR></TABLE><br>";
95 /** DELETING FOLDERS **/
96 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
97 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
98 echo _("Delete Folder");
99 echo "</B></TD></TR>";
100 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
102 $count_special_folders = 0;
104 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash)
109 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
110 if (strtolower($boxes[$p]["unformatted"]) == "inbox")
111 $count_special_folders++
;
112 else if (strtolower($imap_server_type) == "courier" &&
113 strtolower($boxes[$p]["unformatted"]) == "inbox.trash")
114 $count_special_folders++
;
115 else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
116 $count_special_folders++
;
117 else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
118 $count_special_folders++
;
121 if ($count_special_folders < count($boxes)) {
122 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
123 echo "<TT><SELECT NAME=mailbox>\n";
124 for ($i = 0; $i < count($boxes); $i++
) {
126 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
127 ($boxes[$i]["unformatted"] != $trash_folder) &&
128 ($boxes[$i]["unformatted"] != $sent_folder) &&
129 (strtolower($imap_server_type) != "courier" ||
130 strtolower($boxes[$i]["unformatted"]) != "inbox.trash"))
132 $box = $boxes[$i]["unformatted-dm"];
133 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
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 folders 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><B>";
150 echo _("Create Folder");
151 echo "</B></TD></TR>";
152 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
153 echo "<FORM NAME=cf 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 (strtolower($imap_server_type) != "courier"){
159 if ($default_sub_of_inbox == false)
160 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
162 echo '<OPTION VALUE="">[ '._("None")." ]\n";
165 for ($i = 0; $i < count($boxes); $i++
) {
166 if (!in_array('noinferiors', $boxes[$i]['flags'])) {
167 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
168 $box = $boxes[$i]["unformatted"];
169 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
170 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
172 $box = $boxes[$i]["unformatted"];
173 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
174 if (strtolower($imap_server_type) != "courier" ||
175 strtolower($box) != "inbox.trash")
176 echo "<OPTION VALUE=\"$box\">$box2\n";
180 echo "</SELECT></TT>\n";
181 if ($show_contain_subfolders_option) {
182 echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
183 echo _("Let this folder contain subfolders");
186 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
187 echo "</FORM></TD></TR>\n";
189 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
191 /** RENAMING FOLDERS **/
192 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
193 echo _("Rename a Folder");
194 echo "</B></TD></TR>";
195 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
196 if ($count_special_folders < count($boxes)) {
197 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
198 echo "<TT><SELECT NAME=old>\n";
199 for ($i = 0; $i < count($boxes); $i++
) {
202 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
203 ($boxes[$i]["unformatted"] != $trash_folder) &&
204 ($boxes[$i]["unformatted"] != $sent_folder))
206 $box = $boxes[$i]["unformatted-dm"];
207 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
208 if (strtolower($imap_server_type) != "courier" ||
strtolower($box) != "inbox.trash")
209 echo "<OPTION VALUE=\"$box\">$box2\n";
212 echo "</SELECT></TT>\n";
213 echo "<INPUT TYPE=SUBMIT VALUE=\"";
216 echo "</FORM></TD></TR>\n";
218 echo _("No folders found") . "<br><br></td></tr>";
222 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n";
224 /** UNSUBSCRIBE FOLDERS **/
225 echo "<TABLE WIDTH=70% COLS=2 ALIGN=CENTER cellpadding=2 cellspacing=1 border=0>\n";
226 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=2><B>";
227 echo _("Unsubscribe") . "/" . _("Subscribe");
228 echo "</B></TD></TR>\n";
229 echo "<TR><TD BGCOLOR=\"$color[0]\" width=50% ALIGN=CENTER>\n";
230 if ($count_special_folders < count($boxes)) {
231 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
232 echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n";
233 for ($i = 0; $i < count($boxes); $i++
) {
235 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
236 ($boxes[$i]["unformatted"] != $trash_folder) &&
237 ($boxes[$i]["unformatted"] != $sent_folder))
239 $box = $boxes[$i]["unformatted-dm"];
240 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
241 echo " <OPTION VALUE=\"$box\">$box2\n";
244 echo "</SELECT></TT><br>\n";
245 echo "<INPUT TYPE=SUBMIT VALUE=\"";
246 echo _("Unsubscribe");
248 echo "</FORM></TD>\n";
250 echo _("No folders were found to unsubscribe from!") . "</td>";
254 /** SUBSCRIBE TO FOLDERS **/
255 echo "<TD BGCOLOR=\"$color[0]\" widtn=50% ALIGN=CENTER>";
256 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
257 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
261 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
263 for ($p = 0; $p < count ($boxes); $p++
) {
264 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
267 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
271 if ($use_folder == true) {
272 $box[$q] = $boxes_all[$i]["unformatted-dm"];
273 $box2[$q] = $boxes_all[$i]["unformatted-disp"];
277 sqimap_logout($imap_stream);
280 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
281 echo "<tt><select name=mailbox[] multiple size=8>";
283 for ($q = 0; $q < count($box); $q++
) {
284 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
286 echo "</select></tt><br>";
287 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
288 echo "</FORM></TD></TR></TABLE><BR>\n";
290 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
295 <?php
do_hook("folders_bottom"); ?
>
305 sqimap_logout($imapConnection);