thomascube
2011-08-18 fbe54043cf598b19a753dc2b21a7ed558d23fd15
commit | author | age
15a9d1 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/mail/folders.inc                                        |
6  |                                                                       |
e019f2 7  | This file is part of the Roundcube Webmail client                     |
f5e7b3 8  | Copyright (C) 2005-2009, The Roundcube Dev Team                       |
15a9d1 9  | Licensed under the GNU GPL                                            |
T 10  |                                                                       |
11  | PURPOSE:                                                              |
12  |   Implement folder operations line EXPUNGE and Clear                  |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17
18  $Id$
19 */
20
881217 21 // only process ajax requests
T 22 if (!$OUTPUT->ajax_call)
90f81a 23     return;
881217 24
b72e2f 25 $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true);
15a9d1 26
T 27 // send EXPUNGE command
90f81a 28 if ($RCMAIL->action == 'expunge') {
15a9d1 29
90f81a 30     $success = $IMAP->expunge($mbox);
A 31
32     // reload message list if current mailbox
33     if ($success) {
34         $OUTPUT->show_message('folderexpunged', 'confirmation');
35
36         if (!empty($_REQUEST['_reload'])) {
37             $OUTPUT->command('set_quota', rcmail_quota_content());
38             $OUTPUT->command('message_list.clear');
39             $RCMAIL->action = 'list';
40             return;
41         }
42     }
43     else {
44         rcmail_display_server_error();
45     }
f11541 46 }
15a9d1 47
T 48 // clear mailbox
90f81a 49 else if ($RCMAIL->action == 'purge')
f11541 50 {
90f81a 51     $delimiter = $IMAP->get_hierarchy_delimiter();
A 52     $trash_regexp = '/^' . preg_quote($CONFIG['trash_mbox'] . $delimiter, '/') . '/';
53     $junk_regexp  = '/^' . preg_quote($CONFIG['junk_mbox'] . $delimiter, '/') . '/';
ddd776 54
90f81a 55     // we should only be purging trash and junk (or their subfolders)
A 56     if ($mbox == $CONFIG['trash_mbox'] || $mbox == $CONFIG['junk_mbox']
57         || preg_match($trash_regexp, $mbox) || preg_match($junk_regexp, $mbox)
58     ) {
59         $success = $IMAP->clear_mailbox($mbox);
b46edc 60
90f81a 61         if ($success) {
A 62             $OUTPUT->show_message('folderpurged', 'confirmation');
63
64             if (!empty($_REQUEST['_reload'])) {
65                 $OUTPUT->set_env('messagecount', 0);
66                 $OUTPUT->set_env('pagecount', 0);
67                 $OUTPUT->command('message_list.clear');
68                 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text());
69                 $OUTPUT->command('set_unread_count', $mbox, 0);
70                 $OUTPUT->command('set_quota', rcmail_quota_content());
71                 rcmail_set_unseen_count($mbox, 0);
72             }
73         }
74         else {
75             rcmail_display_server_error();
76         }
a02d48 77     }
f11541 78 }
15a9d1 79
90f81a 80 $OUTPUT->send();