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 | |
c97625
|
8 |
| Copyright (C) 2005-2013, The Roundcube Dev Team | |
7fe381
|
9 |
| | |
T |
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. | |
15a9d1
|
13 |
| | |
T |
14 |
| PURPOSE: | |
|
15 |
| Implement folder operations line EXPUNGE and Clear | |
|
16 |
| | |
|
17 |
+-----------------------------------------------------------------------+ |
|
18 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
19 |
+-----------------------------------------------------------------------+ |
|
20 |
*/ |
|
21 |
|
881217
|
22 |
// only process ajax requests |
c97625
|
23 |
if (!$OUTPUT->ajax_call) { |
90f81a
|
24 |
return; |
c97625
|
25 |
} |
881217
|
26 |
|
6b2b2e
|
27 |
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true); |
15a9d1
|
28 |
|
T |
29 |
// send EXPUNGE command |
90f81a
|
30 |
if ($RCMAIL->action == 'expunge') { |
c321a9
|
31 |
$success = $RCMAIL->storage->expunge_folder($mbox); |
90f81a
|
32 |
|
A |
33 |
// reload message list if current mailbox |
|
34 |
if ($success) { |
|
35 |
$OUTPUT->show_message('folderexpunged', 'confirmation'); |
|
36 |
|
|
37 |
if (!empty($_REQUEST['_reload'])) { |
6b2b2e
|
38 |
$OUTPUT->command('set_quota', $RCMAIL->quota_content()); |
90f81a
|
39 |
$OUTPUT->command('message_list.clear'); |
A |
40 |
$RCMAIL->action = 'list'; |
|
41 |
return; |
|
42 |
} |
|
43 |
} |
|
44 |
else { |
6b2b2e
|
45 |
$RCMAIL->display_server_error(); |
90f81a
|
46 |
} |
f11541
|
47 |
} |
15a9d1
|
48 |
// clear mailbox |
da5fa2
|
49 |
else if ($RCMAIL->action == 'purge') { |
AM |
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, '/') . '/'; |
ddd776
|
55 |
|
90f81a
|
56 |
// we should only be purging trash and junk (or their subfolders) |
da5fa2
|
57 |
if ($mbox == $trash_mbox || $mbox == $junk_mbox |
90f81a
|
58 |
|| preg_match($trash_regexp, $mbox) || preg_match($junk_regexp, $mbox) |
A |
59 |
) { |
c321a9
|
60 |
$success = $RCMAIL->storage->clear_folder($mbox); |
b46edc
|
61 |
|
90f81a
|
62 |
if ($success) { |
A |
63 |
$OUTPUT->show_message('folderpurged', 'confirmation'); |
|
64 |
|
|
65 |
if (!empty($_REQUEST['_reload'])) { |
|
66 |
$OUTPUT->set_env('messagecount', 0); |
|
67 |
$OUTPUT->set_env('pagecount', 0); |
04689f
|
68 |
$OUTPUT->set_env('exists', 0); |
90f81a
|
69 |
$OUTPUT->command('message_list.clear'); |
bba252
|
70 |
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text(), $mbox); |
90f81a
|
71 |
$OUTPUT->command('set_unread_count', $mbox, 0); |
6b2b2e
|
72 |
$OUTPUT->command('set_quota', $RCMAIL->quota_content()); |
90f81a
|
73 |
rcmail_set_unseen_count($mbox, 0); |
da5fa2
|
74 |
|
AM |
75 |
// set trash folder state |
|
76 |
if ($mbox === $trash_mbox) { |
|
77 |
$OUTPUT->command('set_trash_count', 0); |
|
78 |
} |
90f81a
|
79 |
} |
A |
80 |
} |
|
81 |
else { |
6b2b2e
|
82 |
$RCMAIL->display_server_error(); |
90f81a
|
83 |
} |
a02d48
|
84 |
} |
f11541
|
85 |
} |
15a9d1
|
86 |
|
90f81a
|
87 |
$OUTPUT->send(); |