6 * Copyright (c) 1999-2002 The SquirrelMail Project 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_utf7_decode_local.php');
18 require_once('../functions/imap.php');
19 require_once('../functions/array.php');
20 require_once('../functions/plugin.php');
21 require_once('../functions/html.php');
23 displayPageHeader($color, 'None');
28 <table bgcolor
="<?php echo $color[0] ?>" width
="95%" align
="center" cellpadding
="2" cellspacing
="0" border
="0">
29 <tr
><td align
="center">
31 <b
><?php
echo _("Folders"); ?
></b
>
33 <table width
="100%" border
="0" cellpadding
="5" cellspacing
="0">
34 <tr
><td bgcolor
="<?php echo $color[4] ?>" align
="center">
38 if ((isset($success) && $success) ||
39 (isset($sent_create) && $sent_create == 'true') ||
40 (isset($trash_create) && $trash_create == 'true')) {
41 if ($success == "subscribe") {
42 $td_str = "<b>" . _("Subscribed successfully!") . "</b><br>";
43 } else if ($success == "unsubscribe") {
44 $td_str = "<b>" . _("Unsubscribed successfully!") . "</b><br>";
45 } else if ($success == "delete") {
46 $td_str = "<b>" . _("Deleted folder successfully!") . "</b><br>";
47 } else if ($success == "create") {
48 $td_str = "<b>" . _("Created folder successfully!") . "</b><br>";
49 } else if ($success == "rename") {
50 $td_str = "<b>" . _("Renamed successfully!") . "</b><br>";
53 echo html_tag( 'table',
55 html_tag( 'td', $td_str .
56 "<a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>" ,
59 'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' ) . "<br>\n";
63 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
64 $boxes = sqimap_mailbox_list($imapConnection);
66 /** CREATING FOLDERS **/
67 echo html_tag( 'table', '', 'center', '', 'width="70%" cols="1" cellpadding="4" cellspacing="0" border="0"' ) .
69 html_tag( 'td', '<b>' . _("Create Folder") . '</b>', 'center', $color[9] )
72 html_tag( 'td', '', 'center', $color[0] ) .
74 "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n".
75 "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n".
76 _("as a subfolder of").
78 "<TT><SELECT NAME=subfolder>\n";
79 if ($default_sub_of_inbox == false) {
80 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
82 echo '<OPTION VALUE="">[ '._("None")." ]\n";
85 for ($i = 0; $i < count($boxes); $i++
) {
86 if (!in_array('noinferiors', $boxes[$i]['flags'])) {
87 if ((strtolower($boxes[$i]['unformatted']) == 'inbox') &&
88 $default_sub_of_inbox) {
90 $box = $boxes[$i]['unformatted'];
91 $box2 = str_replace(' ', ' ',
92 imap_utf7_decode_local($boxes[$i]['unformatted-disp']));
93 echo "<OPTION SELECTED VALUE=\"$box\">$box2</option>\n";
95 $box = $boxes[$i]['unformatted'];
96 $box2 = str_replace(' ', ' ',
97 imap_utf7_decode_local($boxes[$i]['unformatted-disp']));
98 if (strtolower($imap_server_type) != 'courier' ||
99 strtolower($box) != "inbox.trash")
100 echo "<OPTION VALUE=\"$box\">$box2</option>\n";
104 echo "</SELECT></TT>\n";
105 if ($show_contain_subfolders_option) {
106 echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
107 echo _("Let this folder contain subfolders");
110 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
111 echo "</FORM></TD></TR>\n";
114 html_tag( 'td', ' ', 'left', $color[4] )
117 /** count special folders **/
118 $count_special_folders = 0;
120 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash) {
126 if ($save_as_draft) {
129 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
130 if (strtolower($boxes[$p]['unformatted']) == 'inbox')
131 $count_special_folders++
;
132 else if (strtolower($imap_server_type) == 'courier' &&
133 strtolower($boxes[$p]['unformatted']) == 'inbox.trash')
134 $count_special_folders++
;
135 else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
136 $count_special_folders++
;
137 else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
138 $count_special_folders++
;
139 else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
140 $count_special_folders++
;
144 /** RENAMING FOLDERS **/
146 html_tag( 'td', '<b>' . _("Rename a Folder") . '</b>', 'center', $color[9] )
149 html_tag( 'td', '', 'center', $color[0] );
151 if ($count_special_folders < count($boxes)) {
152 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"
153 . "<TT><SELECT NAME=old>\n"
154 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
155 for ($i = 0; $i < count($boxes); $i++
) {
158 if ((strtolower($boxes[$i]['unformatted']) != 'inbox') &&
159 ($boxes[$i]['unformatted'] != $trash_folder) &&
160 ($boxes[$i]['unformatted'] != $sent_folder) &&
161 ($boxes[$i]['unformatted'] != $draft_folder)) {
162 $box = $boxes[$i]['unformatted-dm'];
164 $box2 = str_replace(' ', ' ',
165 imap_utf7_decode_local($boxes[$i]['unformatted-disp']));
166 if (strtolower($imap_server_type) != 'courier' ||
strtolower($box) != 'inbox.trash') {
167 echo "<OPTION VALUE=\"$box\">$box2</option>\n";
171 echo "</SELECT></TT>\n".
172 "<INPUT TYPE=SUBMIT VALUE=\"".
175 "</FORM></td></tr>\n";
177 echo _("No folders found") . "<br><br></td></tr>";
182 html_tag( 'td', ' ', 'left', $color[4] )
185 /** DELETING FOLDERS **/
187 html_tag( 'td', '<b>' . _("Delete Folder") . '</b>', 'center', $color[9] )
190 html_tag( 'td', '', 'center', $color[0] );
192 if ($count_special_folders < count($boxes)) {
193 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"
194 . "<TT><SELECT NAME=mailbox>\n"
195 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
196 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) &&
201 ($boxes[$i]['unformatted'] != $draft_folder) &&
202 (!in_array('noselect', $boxes[$i]['flags'])) &&
203 ((strtolower($imap_server_type) != 'courier') ||
204 (strtolower($boxes[$i]['unformatted']) != 'inbox.trash'))) {
205 $box = $boxes[$i]['unformatted-dm'];
206 $box2 = str_replace(' ', ' ',
207 imap_utf7_decode_local($boxes[$i]['unformatted-disp']));
208 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
211 echo "</SELECT></TT>\n";
212 echo "<INPUT TYPE=SUBMIT VALUE=\"";
215 echo "</FORM></TD></TR>\n";
217 echo _("No folders found") . "<br><br></td><tr>";
221 html_tag( 'td', ' ', 'left', $color[4] )
225 /** UNSUBSCRIBE FOLDERS **/
226 echo html_tag( 'table', '', 'center', '', 'width="70%" cols="2" cellpadding="4" cellspacing="0" border="0"' ) .
228 html_tag( 'td', '<b>' . _("Unsubscribe") . '/' . _("Subscribe") . '</b>', 'center', $color[9], 'colspan="2"' )
231 html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
233 if ($count_special_folders < count($boxes)) {
234 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
235 echo "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
236 for ($i = 0; $i < count($boxes); $i++
) {
238 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
239 ($boxes[$i]["unformatted"] != $trash_folder) &&
240 ($boxes[$i]["unformatted"] != $sent_folder) &&
241 ($boxes[$i]["unformatted"] != $draft_folder)) {
242 $box = $boxes[$i]["unformatted-dm"];
243 $box2 = str_replace(' ', ' ',
244 imap_utf7_decode_local($boxes[$i]["unformatted-disp"]));
245 echo " <OPTION VALUE=\"$box\">$box2\n";
248 echo "</SELECT></TT><br><br>\n";
249 echo "<INPUT TYPE=SUBMIT VALUE=\"";
250 echo _("Unsubscribe");
252 echo "</FORM></td>\n";
254 echo _("No folders were found to unsubscribe from!") . "</td>";
258 /** SUBSCRIBE TO FOLDERS **/
259 echo html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
260 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
261 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
265 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
267 for ($p = 0; $p < count ($boxes); $p++
) {
268 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
271 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
275 if ($use_folder == true) {
276 $box[$q] = $boxes_all[$i]["unformatted-dm"];
277 $box2[$q] = imap_utf7_decode_local($boxes_all[$i]["unformatted-disp"]);
281 sqimap_logout($imap_stream);
284 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
285 echo "<tt><select name=\"mailbox[]\" multiple size=8>";
287 for ($q = 0; $q < count($box); $q++
) {
288 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
290 echo "</select></tt><br><br>";
291 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
292 echo "</FORM></td></tr></table><BR>\n";
294 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
297 do_hook("folders_bottom");
308 sqimap_logout($imapConnection);