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";
104 if ($default_sub_of_inbox == false) {
105 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
107 echo '<OPTION VALUE="">[ '._("None")." ]\n";
111 if ( $default_sub_of_inbox ) {
112 $show_selected = array('inbox');
115 if ( strtolower($imap_server_type) == 'courier' ) {
116 $skip_folders = array('inbox.trash');
119 echo sqimap_mailbox_option_list($imapConnection, $show_selected, $skip_folders, $boxes, 'noinferiors');
121 echo "</SELECT></TT>\n";
122 if ($show_contain_subfolders_option) {
123 echo '<br><input type=CHECKBOX NAME="contain_subs"> '
124 . _("Let this folder contain subfolders")
127 echo "<input type=SUBMIT VALUE=\""._("Create")."\">\n";
128 echo "</FORM></td></tr>\n";
131 html_tag( 'td', ' ', 'left', $color[4] )
134 /** count special folders **/
135 $count_special_folders = 0;
137 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash) {
143 if ($save_as_draft) {
146 for ($p = 0, $cnt = count($boxes); $p < $cnt && $count_special_folders < $num_max; $p++
) {
147 if (strtolower($boxes[$p]['unformatted']) == 'inbox')
148 $count_special_folders++
;
149 else if (strtolower($imap_server_type) == 'courier' &&
150 strtolower($boxes[$p]['unformatted']) == 'inbox.trash')
151 $count_special_folders++
;
152 else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
153 $count_special_folders++
;
154 else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
155 $count_special_folders++
;
156 else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
157 $count_special_folders++
;
161 /** RENAMING FOLDERS **/
163 html_tag( 'td', '<b>' . _("Rename a Folder") . '</b>', 'center', $color[9] )
166 html_tag( 'td', '', 'center', $color[0] );
168 if ($count_special_folders < count($boxes)) {
169 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"
170 . "<TT><SELECT NAME=old>\n"
171 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
173 echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes);
175 echo "</SELECT></TT>\n".
176 "<input type=SUBMIT VALUE=\"".
179 "</FORM></td></tr>\n";
181 echo _("No folders found") . '<br><br></td></tr>';
186 html_tag( 'td', ' ', 'left', $color[4] )
189 /** DELETING FOLDERS **/
191 html_tag( 'td', '<b>' . _("Delete Folder") . '</b>', 'center', $color[9] )
194 html_tag( 'td', '', 'center', $color[0] );
196 if ($count_special_folders < count($boxes)) {
197 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"
198 . "<TT><SELECT NAME=mailbox>\n"
199 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
201 echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes);
203 echo "</SELECT></TT>\n"
204 . '<input type=SUBMIT VALUE="'
207 . "</form></td></tr>\n";
209 echo _("No folders found") . "<br><br></td></tr>";
213 html_tag( 'td', ' ', 'left', $color[4] )
217 /** UNSUBSCRIBE FOLDERS **/
218 echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
220 html_tag( 'td', '<b>' . _("Unsubscribe") . '/' . _("Subscribe") . '</b>', 'center', $color[9], 'colspan="2"' )
223 html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
225 if ($count_special_folders < count($boxes)) {
226 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"
227 . "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
228 for ($i = 0; $i < count($boxes); $i++
) {
230 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
231 ($boxes[$i]["unformatted"] != $trash_folder) &&
232 ($boxes[$i]["unformatted"] != $sent_folder) &&
233 ($boxes[$i]["unformatted"] != $draft_folder)) {
234 $box = $boxes[$i]["unformatted-dm"];
235 $box2 = str_replace(' ', ' ',
236 imap_utf7_decode_local($boxes[$i]["unformatted-disp"]));
237 echo " <OPTION VALUE=\"$box\">$box2\n";
240 echo "</SELECT></TT><br><br>\n"
241 . '<input type=SUBMIT VALUE="'
246 echo _("No folders were found to unsubscribe from!") . '</td>';
250 /** SUBSCRIBE TO FOLDERS **/
251 echo html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
252 if(!$no_list_for_subscribe) {
253 $boxes_all = sqimap_mailbox_list_all ($imapConnection);
257 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
259 for ($p = 0; $p < count ($boxes); $p++
) {
260 if ($boxes_all[$i]['unformatted'] == $boxes[$p]['unformatted']) {
263 } else if ($boxes_all[$i]['unformatted-dm'] == $folder_prefix) {
267 if ($use_folder == true) {
268 $box[$q] = $boxes_all[$i]['unformatted-dm'];
269 $box2[$q] = imap_utf7_decode_local($boxes_all[$i]['unformatted-disp']);
274 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
275 . '<tt><select name="mailbox[]" multiple size=8>';
277 for ($q = 0; $q < count($box); $q++
) {
278 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
280 echo '</select></tt><br><br>'
281 . '<input type=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
282 . "</FORM></td></tr></table><BR>\n";
284 echo _("No folders were found to subscribe to!") . '</td></tr></table>';
287 /* don't perform the list action -- this is much faster */
288 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
289 . _("Subscribe to:") . '<br>'
290 . '<tt><input type="text" name="mailbox[]" size=35>'
291 . '<INPUT TYPE=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
292 . "</FORM></TD></TR></TABLE><BR>\n";
295 do_hook('folders_bottom');
305 sqimap_logout($imapConnection);