6 * Copyright (c) 1999-2003 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 /* Path for SquirrelMail required files. */
17 define('SM_PATH','../');
19 /* SquirrelMail required files. */
20 require_once(SM_PATH
. 'include/validate.php');
21 require_once(SM_PATH
. 'functions/imap.php');
22 require_once(SM_PATH
. 'functions/plugin.php');
23 require_once(SM_PATH
. 'functions/html.php');
25 displayPageHeader($color, 'None');
27 /* get globals we may need */
29 $username = $_SESSION['username'];
30 $key = $_COOKIE['key'];
31 $delimiter = $_SESSION['delimiter'];
32 $onetimepad = $_SESSION['onetimepad'];
33 if (isset($_GET['success'])) {
34 $success = $_GET['success'];
37 /* end of get globals */
40 html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) .
42 html_tag( 'td', '', 'center' ) . '<b>' . _("Folders") . '</b>' .
43 html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) .
45 html_tag( 'td', '', 'center', $color[4] );
47 if ( isset($success) && $success ) {
54 $td_str .= _("Subscribed successfully!");
57 $td_str .= _("Unsubscribed successfully!");
60 $td_str .= _("Deleted folder successfully!");
63 $td_str .= _("Created folder successfully!");
66 $td_str .= _("Renamed successfully!");
68 case 'subscribe-doesnotexist':
69 $td_str .= _("Subscription Unsuccessful - Folder does not exist.");
73 $td_str .= '</b><br>';
76 echo html_tag( 'table',
78 html_tag( 'td', $td_str .
79 '<a href="../src/left_main.php" target=left>' .
80 _("refresh folder list") . '</a>' ,
83 'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' );
88 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
89 $boxes = sqimap_mailbox_list($imapConnection);
91 /** CREATING FOLDERS **/
92 echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
94 html_tag( 'td', '<b>' . _("Create Folder") . '</b>', 'center', $color[9] )
97 html_tag( 'td', '', 'center', $color[0] ) .
99 "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n".
100 "<input type=TEXT SIZE=25 NAME=folder_name><BR>\n".
101 _("as a subfolder of").
103 "<TT><SELECT NAME=subfolder>\n";
107 $server_type = strtolower($imap_server_type);
108 if ( $server_type == 'courier' ) {
109 $show_selected = array('inbox');
110 $skip_folders = array('inbox.trash');
111 if ( $default_folder_prefix == 'INBOX.' ) {
112 array_push($skip_folders, 'inbox');
116 if ( $default_sub_of_inbox == false ) {
117 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
119 echo '<OPTION VALUE="">[ '._("None")." ]\n";
120 $show_selected = array('inbox');
123 echo sqimap_mailbox_option_list($imapConnection, $show_selected, $skip_folders, $boxes, 'noinferiors');
125 echo "</SELECT></TT>\n";
126 if ($show_contain_subfolders_option) {
127 echo '<br><input type=CHECKBOX NAME="contain_subs"> '
128 . _("Let this folder contain subfolders")
131 echo "<input type=SUBMIT VALUE=\""._("Create")."\">\n";
132 echo "</FORM></td></tr>\n";
135 html_tag( 'td', ' ', 'left', $color[4] )
138 /** count special folders **/
139 $count_special_folders = 0;
141 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash) {
147 if ($save_as_draft) {
150 for ($p = 0, $cnt = count($boxes); $p < $cnt && $count_special_folders < $num_max; $p++
) {
151 if (strtolower($boxes[$p]['unformatted']) == 'inbox')
152 $count_special_folders++
;
153 else if (strtolower($imap_server_type) == 'courier' &&
154 strtolower($boxes[$p]['unformatted']) == 'inbox.trash')
155 $count_special_folders++
;
156 else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
157 $count_special_folders++
;
158 else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
159 $count_special_folders++
;
160 else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
161 $count_special_folders++
;
165 /** RENAMING FOLDERS **/
167 html_tag( 'td', '<b>' . _("Rename a Folder") . '</b>', 'center', $color[9] )
170 html_tag( 'td', '', 'center', $color[0] );
172 if ($count_special_folders < count($boxes)) {
173 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"
174 . "<TT><SELECT NAME=old>\n"
175 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
177 echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes);
179 echo "</SELECT></TT>\n".
180 "<input type=SUBMIT VALUE=\"".
183 "</FORM></td></tr>\n";
185 echo _("No folders found") . '<br><br></td></tr>';
190 html_tag( 'td', ' ', 'left', $color[4] )
193 /** DELETING FOLDERS **/
195 html_tag( 'td', '<b>' . _("Delete Folder") . '</b>', 'center', $color[9] )
198 html_tag( 'td', '', 'center', $color[0] );
200 if ($count_special_folders < count($boxes)) {
201 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"
202 . "<TT><SELECT NAME=mailbox>\n"
203 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
205 echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes);
207 echo "</SELECT></TT>\n"
208 . '<input type=SUBMIT VALUE="'
211 . "</form></td></tr>\n";
213 echo _("No folders found") . "<br><br></td></tr>";
217 html_tag( 'td', ' ', 'left', $color[4] )
221 /** UNSUBSCRIBE FOLDERS **/
222 echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
224 html_tag( 'td', '<b>' . _("Unsubscribe") . '/' . _("Subscribe") . '</b>', 'center', $color[9], 'colspan="2"' )
227 html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
229 if ($count_special_folders < count($boxes)) {
230 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"
231 . "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
232 for ($i = 0; $i < count($boxes); $i++
) {
234 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
235 ($boxes[$i]["unformatted"] != $trash_folder) &&
236 ($boxes[$i]["unformatted"] != $sent_folder) &&
237 ($boxes[$i]["unformatted"] != $draft_folder)) {
238 $box = $boxes[$i]["unformatted-dm"];
239 $box2 = str_replace(' ', ' ',
240 imap_utf7_decode_local($boxes[$i]["unformatted-disp"]));
241 echo " <OPTION VALUE=\"$box\">$box2\n";
244 echo "</SELECT></TT><br><br>\n"
245 . '<input type=SUBMIT VALUE="'
250 echo _("No folders were found to unsubscribe from!") . '</td>';
254 /** SUBSCRIBE TO FOLDERS **/
255 echo html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
256 if(!$no_list_for_subscribe) {
257 $boxes_all = sqimap_mailbox_list_all ($imapConnection);
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] = imap_utf7_decode_local($boxes_all[$i]['unformatted-disp']);
278 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
279 . '<tt><select name="mailbox[]" multiple size=8>';
281 for ($q = 0; $q < count($box); $q++
) {
282 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
284 echo '</select></tt><br><br>'
285 . '<input type=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
286 . "</FORM></td></tr></table><BR>\n";
288 echo _("No folders were found to subscribe to!") . '</td></tr></table>';
291 /* don't perform the list action -- this is much faster */
292 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
293 . _("Subscribe to:") . '<br>'
294 . '<tt><input type="text" name="mailbox[]" size=35>'
295 . '<INPUT TYPE=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
296 . "</FORM></TD></TR></TABLE><BR>\n";
299 do_hook('folders_bottom');
309 sqimap_logout($imapConnection);