6
* Copyright (c) 1999-2003 The SquirrelMail Project Team
6
* Copyright (c) 1999-2005 The SquirrelMail Project Team
7
7
* Licensed under the GNU GPL. For full terms see the file COPYING.
9
9
* Handles all interaction between the user and the other folder
10
10
* scripts which do most of the work. Also handles the Special
13
* $Id: folders.php,v 1.121 2003/12/01 21:56:55 cigamit Exp $
13
* @version $Id: folders.php,v 1.112.2.10 2004/12/27 15:03:59 kink Exp $
14
14
* @package squirrelmail
17
/** Path for SquirrelMail required files. */
18
* Path for SquirrelMail required files.
18
21
define('SM_PATH','../');
20
23
/* SquirrelMail required files. */
22
25
require_once(SM_PATH . 'functions/imap.php');
23
26
require_once(SM_PATH . 'functions/plugin.php');
24
27
require_once(SM_PATH . 'functions/html.php');
28
require_once(SM_PATH . 'functions/forms.php');
26
30
displayPageHeader($color, 'None');
37
41
/* end of get globals */
40
44
html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) .
42
46
html_tag( 'td', '', 'center' ) . '<b>' . _("Folders") . '</b>' .
73
$td_str .= '</b><br>';
77
$td_str .= '</b><br />';
76
80
echo html_tag( 'table',
78
82
html_tag( 'td', $td_str .
79
'<a href="../src/left_main.php" target=left>' .
83
'<a href="../src/left_main.php" target="left">' .
80
84
_("refresh folder list") . '</a>' ,
83
87
'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' );
88
92
$imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
89
$boxes = sqimap_mailbox_list($imapConnection);
94
// force retrieval of a non cached folderlist
95
$boxes = sqimap_mailbox_list($imapConnection,true);
91
97
/** CREATING FOLDERS **/
92
98
echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
96
102
html_tag( 'tr' ) .
97
103
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
addForm('folders_create.php', 'POST', 'cf').
105
addInput('folder_name', '', 25).
106
"<br />\n". _("as a subfolder of"). '<br />'.
107
"<tt><select name=\"subfolder\">\n";
105
109
$show_selected = array();
106
110
$skip_folders = array();
108
112
if ( $server_type == 'courier' ) {
109
113
array_push($skip_folders, 'inbox.trash');
110
114
if ( $default_folder_prefix == 'INBOX.' ) {
111
array_push($skip_folders, 'inbox');
115
array_push($skip_folders, 'INBOX');
115
119
if ( $default_sub_of_inbox == false ) {
116
echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
120
echo '<option selected="selected" value="">[ '._("None")." ]</option>\n";
118
echo '<OPTION VALUE="">[ '._("None")." ]\n";
122
echo '<option value="">[ '._("None")." ]</option>\n";
119
123
$show_selected = array('inbox');
125
129
// use the long format to show subfolders in an intelligible way if parent is missing (special folder)
126
130
echo sqimap_mailbox_option_list($imapConnection, $show_selected, $skip_folders, $boxes, 'noinferiors', true);
128
echo "</SELECT></TT>\n";
132
echo "</select></tt>\n";
129
133
if ($show_contain_subfolders_option) {
130
echo '<br><input type=CHECKBOX NAME="contain_subs"> '
135
addCheckBox('contain_subs', FALSE, '1') .' '
131
136
. _("Let this folder contain subfolders")
134
echo "<input type=SUBMIT VALUE=\""._("Create")."\">\n";
135
echo "</FORM></td></tr>\n";
139
echo "<input type=\"submit\" value=\""._("Create")."\" />\n";
140
echo "</form></td></tr>\n";
137
142
echo html_tag( 'tr',
138
143
html_tag( 'td', ' ', 'left', $color[4] )
141
146
/** count special folders **/
143
// FIX ME, why not check if the folders are defined IMHO move_to_sent, move_to_trash has nothing todo with it
144
147
$count_special_folders = 0;
146
149
if (strtolower($imap_server_type) == "courier" || $move_to_trash) {
156
// What if move_to_sent = false and $sent_folder is set? Should it still be skipped?
159
// determine which folders the user shouldn't be able to rename/delete
158
160
for ($p = 0, $cnt = count($boxes); $p < $cnt && $count_special_folders < $num_max; $p++) {
159
switch ($boxes[$p]['unformatted'])
161
case (strtoupper($boxes[$p]['unformatted']) == 'INBOX'):
162
++$count_special_folders;
163
$skip_folders[] = $boxes[$p]['unformatted'];
165
// FIX ME inbox.trash should be set in conf.pl
167
if (strtolower($imap_server_type) == 'courier') {
168
++$count_special_folders;
172
++$count_special_folders;
173
$skip_folders[] = $trash_folder;
176
++$count_special_folders;
177
$skip_folders[] = $sent_folder;
180
++$count_special_folders;
181
$skip_folders[] = $draft_folder;
161
switch ($boxes[$p]['unformatted']) {
162
case (strtoupper($boxes[$p]['unformatted']) == 'INBOX'):
163
++$count_special_folders;
164
$skip_folders[] = $boxes[$p]['unformatted'];
166
// FIX ME inbox.trash should be set in conf.pl
168
if (strtolower($imap_server_type) == 'courier') {
169
++$count_special_folders;
173
++$count_special_folders;
174
$skip_folders[] = $trash_folder;
177
++$count_special_folders;
178
$skip_folders[] = $sent_folder;
181
++$count_special_folders;
182
$skip_folders[] = $draft_folder;
193
193
html_tag( 'td', '', 'center', $color[0] );
195
195
if ($count_special_folders < count($boxes)) {
196
echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"
197
. "<TT><SELECT NAME=old>\n"
198
. ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
196
echo addForm('folders_rename_getname.php')
197
. "<tt><select name=\"old\">\n"
198
. ' <option value="">[ ' . _("Select a folder") . " ]</option>\n";
200
200
// use existing IMAP connection, we have no special values to show,
201
201
// but we do include values to skip. Use the pre-created $boxes to save an IMAP query.
203
203
// use long format to make sure folder names make sense when parents may be missing.
204
204
echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes, NULL, true);
206
echo "</SELECT></TT>\n".
207
"<input type=SUBMIT VALUE=\"".
206
echo "</select></tt>\n".
207
'<input type="submit" value="'.
210
"</FORM></td></tr>\n";
210
"</form></td></tr>\n";
212
echo _("No folders found") . '<br><br></td></tr>';
212
echo _("No folders found") . '<br /><br /></td></tr>';
214
214
$boxes_sub = $boxes;
225
225
html_tag( 'td', '', 'center', $color[0] );
227
227
if ($count_special_folders < count($boxes)) {
228
echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"
229
. "<TT><SELECT NAME=mailbox>\n"
230
. ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
228
echo addForm('folders_delete.php')
229
. "<tt><select name=\"mailbox\">\n"
230
. ' <option value="">[ ' . _("Select a folder") . " ]</option>\n";
232
232
// send NULL for the flag - ALL folders are eligible for delete (except what we've got in skiplist)
233
233
// use long format to make sure folder names make sense when parents may be missing.
234
234
echo sqimap_mailbox_option_list($imapConnection, 0, $skip_folders, $boxes, NULL, true);
236
echo "</SELECT></TT>\n"
237
. '<input type=SUBMIT VALUE="'
236
echo "</select></tt>\n"
237
. '<input type="submit" value="'
240
240
. "</form></td></tr>\n";
242
echo _("No folders found") . "<br><br></td></tr>";
242
echo _("No folders found") . "<br /><br /></td></tr>";
245
245
echo html_tag( 'tr',
256
256
html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
258
258
if ($count_special_folders < count($boxes)) {
259
echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"
260
. "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
259
echo addForm('folders_subscribe.php?method=unsub')
260
. "<tt><select name=\"mailbox[]\" multiple=\"multiple\" size=\"8\">\n";
261
261
for ($i = 0; $i < count($boxes); $i++) {
262
262
$use_folder = true;
263
263
if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
264
264
($boxes[$i]["unformatted"] != $trash_folder) &&
265
265
($boxes[$i]["unformatted"] != $sent_folder) &&
266
266
($boxes[$i]["unformatted"] != $draft_folder)) {
267
$box = htmlspecialchars($boxes[$i]["unformatted-dm"]);
268
$box2 = str_replace(' ', ' ',
269
htmlspecialchars(imap_utf7_decode_local($boxes[$i]["unformatted-disp"])));
270
echo " <OPTION VALUE=\"$box\">$box2\n";
267
$box = $boxes[$i]["unformatted-dm"];
268
$box2 = str_replace(array(' ','<','>'), array(' ','<','>'),
269
imap_utf7_decode_local($boxes[$i]["unformatted-disp"]));
270
echo " <option value=\"$box\">$box2</option>\n";
273
echo "</SELECT></TT><br><br>\n"
274
. '<input type=SUBMIT VALUE="'
273
echo "</select></tt><br /><br />\n"
274
. '<input type="submit" value="'
275
275
. _("Unsubscribe")
279
279
echo _("No folders were found to unsubscribe from!") . '</td>';
300
300
if ($use_folder == true) {
301
$box[$q] = htmlspecialchars($boxes_all[$i]['unformatted-dm']);
302
$box2[$q] = htmlspecialchars(imap_utf7_decode_local($boxes_all[$i]['unformatted-disp']));
301
$box[$q] = $boxes_all[$i]['unformatted-dm'];
302
$box2[$q] = imap_utf7_decode_local($boxes_all[$i]['unformatted-disp']);
306
306
if ($box && $box2) {
307
echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
308
. '<tt><select name="mailbox[]" multiple size=8>';
307
echo addForm('folders_subscribe.php?method=sub')
308
. '<tt><select name="mailbox[]" multiple="multiple" size="8">';
310
310
for ($q = 0; $q < count($box); $q++) {
311
echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
311
echo ' <option value="' . $box[$q] . '">' .
312
str_replace(array(' ','<','>'),array(' ','<','>'),$box2[$q])."</option>\n";
313
echo '</select></tt><br><br>'
314
. '<input type=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
315
. "</FORM></td></tr></table><BR>\n";
314
echo '</select></tt><br /><br />'
315
. '<input type="submit" value="'. _("Subscribe") . "\" />\n"
316
. "</form></td></tr></table><br />\n";
317
318
echo _("No folders were found to subscribe to!") . '</td></tr></table>';
320
321
/* don't perform the list action -- this is much faster */
321
echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"
322
. _("Subscribe to:") . '<br>'
323
. '<tt><input type="text" name="mailbox[]" size=35>'
324
. '<INPUT TYPE=SUBMIT VALUE="'. _("Subscribe") . "\">\n"
325
. "</FORM></TD></TR></TABLE><BR>\n";
322
echo addForm('folders_subscribe.php?method=sub')
323
. _("Subscribe to:") . '<br />'
324
. '<tt><input type="text" name="mailbox[]" size="35" />'
325
. '<input type="submit" value="'. _("Subscribe") . "\" />\n"
326
. "</form></td></tr></table><br />\n";
328
329
do_hook('folders_bottom');
338
336
sqimap_logout($imapConnection);