6 ** Copyright (c) 1999-2001 The SquirrelMail development team
7 ** Licensed under the GNU GPL. For full terms see the file COPYING.
9 ** Handles all interaction between the user and the other folder
10 ** scripts which do most of the work. Also handles the Special
16 require_once('../src/validate.php');
17 require_once('../functions/imap.php');
18 require_once('../functions/array.php');
19 require_once('../functions/plugin.php');
21 displayPageHeader($color, 'None');
26 <table bgcolor
="<?php echo $color[0] ?>" width
="95%" align
="center" cellpadding
="2" cellspacing
="0" border
="0">
27 <tr
><td align
="center">
29 <b
><?php
echo _("Folders"); ?
></b
>
31 <table width
="100%" border
="0" cellpadding
="5" cellspacing
="0">
32 <tr
><td bgcolor
="<?php echo $color[4] ?>" align
="center">
36 if ((isset($success) && $success) ||
37 (isset($sent_create) && $sent_create == "true") ||
38 (isset($trash_create) && $trash_create == "true")) {
39 echo "<table width=100% align=center cellpadding=2 cellspacing=0 border=0>\n";
40 echo " <tr><td align=center>\n";
41 if ($success == "subscribe") {
42 echo "<b>" . _("Subscribed successfully!") . "</b><br>";
43 } else if ($success == "unsubscribe") {
44 echo "<b>" . _("Unsubscribed successfully!") . "</b><br>";
45 } else if ($success == "delete") {
46 echo "<b>" . _("Deleted folder successfully!") . "</b><br>";
47 } else if ($success == "create") {
48 echo "<b>" . _("Created folder successfully!") . "</b><br>";
49 } else if ($success == "rename") {
50 echo "<b>" . _("Renamed successfully!") . "</b><br>";
53 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>";
55 echo "</table><br>\n";
57 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
58 $boxes = sqimap_mailbox_list($imapConnection);
60 /** DELETING FOLDERS **/
61 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n";
62 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
63 echo _("Delete Folder");
64 echo "</B></TD></TR>";
65 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
67 $count_special_folders = 0;
69 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash)
74 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
75 if (strtolower($boxes[$p]["unformatted"]) == "inbox")
76 $count_special_folders++
;
77 else if (strtolower($imap_server_type) == "courier" &&
78 strtolower($boxes[$p]["unformatted"]) == "inbox.trash")
79 $count_special_folders++
;
80 else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
81 $count_special_folders++
;
82 else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
83 $count_special_folders++
;
86 if ($count_special_folders < count($boxes)) {
87 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
88 echo "<TT><SELECT NAME=mailbox>\n";
89 for ($i = 0; $i < count($boxes); $i++
) {
91 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
92 ($boxes[$i]["unformatted"] != $trash_folder) &&
93 ($boxes[$i]["unformatted"] != $sent_folder) &&
94 (strtolower($imap_server_type) != "courier" ||
95 strtolower($boxes[$i]["unformatted"]) != "inbox.trash"))
97 $box = $boxes[$i]["unformatted-dm"];
98 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
99 echo " <OPTION VALUE=\"$box\">$box2\n";
102 echo "</SELECT></TT>\n";
103 echo "<INPUT TYPE=SUBMIT VALUE=\"";
106 echo "</FORM></TD></TR>\n";
108 echo _("No folders found") . "<br><br></td><tr>";
111 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
113 /** CREATING FOLDERS **/
114 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
115 echo _("Create Folder");
116 echo "</B></TD></TR>";
117 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
118 echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
119 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
120 echo _("as a subfolder of");
122 echo "<TT><SELECT NAME=subfolder>\n";
123 if (strtolower($imap_server_type) != "courier"){
124 if ($default_sub_of_inbox == false)
125 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
127 echo '<OPTION VALUE="">[ '._("None")." ]\n";
130 for ($i = 0; $i < count($boxes); $i++
) {
131 if (!in_array('noinferiors', $boxes[$i]['flags'])) {
132 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
133 $box = $boxes[$i]["unformatted"];
134 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
135 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
137 $box = $boxes[$i]["unformatted"];
138 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
139 if (strtolower($imap_server_type) != "courier" ||
140 strtolower($box) != "inbox.trash")
141 echo "<OPTION VALUE=\"$box\">$box2\n";
145 echo "</SELECT></TT>\n";
146 if ($show_contain_subfolders_option) {
147 echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
148 echo _("Let this folder contain subfolders");
151 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
152 echo "</FORM></TD></TR>\n";
154 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
156 /** RENAMING FOLDERS **/
157 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
158 echo _("Rename a Folder");
159 echo "</B></TD></TR>";
160 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
161 if ($count_special_folders < count($boxes)) {
162 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
163 echo "<TT><SELECT NAME=old>\n";
164 for ($i = 0; $i < count($boxes); $i++
) {
167 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
168 ($boxes[$i]["unformatted"] != $trash_folder) &&
169 ($boxes[$i]["unformatted"] != $sent_folder))
171 $box = $boxes[$i]["unformatted-dm"];
172 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
173 if (strtolower($imap_server_type) != "courier" ||
strtolower($box) != "inbox.trash")
174 echo "<OPTION VALUE=\"$box\">$box2\n";
177 echo "</SELECT></TT>\n";
178 echo "<INPUT TYPE=SUBMIT VALUE=\"";
181 echo "</FORM></TD></TR>\n";
183 echo _("No folders found") . "<br><br></td></tr>";
187 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n";
189 /** UNSUBSCRIBE FOLDERS **/
190 echo "<TABLE WIDTH=70% COLS=2 ALIGN=CENTER cellpadding=2 cellspacing=1 border=0>\n";
191 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=2><B>";
192 echo _("Unsubscribe") . "/" . _("Subscribe");
193 echo "</B></TD></TR>\n";
194 echo "<TR><TD BGCOLOR=\"$color[0]\" width=50% ALIGN=CENTER>\n";
195 if ($count_special_folders < count($boxes)) {
196 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
197 echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n";
198 for ($i = 0; $i < count($boxes); $i++
) {
200 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
201 ($boxes[$i]["unformatted"] != $trash_folder) &&
202 ($boxes[$i]["unformatted"] != $sent_folder))
204 $box = $boxes[$i]["unformatted-dm"];
205 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
206 echo " <OPTION VALUE=\"$box\">$box2\n";
209 echo "</SELECT></TT><br>\n";
210 echo "<INPUT TYPE=SUBMIT VALUE=\"";
211 echo _("Unsubscribe");
213 echo "</FORM></TD>\n";
215 echo _("No folders were found to unsubscribe from!") . "</td>";
219 /** SUBSCRIBE TO FOLDERS **/
220 echo "<TD BGCOLOR=\"$color[0]\" width=50% ALIGN=CENTER>";
221 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
222 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
226 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
228 for ($p = 0; $p < count ($boxes); $p++
) {
229 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
232 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
236 if ($use_folder == true) {
237 $box[$q] = $boxes_all[$i]["unformatted-dm"];
238 $box2[$q] = $boxes_all[$i]["unformatted-disp"];
242 sqimap_logout($imap_stream);
245 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
246 echo "<tt><select name=mailbox[] multiple size=8>";
248 for ($q = 0; $q < count($box); $q++
) {
249 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
251 echo "</select></tt><br>";
252 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
253 echo "</FORM></TD></TR></TABLE><BR>\n";
255 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
260 <?php
do_hook("folders_bottom"); ?
>
270 sqimap_logout($imapConnection);