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 /* 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_utf7_decode_local.php');
22 require_once(SM_PATH
. 'functions/imap.php');
23 require_once(SM_PATH
. 'functions/array.php');
24 require_once(SM_PATH
. 'functions/plugin.php');
25 require_once(SM_PATH
. 'functions/html.php');
27 displayPageHeader($color, 'None');
29 /* get globals we may need */
31 $username = $_SESSION['username'];
32 $key = $_COOKIE['key'];
33 $delimiter = $_SESSION['delimiter'];
34 $onetimepad = $_SESSION['onetimepad'];
35 if (isset($_GET['success'])) {
36 $success = $_GET['success'];
39 /* end of get globals */
42 html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) .
44 html_tag( 'td', '', 'center' ) . '<b>' . _("Folders") . '</b>' .
45 html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) .
47 html_tag( 'td', '', 'center', $color[4] );
49 if ( isset($success) && $success ) {
56 $td_str .= _("Subscribed successfully!");
59 $td_str .= _("Unsubscribed successfully!");
62 $td_str .= _("Deleted folder successfully!");
65 $td_str .= _("Created folder successfully!");
68 $td_str .= _("Renamed successfully!");
70 case 'subscribe-doesnotexist':
71 $td_str .= _("Subscription Unsuccessful - Folder does not exist.");
75 $td_str .= '</b><br>';
78 echo html_tag( 'table',
80 html_tag( 'td', $td_str .
81 '<a href="../src/left_main.php" target=left>' .
82 _("refresh folder list") . '</a>' ,
85 'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' );
90 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
91 $boxes = sqimap_mailbox_list($imapConnection);
93 /** CREATING FOLDERS **/
94 echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
96 html_tag( 'td', '<b>' . _("Create Folder") . '</b>', 'center', $color[9] )
99 html_tag( 'td', '', 'center', $color[0] ) .
101 "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n".
102 "<input type=TEXT SIZE=25 NAME=folder_name><BR>\n".
103 _("as a subfolder of").
105 "<TT><SELECT NAME=subfolder>\n";
106 if ($default_sub_of_inbox == false) {
107 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
109 echo '<OPTION VALUE="">[ '._("None")." ]\n";
113 if ( $default_sub_of_inbox ) {
114 $show_selected = array('inbox');
117 if ( strtolower($imap_server_type) == 'courier' ) {
118 $skip_folders = array('inbox.trash');
121 echo sqimap_mailbox_option_list($imapConnection, $show_selected, $skip_folders, $boxes, 'noinferiors');
123 echo "</SELECT></TT>\n";
124 if ($show_contain_subfolders_option) {
125 echo '<br><input type=CHECKBOX NAME="contain_subs"> '
126 . _("Let this folder contain subfolders")
129 echo "<input type=SUBMIT VALUE=\""._("Create")."\">\n";
130 echo "</FORM></td></tr>\n";
133 html_tag( 'td', ' ', 'left', $color[4] )
136 /** count special folders **/
137 $count_special_folders = 0;
139 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash) {
145 if ($save_as_draft) {
148 for ($p = 0, $cnt = count($boxes); $p < $cnt && $count_special_folders < $num_max; $p++
) {
149 if (strtolower($boxes[$p]['unformatted']) == 'inbox')
150 $count_special_folders++
;
151 else if (strtolower($imap_server_type) == 'courier' &&
152 strtolower($boxes[$p]['unformatted']) == 'inbox.trash')
153 $count_special_folders++
;
154 else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
155 $count_special_folders++
;
156 else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
157 $count_special_folders++
;
158 else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
159 $count_special_folders++
;
163 /** RENAMING FOLDERS **/
165 html_tag( 'td', '<b>' . _("Rename a Folder") . '</b>', 'center', $color[9] )
168 html_tag( 'td', '', 'center', $color[0] );
170 if ($count_special_folders < count($boxes)) {
171 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"
172 . "<TT><SELECT NAME=old>\n"
173 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
175 echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes);
177 echo "</SELECT></TT>\n".
178 "<input type=SUBMIT VALUE=\"".
181 "</FORM></td></tr>\n";
183 echo _("No folders found") . '<br><br></td></tr>';
188 html_tag( 'td', ' ', 'left', $color[4] )
191 /** DELETING FOLDERS **/
193 html_tag( 'td', '<b>' . _("Delete Folder") . '</b>', 'center', $color[9] )
196 html_tag( 'td', '', 'center', $color[0] );
198 if ($count_special_folders < count($boxes)) {
199 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"
200 . "<TT><SELECT NAME=mailbox>\n"
201 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
203 echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes);
205 echo "</SELECT></TT>\n"
206 . '<input type=SUBMIT VALUE="'
209 . "</form></td></tr>\n";
211 echo _("No folders found") . "<br><br></td></tr>";
215 html_tag( 'td', ' ', 'left', $color[4] )
219 /** UNSUBSCRIBE FOLDERS **/
220 echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
222 html_tag( 'td', '<b>' . _("Unsubscribe") . '/' . _("Subscribe") . '</b>', 'center', $color[9], 'colspan="2"' )
225 html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
227 if ($count_special_folders < count($boxes)) {
228 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"
229 . "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
230 for ($i = 0; $i < count($boxes); $i++
) {
232 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
233 ($boxes[$i]["unformatted"] != $trash_folder) &&
234 ($boxes[$i]["unformatted"] != $sent_folder) &&
235 ($boxes[$i]["unformatted"] != $draft_folder)) {
236 $box = $boxes[$i]["unformatted-dm"];
237 $box2 = str_replace(' ', ' ',
238 imap_utf7_decode_local($boxes[$i]["unformatted-disp"]));
239 echo " <OPTION VALUE=\"$box\">$box2\n";
242 echo "</SELECT></TT><br><br>\n"
243 . '<input type=SUBMIT VALUE="'
248 echo _("No folders were found to unsubscribe from!") . '</td>';
252 /** SUBSCRIBE TO FOLDERS **/
253 echo html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
254 if(!$no_list_for_subscribe) {
255 $boxes_all = sqimap_mailbox_list_all ($imapConnection);
259 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
261 for ($p = 0; $p < count ($boxes); $p++
) {
262 if ($boxes_all[$i]['unformatted'] == $boxes[$p]['unformatted']) {
265 } else if ($boxes_all[$i]['unformatted-dm'] == $folder_prefix) {
269 if ($use_folder == true) {
270 $box[$q] = $boxes_all[$i]['unformatted-dm'];
271 $box2[$q] = imap_utf7_decode_local($boxes_all[$i]['unformatted-disp']);
276 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
277 . '<tt><select name="mailbox[]" multiple size=8>';
279 for ($q = 0; $q < count($box); $q++
) {
280 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
282 echo '</select></tt><br><br>'
283 . '<input type=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
284 . "</FORM></td></tr></table><BR>\n";
286 echo _("No folders were found to subscribe to!") . '</td></tr></table>';
289 /* don't perform the list action -- this is much faster */
290 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
291 . _("Subscribe to:") . '<br>'
292 . '<tt><input type="text" name="mailbox[]" size=35>'
293 . '<INPUT TYPE=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
294 . "</FORM></TD></TR></TABLE><BR>\n";
297 do_hook('folders_bottom');
307 sqimap_logout($imapConnection);