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/plugin.php');
24 require_once(SM_PATH
. 'functions/html.php');
26 displayPageHeader($color, 'None');
28 /* get globals we may need */
30 $username = $_SESSION['username'];
31 $key = $_COOKIE['key'];
32 $delimiter = $_SESSION['delimiter'];
33 $onetimepad = $_SESSION['onetimepad'];
34 if (isset($_GET['success'])) {
35 $success = $_GET['success'];
38 /* end of get globals */
41 html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) .
43 html_tag( 'td', '', 'center' ) . '<b>' . _("Folders") . '</b>' .
44 html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) .
46 html_tag( 'td', '', 'center', $color[4] );
48 if ( isset($success) && $success ) {
55 $td_str .= _("Subscribed successfully!");
58 $td_str .= _("Unsubscribed successfully!");
61 $td_str .= _("Deleted folder successfully!");
64 $td_str .= _("Created folder successfully!");
67 $td_str .= _("Renamed successfully!");
69 case 'subscribe-doesnotexist':
70 $td_str .= _("Subscription Unsuccessful - Folder does not exist.");
74 $td_str .= '</b><br>';
77 echo html_tag( 'table',
79 html_tag( 'td', $td_str .
80 '<a href="../src/left_main.php" target=left>' .
81 _("refresh folder list") . '</a>' ,
84 'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' );
89 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
90 $boxes = sqimap_mailbox_list($imapConnection);
92 /** CREATING FOLDERS **/
93 echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
95 html_tag( 'td', '<b>' . _("Create Folder") . '</b>', 'center', $color[9] )
98 html_tag( 'td', '', 'center', $color[0] ) .
100 "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n".
101 "<input type=TEXT SIZE=25 NAME=folder_name><BR>\n".
102 _("as a subfolder of").
104 "<TT><SELECT NAME=subfolder>\n";
105 if ($default_sub_of_inbox == false) {
106 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
108 echo '<OPTION VALUE="">[ '._("None")." ]\n";
112 if ( $default_sub_of_inbox ) {
113 $show_selected = array('inbox');
116 if ( strtolower($imap_server_type) == 'courier' ) {
117 $skip_folders = array('inbox.trash');
120 echo sqimap_mailbox_option_list($imapConnection, $show_selected, $skip_folders, $boxes, 'noinferiors');
122 echo "</SELECT></TT>\n";
123 if ($show_contain_subfolders_option) {
124 echo '<br><input type=CHECKBOX NAME="contain_subs"> '
125 . _("Let this folder contain subfolders")
128 echo "<input type=SUBMIT VALUE=\""._("Create")."\">\n";
129 echo "</FORM></td></tr>\n";
132 html_tag( 'td', ' ', 'left', $color[4] )
135 /** count special folders **/
136 $count_special_folders = 0;
138 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash) {
144 if ($save_as_draft) {
147 for ($p = 0, $cnt = count($boxes); $p < $cnt && $count_special_folders < $num_max; $p++
) {
148 if (strtolower($boxes[$p]['unformatted']) == 'inbox')
149 $count_special_folders++
;
150 else if (strtolower($imap_server_type) == 'courier' &&
151 strtolower($boxes[$p]['unformatted']) == 'inbox.trash')
152 $count_special_folders++
;
153 else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
154 $count_special_folders++
;
155 else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
156 $count_special_folders++
;
157 else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
158 $count_special_folders++
;
162 /** RENAMING FOLDERS **/
164 html_tag( 'td', '<b>' . _("Rename a Folder") . '</b>', 'center', $color[9] )
167 html_tag( 'td', '', 'center', $color[0] );
169 if ($count_special_folders < count($boxes)) {
170 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"
171 . "<TT><SELECT NAME=old>\n"
172 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
174 echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes);
176 echo "</SELECT></TT>\n".
177 "<input type=SUBMIT VALUE=\"".
180 "</FORM></td></tr>\n";
182 echo _("No folders found") . '<br><br></td></tr>';
187 html_tag( 'td', ' ', 'left', $color[4] )
190 /** DELETING FOLDERS **/
192 html_tag( 'td', '<b>' . _("Delete Folder") . '</b>', 'center', $color[9] )
195 html_tag( 'td', '', 'center', $color[0] );
197 if ($count_special_folders < count($boxes)) {
198 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"
199 . "<TT><SELECT NAME=mailbox>\n"
200 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
202 echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes);
204 echo "</SELECT></TT>\n"
205 . '<input type=SUBMIT VALUE="'
208 . "</form></td></tr>\n";
210 echo _("No folders found") . "<br><br></td></tr>";
214 html_tag( 'td', ' ', 'left', $color[4] )
218 /** UNSUBSCRIBE FOLDERS **/
219 echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
221 html_tag( 'td', '<b>' . _("Unsubscribe") . '/' . _("Subscribe") . '</b>', 'center', $color[9], 'colspan="2"' )
224 html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
226 if ($count_special_folders < count($boxes)) {
227 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"
228 . "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
229 for ($i = 0; $i < count($boxes); $i++
) {
231 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
232 ($boxes[$i]["unformatted"] != $trash_folder) &&
233 ($boxes[$i]["unformatted"] != $sent_folder) &&
234 ($boxes[$i]["unformatted"] != $draft_folder)) {
235 $box = $boxes[$i]["unformatted-dm"];
236 $box2 = str_replace(' ', ' ',
237 imap_utf7_decode_local($boxes[$i]["unformatted-disp"]));
238 echo " <OPTION VALUE=\"$box\">$box2\n";
241 echo "</SELECT></TT><br><br>\n"
242 . '<input type=SUBMIT VALUE="'
247 echo _("No folders were found to unsubscribe from!") . '</td>';
251 /** SUBSCRIBE TO FOLDERS **/
252 echo html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
253 if(!$no_list_for_subscribe) {
254 $boxes_all = sqimap_mailbox_list_all ($imapConnection);
258 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
260 for ($p = 0; $p < count ($boxes); $p++
) {
261 if ($boxes_all[$i]['unformatted'] == $boxes[$p]['unformatted']) {
264 } else if ($boxes_all[$i]['unformatted-dm'] == $folder_prefix) {
268 if ($use_folder == true) {
269 $box[$q] = $boxes_all[$i]['unformatted-dm'];
270 $box2[$q] = imap_utf7_decode_local($boxes_all[$i]['unformatted-disp']);
275 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
276 . '<tt><select name="mailbox[]" multiple size=8>';
278 for ($q = 0; $q < count($box); $q++
) {
279 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
281 echo '</select></tt><br><br>'
282 . '<input type=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
283 . "</FORM></td></tr></table><BR>\n";
285 echo _("No folders were found to subscribe to!") . '</td></tr></table>';
288 /* don't perform the list action -- this is much faster */
289 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
290 . _("Subscribe to:") . '<br>'
291 . '<tt><input type="text" name="mailbox[]" size=35>'
292 . '<INPUT TYPE=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
293 . "</FORM></TD></TR></TABLE><BR>\n";
296 do_hook('folders_bottom');
306 sqimap_logout($imapConnection);