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 require_once('../src/validate.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/array.php');
18 require_once('../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>";
52 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>";
54 echo "</table><br>\n";
56 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
57 $boxes = sqimap_mailbox_list($imapConnection);
59 /** DELETING FOLDERS **/
60 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
61 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
62 echo _("Delete Folder");
63 echo "</B></TD></TR>";
64 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
66 $count_special_folders = 0;
68 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash)
73 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
74 if (strtolower($boxes[$p]["unformatted"]) == "inbox")
75 $count_special_folders++
;
76 else if (strtolower($imap_server_type) == "courier" &&
77 strtolower($boxes[$p]["unformatted"]) == "inbox.trash")
78 $count_special_folders++
;
79 else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
80 $count_special_folders++
;
81 else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
82 $count_special_folders++
;
85 if ($count_special_folders < count($boxes)) {
86 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
87 echo "<TT><SELECT NAME=mailbox>\n";
88 for ($i = 0; $i < count($boxes); $i++
) {
90 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
91 ($boxes[$i]["unformatted"] != $trash_folder) &&
92 ($boxes[$i]["unformatted"] != $sent_folder) &&
93 (strtolower($imap_server_type) != "courier" ||
94 strtolower($boxes[$i]["unformatted"]) != "inbox.trash"))
96 $box = $boxes[$i]["unformatted-dm"];
97 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
98 echo " <OPTION VALUE=\"$box\">$box2\n";
101 echo "</SELECT></TT>\n";
102 echo "<INPUT TYPE=SUBMIT VALUE=\"";
105 echo "</FORM></TD></TR>\n";
107 echo _("No folders found") . "<br><br></td><tr>";
110 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
112 /** CREATING FOLDERS **/
113 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
114 echo _("Create Folder");
115 echo "</B></TD></TR>";
116 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
117 echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
118 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
119 echo _("as a subfolder of");
121 echo "<TT><SELECT NAME=subfolder>\n";
122 if (strtolower($imap_server_type) != "courier"){
123 if ($default_sub_of_inbox == false)
124 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
126 echo '<OPTION VALUE="">[ '._("None")." ]\n";
129 for ($i = 0; $i < count($boxes); $i++
) {
130 if (!in_array('noinferiors', $boxes[$i]['flags'])) {
131 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
132 $box = $boxes[$i]["unformatted"];
133 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
134 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
136 $box = $boxes[$i]["unformatted"];
137 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
138 if (strtolower($imap_server_type) != "courier" ||
139 strtolower($box) != "inbox.trash")
140 echo "<OPTION VALUE=\"$box\">$box2\n";
144 echo "</SELECT></TT>\n";
145 if ($show_contain_subfolders_option) {
146 echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
147 echo _("Let this folder contain subfolders");
150 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
151 echo "</FORM></TD></TR>\n";
153 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
155 /** RENAMING FOLDERS **/
156 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
157 echo _("Rename a Folder");
158 echo "</B></TD></TR>";
159 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
160 if ($count_special_folders < count($boxes)) {
161 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
162 echo "<TT><SELECT NAME=old>\n";
163 for ($i = 0; $i < count($boxes); $i++
) {
166 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
167 ($boxes[$i]["unformatted"] != $trash_folder) &&
168 ($boxes[$i]["unformatted"] != $sent_folder))
170 $box = $boxes[$i]["unformatted-dm"];
171 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
172 if (strtolower($imap_server_type) != "courier" ||
strtolower($box) != "inbox.trash")
173 echo "<OPTION VALUE=\"$box\">$box2\n";
176 echo "</SELECT></TT>\n";
177 echo "<INPUT TYPE=SUBMIT VALUE=\"";
180 echo "</FORM></TD></TR>\n";
182 echo _("No folders found") . "<br><br></td></tr>";
186 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n";
188 /** UNSUBSCRIBE FOLDERS **/
189 echo "<TABLE WIDTH=70% COLS=2 ALIGN=CENTER cellpadding=2 cellspacing=1 border=0>\n";
190 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=2><B>";
191 echo _("Unsubscribe") . "/" . _("Subscribe");
192 echo "</B></TD></TR>\n";
193 echo "<TR><TD BGCOLOR=\"$color[0]\" width=50% ALIGN=CENTER>\n";
194 if ($count_special_folders < count($boxes)) {
195 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
196 echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n";
197 for ($i = 0; $i < count($boxes); $i++
) {
199 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
200 ($boxes[$i]["unformatted"] != $trash_folder) &&
201 ($boxes[$i]["unformatted"] != $sent_folder))
203 $box = $boxes[$i]["unformatted-dm"];
204 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
205 echo " <OPTION VALUE=\"$box\">$box2\n";
208 echo "</SELECT></TT><br>\n";
209 echo "<INPUT TYPE=SUBMIT VALUE=\"";
210 echo _("Unsubscribe");
212 echo "</FORM></TD>\n";
214 echo _("No folders were found to unsubscribe from!") . "</td>";
218 /** SUBSCRIBE TO FOLDERS **/
219 echo "<TD BGCOLOR=\"$color[0]\" width=50% ALIGN=CENTER>";
220 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
221 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
225 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
227 for ($p = 0; $p < count ($boxes); $p++
) {
228 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
231 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
235 if ($use_folder == true) {
236 $box[$q] = $boxes_all[$i]["unformatted-dm"];
237 $box2[$q] = $boxes_all[$i]["unformatted-disp"];
241 sqimap_logout($imap_stream);
244 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
245 echo "<tt><select name=mailbox[] multiple size=8>";
247 for ($q = 0; $q < count($box); $q++
) {
248 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
250 echo "</select></tt><br>";
251 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
252 echo "</FORM></TD></TR></TABLE><BR>\n";
254 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
259 <?php
do_hook("folders_bottom"); ?
>
269 sqimap_logout($imapConnection);