~ubuntu-branches/ubuntu/hardy/squirrelmail/hardy-updates

« back to all changes in this revision

Viewing changes to src/folders.php

  • Committer: Bazaar Package Importer
  • Author(s): Thijs Kinkhorst
  • Date: 2005-02-06 21:41:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050206214151-z4n1o8mnttgzuj0y
Tags: 2:1.4.4-3
* Move default_pref config file from /var to /etc, as per Debian policy
  (Closes: #293281)
* [JvW] (finally) override two lintian warnings about nonstandard
  permissions that are intentional (Closes: #293366)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/**
4
4
 * folders.php
5
5
 *
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.
8
8
 *
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
11
11
 * Folders.
12
12
 *
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
15
15
 */
16
16
 
17
 
/** Path for SquirrelMail required files. */
 
17
/**
 
18
 * Path for SquirrelMail required files.
 
19
 * @ignore
 
20
 */
18
21
define('SM_PATH','../');
19
22
 
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');
25
29
 
26
30
displayPageHeader($color, 'None');
27
31
 
36
40
 
37
41
/* end of get globals */
38
42
 
39
 
echo '<br>' .
 
43
echo '<br />' .
40
44
    html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) .
41
45
        html_tag( 'tr' ) .
42
46
            html_tag( 'td', '', 'center' ) . '<b>' . _("Folders") . '</b>' .
70
74
            break;
71
75
    }
72
76
 
73
 
    $td_str .= '</b><br>';        
 
77
    $td_str .= '</b><br />';
74
78
 
75
79
 
76
80
    echo html_tag( 'table',
77
81
                html_tag( 'tr',
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>' ,
81
85
                     'center' )
82
86
                ) ,
83
87
            'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' );
84
88
}
85
89
 
86
 
echo "\n<br>";
 
90
echo "\n<br />";
87
91
 
88
92
$imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
89
 
$boxes = sqimap_mailbox_list($imapConnection);
 
93
 
 
94
// force retrieval of a non cached folderlist
 
95
$boxes = sqimap_mailbox_list($imapConnection,true);
90
96
 
91
97
/** CREATING FOLDERS **/
92
98
echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
95
101
            ) .
96
102
            html_tag( 'tr' ) .
97
103
                html_tag( 'td', '', 'center', $color[0] ) .
98
 
 
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").
102
 
     '<BR>'.
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";
104
108
 
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');
112
116
  }
113
117
}
114
118
 
115
119
if ( $default_sub_of_inbox == false ) {
116
 
    echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
 
120
    echo '<option selected="selected" value="">[ '._("None")." ]</option>\n";
117
121
} else {
118
 
    echo '<OPTION VALUE="">[ '._("None")." ]\n";
 
122
    echo '<option value="">[ '._("None")." ]</option>\n";
119
123
    $show_selected = array('inbox');
120
124
}
121
125
 
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);
127
131
 
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"> &nbsp;'
 
134
    echo '<br />'.
 
135
         addCheckBox('contain_subs', FALSE, '1') .' &nbsp;'
131
136
       . _("Let this folder contain subfolders")
132
 
       . '<BR>';
 
137
       . '<br />';
133
138
}
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";
136
141
 
137
142
echo html_tag( 'tr',
138
143
            html_tag( 'td', '&nbsp;', 'left', $color[4] )
139
144
        ) ."\n";
140
145
 
141
146
/** count special folders **/
142
 
 
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;
145
148
$num_max = 1;
146
149
if (strtolower($imap_server_type) == "courier" || $move_to_trash) {
153
156
    $num_max++;
154
157
}
155
158
 
156
 
// What if move_to_sent = false and $sent_folder is set? Should it still be skipped?
157
 
 
 
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'])
160
 
    {
161
 
       case (strtoupper($boxes[$p]['unformatted']) == 'INBOX'):
162
 
          ++$count_special_folders;
163
 
          $skip_folders[] = $boxes[$p]['unformatted'];
164
 
          break;
165
 
       // FIX ME inbox.trash should be set in conf.pl
166
 
       case 'inbox.trash':
167
 
          if (strtolower($imap_server_type) == 'courier') {
168
 
              ++$count_special_folders;
169
 
          }
170
 
          break;
171
 
       case $trash_folder:
172
 
           ++$count_special_folders;
173
 
           $skip_folders[] = $trash_folder;
174
 
           break;
175
 
       case $sent_folder:
176
 
           ++$count_special_folders;
177
 
           $skip_folders[] = $sent_folder;
178
 
           break;
179
 
       case $draft_folder:
180
 
           ++$count_special_folders;
181
 
           $skip_folders[] = $draft_folder;
182
 
           break;
183
 
       default: break;
184
 
    }     
 
161
    switch ($boxes[$p]['unformatted']) {
 
162
        case (strtoupper($boxes[$p]['unformatted']) == 'INBOX'):
 
163
            ++$count_special_folders;
 
164
            $skip_folders[] = $boxes[$p]['unformatted'];
 
165
            break;
 
166
        // FIX ME inbox.trash should be set in conf.pl
 
167
        case 'inbox.trash':
 
168
            if (strtolower($imap_server_type) == 'courier') {
 
169
                ++$count_special_folders;
 
170
            }
 
171
            break;
 
172
        case $trash_folder:
 
173
            ++$count_special_folders;
 
174
            $skip_folders[] = $trash_folder;
 
175
            break;
 
176
        case $sent_folder:
 
177
            ++$count_special_folders;
 
178
            $skip_folders[] = $sent_folder;
 
179
            break;
 
180
        case $draft_folder:
 
181
            ++$count_special_folders;
 
182
            $skip_folders[] = $draft_folder;
 
183
            break;
 
184
    }
185
185
}
186
186
 
187
187
 
193
193
        html_tag( 'td', '', 'center', $color[0] );
194
194
 
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";
199
199
 
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);
205
205
 
206
 
    echo "</SELECT></TT>\n".
207
 
         "<input type=SUBMIT VALUE=\"".
 
206
    echo "</select></tt>\n".
 
207
         '<input type="submit" value="'.
208
208
         _("Rename").
209
 
         "\">\n".
210
 
         "</FORM></td></tr>\n";
 
209
         "\" />\n".
 
210
         "</form></td></tr>\n";
211
211
} else {
212
 
    echo _("No folders found") . '<br><br></td></tr>';
 
212
    echo _("No folders found") . '<br /><br /></td></tr>';
213
213
}
214
214
$boxes_sub = $boxes;
215
215
 
225
225
        html_tag( 'td', '', 'center', $color[0] );
226
226
 
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";
231
231
 
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);
235
235
 
236
 
    echo "</SELECT></TT>\n"
237
 
       . '<input type=SUBMIT VALUE="'
 
236
    echo "</select></tt>\n"
 
237
       . '<input type="submit" value="'
238
238
       . _("Delete")
239
 
       . "\">\n"
 
239
       . "\" />\n"
240
240
       . "</form></td></tr>\n";
241
241
} else {
242
 
    echo _("No folders found") . "<br><br></td></tr>";
 
242
    echo _("No folders found") . "<br /><br /></td></tr>";
243
243
}
244
244
 
245
245
echo html_tag( 'tr',
256
256
                html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
257
257
 
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(' ', '&nbsp;',
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('&nbsp;','&lt;','&gt;'),
 
269
                                imap_utf7_decode_local($boxes[$i]["unformatted-disp"]));
 
270
            echo "         <option value=\"$box\">$box2</option>\n";
271
271
        }
272
272
    }
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")
276
 
       . "\">\n"
277
 
       . "</FORM></td>\n";
 
276
       . "\" />\n"
 
277
       . "</form></td>\n";
278
278
} else {
279
279
    echo _("No folders were found to unsubscribe from!") . '</td>';
280
280
}
298
298
        }
299
299
    }
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']);
303
303
        $q++;
304
304
    }
305
305
  }
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">';
309
309
 
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('&nbsp;','&lt;','&gt;'),$box2[$q])."</option>\n";
312
313
    }      
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";
316
317
  } else {
317
318
    echo _("No folders were found to subscribe to!") . '</td></tr></table>';
318
319
  }
319
320
} else {
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";
326
327
}
327
328
 
328
329
do_hook('folders_bottom');
329
330
?>
330
 
 
331
331
    </td></tr>
332
332
    </table>
333
 
 
334
333
</td></tr>
335
334
</table>
336
 
 
337
335
<?php
338
336
   sqimap_logout($imapConnection);
339
337
?>
340
 
 
341
338
</body></html>