0
|
1 <?php
|
|
2
|
|
3 /**
|
|
4 +-----------------------------------------------------------------------+
|
|
5 | program/steps/mail/folders.inc |
|
|
6 | |
|
|
7 | This file is part of the Roundcube Webmail client |
|
|
8 | Copyright (C) 2005-2013, The Roundcube Dev Team |
|
|
9 | |
|
|
10 | Licensed under the GNU General Public License version 3 or |
|
|
11 | any later version with exceptions for skins & plugins. |
|
|
12 | See the README file for a full license statement. |
|
|
13 | |
|
|
14 | PURPOSE: |
|
|
15 | Implement folder operations line EXPUNGE and Clear |
|
|
16 | |
|
|
17 +-----------------------------------------------------------------------+
|
|
18 | Author: Thomas Bruederli <roundcube@gmail.com> |
|
|
19 +-----------------------------------------------------------------------+
|
|
20 */
|
|
21
|
|
22 // only process ajax requests
|
|
23 if (!$OUTPUT->ajax_call) {
|
|
24 return;
|
|
25 }
|
|
26
|
|
27 $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
|
|
28
|
|
29 // send EXPUNGE command
|
|
30 if ($RCMAIL->action == 'expunge') {
|
|
31 $success = $RCMAIL->storage->expunge_folder($mbox);
|
|
32
|
|
33 // reload message list if current mailbox
|
|
34 if ($success) {
|
|
35 $OUTPUT->show_message('folderexpunged', 'confirmation');
|
|
36
|
|
37 if (!empty($_REQUEST['_reload'])) {
|
|
38 $OUTPUT->command('set_quota', $RCMAIL->quota_content(null, $mbox));
|
|
39 $OUTPUT->command('message_list.clear');
|
|
40 $RCMAIL->action = 'list';
|
|
41 return;
|
|
42 }
|
|
43 }
|
|
44 else {
|
|
45 $RCMAIL->display_server_error();
|
|
46 }
|
|
47 }
|
|
48 // clear mailbox
|
|
49 else if ($RCMAIL->action == 'purge') {
|
|
50 $delimiter = $RCMAIL->storage->get_hierarchy_delimiter();
|
|
51 $trash_mbox = $RCMAIL->config->get('trash_mbox');
|
|
52 $junk_mbox = $RCMAIL->config->get('junk_mbox');
|
|
53 $trash_regexp = '/^' . preg_quote($trash_mbox . $delimiter, '/') . '/';
|
|
54 $junk_regexp = '/^' . preg_quote($junk_mbox . $delimiter, '/') . '/';
|
|
55
|
|
56 // we should only be purging trash and junk (or their subfolders)
|
|
57 if ($mbox == $trash_mbox || $mbox == $junk_mbox
|
|
58 || preg_match($trash_regexp, $mbox) || preg_match($junk_regexp, $mbox)
|
|
59 ) {
|
|
60 $success = $RCMAIL->storage->clear_folder($mbox);
|
|
61
|
|
62 if ($success) {
|
|
63 $OUTPUT->show_message('folderpurged', 'confirmation');
|
|
64
|
|
65 if (!empty($_REQUEST['_reload'])) {
|
|
66 $OUTPUT->set_env('messagecount', 0);
|
|
67 $OUTPUT->set_env('pagecount', 0);
|
|
68 $OUTPUT->set_env('exists', 0);
|
|
69 $OUTPUT->command('message_list.clear');
|
|
70 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text(), $mbox);
|
|
71 $OUTPUT->command('set_unread_count', $mbox, 0);
|
|
72 $OUTPUT->command('set_quota', $RCMAIL->quota_content(null, $mbox));
|
|
73 rcmail_set_unseen_count($mbox, 0);
|
|
74
|
|
75 // set trash folder state
|
|
76 if ($mbox === $trash_mbox) {
|
|
77 $OUTPUT->command('set_trash_count', 0);
|
|
78 }
|
|
79 }
|
|
80 }
|
|
81 else {
|
|
82 $RCMAIL->display_server_error();
|
|
83 }
|
|
84 }
|
|
85 }
|
|
86
|
|
87 $OUTPUT->send();
|