replace the hook for the subject line that Mr. Groot Koerkamp dropped.
[squirrelmail.git] / src / folders.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * folders.php
5 *
76911253 6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Handles all interaction between the user and the other folder
10 * scripts which do most of the work. Also handles the Special
11 * Folders.
12 *
13 * $Id$
14 */
15
86725763 16/* Path for SquirrelMail required files. */
17define('SM_PATH','../');
18
19/* SquirrelMail required files. */
08185f2a 20require_once(SM_PATH . 'include/validate.php');
86725763 21require_once(SM_PATH . 'functions/imap.php');
86725763 22require_once(SM_PATH . 'functions/plugin.php');
23require_once(SM_PATH . 'functions/html.php');
d3cdb279 24
e634431a 25displayPageHeader($color, 'None');
aa42fbfb 26
a32985a5 27/* get globals we may need */
28
f38b7cf0 29sqgetGlobalVar('username', $username, SQ_SESSION);
30sqgetGlobalVar('key', $key, SQ_COOKIE);
31sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
32sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
33
34sqgetGlobalVar('success', $success, SQ_GET);
a32985a5 35
36/* end of get globals */
37
2441907d 38echo '<br>' .
6206f6c4 39 html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) .
2441907d 40 html_tag( 'tr' ) .
41 html_tag( 'td', '', 'center' ) . '<b>' . _("Folders") . '</b>' .
42 html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) .
43 html_tag( 'tr' ) .
44 html_tag( 'td', '', 'center', $color[4] );
aa42fbfb 45
b7f83b61 46if ( isset($success) && $success ) {
47
48 $td_str = '<b>';
49
50 switch ($success)
51 {
52 case 'subscribe':
53 $td_str .= _("Subscribed successfully!");
54 break;
55 case 'unsubscribe':
56 $td_str .= _("Unsubscribed successfully!");
57 break;
58 case 'delete':
59 $td_str .= _("Deleted folder successfully!");
60 break;
61 case 'create':
62 $td_str .= _("Created folder successfully!");
63 break;
64 case 'rename':
65 $td_str .= _("Renamed successfully!");
66 break;
67 case 'subscribe-doesnotexist':
68 $td_str .= _("Subscription Unsuccessful - Folder does not exist.");
69 break;
e634431a 70 }
71
b7f83b61 72 $td_str .= '</b><br>';
73
74
50ed645b 75 echo html_tag( 'table',
76 html_tag( 'tr',
77 html_tag( 'td', $td_str .
b7f83b61 78 '<a href="../src/left_main.php" target=left>' .
79 _("refresh folder list") . '</a>' ,
50ed645b 80 'center' )
81 ) ,
b7f83b61 82 'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' );
e634431a 83}
b7f83b61 84
85echo "\n<br>";
86
e634431a 87$imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
88$boxes = sqimap_mailbox_list($imapConnection);
89
90/** CREATING FOLDERS **/
ac50138c 91echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
50ed645b 92 html_tag( 'tr',
93 html_tag( 'td', '<b>' . _("Create Folder") . '</b>', 'center', $color[9] )
94 ) .
95 html_tag( 'tr' ) .
96 html_tag( 'td', '', 'center', $color[0] ) .
97
1c52ba77 98 "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n".
6b4bd11f 99 "<input type=TEXT SIZE=25 NAME=folder_name><BR>\n".
1c52ba77 100 _("as a subfolder of").
b7f83b61 101 '<BR>'.
1c52ba77 102 "<TT><SELECT NAME=subfolder>\n";
7f0a2c23 103
104$show_selected=0;
105$skip_folders=0;
106$server_type = strtolower($imap_server_type);
107if ( $server_type == 'courier' ) {
108 $show_selected = array('inbox');
7c8b7b4f 109 $skip_folders = array('inbox.trash');
110 if ( $default_folder_prefix == 'INBOX.' ) {
111 array_push($skip_folders, 'inbox');
112 }
7f0a2c23 113}
114
115if ( $default_sub_of_inbox == false ) {
e634431a 116 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
117} else {
118 echo '<OPTION VALUE="">[ '._("None")." ]\n";
be2d5495 119 $show_selected = array('inbox');
120}
be2d5495 121
122echo sqimap_mailbox_option_list($imapConnection, $show_selected, $skip_folders, $boxes, 'noinferiors');
123
e634431a 124echo "</SELECT></TT>\n";
125if ($show_contain_subfolders_option) {
b7f83b61 126 echo '<br><input type=CHECKBOX NAME="contain_subs"> &nbsp;'
127 . _("Let this folder contain subfolders")
128 . '<BR>';
1c52ba77 129}
6b4bd11f 130echo "<input type=SUBMIT VALUE=\""._("Create")."\">\n";
131echo "</FORM></td></tr>\n";
e634431a 132
50ed645b 133echo html_tag( 'tr',
134 html_tag( 'td', '&nbsp;', 'left', $color[4] )
135 ) ."\n";
0037f048 136
137/** count special folders **/
138$count_special_folders = 0;
139$num_max = 1;
140if (strtolower($imap_server_type) == "courier" || $move_to_trash) {
141 $num_max++;
142}
143if ($move_to_sent) {
144 $num_max++;
145}
146if ($save_as_draft) {
147 $num_max++;
148}
336155db 149for ($p = 0, $cnt = count($boxes); $p < $cnt && $count_special_folders < $num_max; $p++) {
0037f048 150 if (strtolower($boxes[$p]['unformatted']) == 'inbox')
151 $count_special_folders++;
152 else if (strtolower($imap_server_type) == 'courier' &&
153 strtolower($boxes[$p]['unformatted']) == 'inbox.trash')
154 $count_special_folders++;
155 else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
156 $count_special_folders++;
157 else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
158 $count_special_folders++;
159 else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
160 $count_special_folders++;
161}
162
163
e634431a 164/** RENAMING FOLDERS **/
50ed645b 165echo html_tag( 'tr',
166 html_tag( 'td', '<b>' . _("Rename a Folder") . '</b>', 'center', $color[9] )
167 ) .
168 html_tag( 'tr' ) .
169 html_tag( 'td', '', 'center', $color[0] );
170
0037f048 171if ($count_special_folders < count($boxes)) {
172 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"
173 . "<TT><SELECT NAME=old>\n"
174 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
be2d5495 175
176 echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes);
177
1c52ba77 178 echo "</SELECT></TT>\n".
6b4bd11f 179 "<input type=SUBMIT VALUE=\"".
1c52ba77 180 _("Rename").
181 "\">\n".
50ed645b 182 "</FORM></td></tr>\n";
e634431a 183} else {
b7f83b61 184 echo _("No folders found") . '<br><br></td></tr>';
e634431a 185}
186$boxes_sub = $boxes;
187
50ed645b 188echo html_tag( 'tr',
189 html_tag( 'td', '&nbsp;', 'left', $color[4] )
190 ) ."\n";
e634431a 191
192/** DELETING FOLDERS **/
50ed645b 193echo html_tag( 'tr',
194 html_tag( 'td', '<b>' . _("Delete Folder") . '</b>', 'center', $color[9] )
195 ) .
196 html_tag( 'tr' ) .
197 html_tag( 'td', '', 'center', $color[0] );
e634431a 198
e634431a 199if ($count_special_folders < count($boxes)) {
0037f048 200 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"
201 . "<TT><SELECT NAME=mailbox>\n"
202 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
be2d5495 203
204 echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes);
205
b7f83b61 206 echo "</SELECT></TT>\n"
207 . '<input type=SUBMIT VALUE="'
208 . _("Delete")
209 . "\">\n"
210 . "</form></td></tr>\n";
e634431a 211} else {
6b4bd11f 212 echo _("No folders found") . "<br><br></td></tr>";
e634431a 213}
50ed645b 214
215echo html_tag( 'tr',
216 html_tag( 'td', '&nbsp;', 'left', $color[4] )
217 ) ."</table>\n";
218
e634431a 219
220/** UNSUBSCRIBE FOLDERS **/
12ff1cab 221echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
50ed645b 222 html_tag( 'tr',
223 html_tag( 'td', '<b>' . _("Unsubscribe") . '/' . _("Subscribe") . '</b>', 'center', $color[9], 'colspan="2"' )
224 ) .
225 html_tag( 'tr' ) .
226 html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
227
e634431a 228if ($count_special_folders < count($boxes)) {
b7f83b61 229 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"
230 . "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
e634431a 231 for ($i = 0; $i < count($boxes); $i++) {
232 $use_folder = true;
233 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
234 ($boxes[$i]["unformatted"] != $trash_folder) &&
235 ($boxes[$i]["unformatted"] != $sent_folder) &&
236 ($boxes[$i]["unformatted"] != $draft_folder)) {
237 $box = $boxes[$i]["unformatted-dm"];
46bc57c1 238 $box2 = str_replace(' ', '&nbsp;',
239 imap_utf7_decode_local($boxes[$i]["unformatted-disp"]));
e634431a 240 echo " <OPTION VALUE=\"$box\">$box2\n";
241 }
242 }
b7f83b61 243 echo "</SELECT></TT><br><br>\n"
244 . '<input type=SUBMIT VALUE="'
245 . _("Unsubscribe")
246 . "\">\n"
247 . "</FORM></td>\n";
e634431a 248} else {
b7f83b61 249 echo _("No folders were found to unsubscribe from!") . '</td>';
e634431a 250}
251$boxes_sub = $boxes;
252
253/** SUBSCRIBE TO FOLDERS **/
50ed645b 254echo html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
52ed2f88 255if(!$no_list_for_subscribe) {
336155db 256 $boxes_all = sqimap_mailbox_list_all ($imapConnection);
52ed2f88 257
b7f83b61 258 $box = '';
259 $box2 = '';
52ed2f88 260 for ($i = 0, $q = 0; $i < count($boxes_all); $i++) {
e634431a 261 $use_folder = true;
262 for ($p = 0; $p < count ($boxes); $p++) {
b7f83b61 263 if ($boxes_all[$i]['unformatted'] == $boxes[$p]['unformatted']) {
e634431a 264 $use_folder = false;
265 continue;
b7f83b61 266 } else if ($boxes_all[$i]['unformatted-dm'] == $folder_prefix) {
e634431a 267 $use_folder = false;
268 }
269 }
7e235a1a 270 if ($use_folder == true) {
b7f83b61 271 $box[$q] = $boxes_all[$i]['unformatted-dm'];
272 $box2[$q] = imap_utf7_decode_local($boxes_all[$i]['unformatted-disp']);
e634431a 273 $q++;
274 }
52ed2f88 275 }
52ed2f88 276 if ($box && $box2) {
b7f83b61 277 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
278 . '<tt><select name="mailbox[]" multiple size=8>';
e634431a 279
280 for ($q = 0; $q < count($box); $q++) {
281 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
282 }
b7f83b61 283 echo '</select></tt><br><br>'
284 . '<input type=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
285 . "</FORM></td></tr></table><BR>\n";
52ed2f88 286 } else {
b7f83b61 287 echo _("No folders were found to subscribe to!") . '</td></tr></table>';
52ed2f88 288 }
289} else {
290 /* don't perform the list action -- this is much faster */
b7f83b61 291 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
292 . _("Subscribe to:") . '<br>'
293 . '<tt><input type="text" name="mailbox[]" size=35>'
294 . '<INPUT TYPE=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
295 . "</FORM></TD></TR></TABLE><BR>\n";
e634431a 296}
e7db48af 297
b7f83b61 298do_hook('folders_bottom');
bd9bbfef 299?>
e7db48af 300
e7db48af 301 </td></tr>
302 </table>
303
304</td></tr>
305</table>
306
307<?php
1195c340 308 sqimap_logout($imapConnection);
aa42fbfb 309?>
e7db48af 310
0037f048 311</body></html>