commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
/* |
|
3 |
+-----------------------------------------------------------------------+ |
|
4 |
| program/steps/mail/mark.inc | |
|
5 |
| | |
|
6 |
| This file is part of the RoundCube Webmail client | |
f11541
|
7 |
| Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | |
30233b
|
8 |
| Licensed under the GNU GPL | |
4e17e6
|
9 |
| | |
T |
10 |
| PURPOSE: | |
|
11 |
| Mark the submitted messages with the specified flag | |
|
12 |
| | |
|
13 |
+-----------------------------------------------------------------------+ |
|
14 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
15 |
+-----------------------------------------------------------------------+ |
|
16 |
|
|
17 |
$Id$ |
|
18 |
|
|
19 |
*/ |
|
20 |
|
f11541
|
21 |
$a_flags_map = array( |
T |
22 |
'undelete' => 'UNDELETED', |
|
23 |
'delete' => 'DELETED', |
|
24 |
'read' => 'SEEN', |
e189a6
|
25 |
'unread' => 'UNSEEN', |
A |
26 |
'flagged' => 'FLAGGED', |
|
27 |
'unflagged' => 'UNFLAGGED'); |
4e17e6
|
28 |
|
8d0758
|
29 |
if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_value('_flag', RCUBE_INPUT_POST))) |
f11541
|
30 |
{ |
b3ce79
|
31 |
$flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag); |
cd9a03
|
32 |
|
A |
33 |
if ($flag == 'DELETED' && $CONFIG['skip_deleted'] && $_POST['_from'] != 'show') { |
|
34 |
// count messages before changing anything |
|
35 |
$old_count = $IMAP->messagecount(); |
|
36 |
$old_pages = ceil($old_count / $IMAP->page_size); |
|
37 |
$count = sizeof(explode(',', $uids)); |
|
38 |
} |
|
39 |
|
b3ce79
|
40 |
$marked = $IMAP->set_flag($uids, $flag); |
0b2ce9
|
41 |
|
A |
42 |
if ($marked == -1) { |
|
43 |
// send error message |
|
44 |
if ($_POST['_from'] != 'show') |
|
45 |
$OUTPUT->command('list_mailbox'); |
|
46 |
$OUTPUT->show_message('errormarking', 'error'); |
|
47 |
$OUTPUT->send(); |
|
48 |
exit; |
|
49 |
} |
f11541
|
50 |
|
0b2ce9
|
51 |
if($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid'])) { |
3d3531
|
52 |
$uids = get_input_value('_ruid', RCUBE_INPUT_POST); |
A |
53 |
$read = $IMAP->set_flag($uids, 'SEEN'); |
|
54 |
|
0b2ce9
|
55 |
if ($read != -1 && !$CONFIG['skip_deleted']) |
3d3531
|
56 |
$OUTPUT->command('flag_deleted_as_read', $uids); |
0b2ce9
|
57 |
} |
A |
58 |
|
|
59 |
if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) { |
c5ac07
|
60 |
$mbox_name = $IMAP->get_mailbox_name(); |
cf1f0f
|
61 |
$OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); |
4e17e6
|
62 |
} |
0b2ce9
|
63 |
else if ($flag == 'DELETED' && $CONFIG['skip_deleted']) { |
A |
64 |
if ($_POST['_from'] == 'show') { |
|
65 |
if ($next = get_input_value('_next_uid', RCUBE_INPUT_GPC)) |
|
66 |
$OUTPUT->command('show_message', $next); |
|
67 |
else |
|
68 |
$OUTPUT->command('command', 'list'); |
|
69 |
} else { |
|
70 |
// refresh saved search set after moving some messages |
|
71 |
if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) { |
|
72 |
$_SESSION['search'][$search_request] = $IMAP->refresh_search(); |
|
73 |
} |
|
74 |
|
|
75 |
$msg_count = $IMAP->messagecount(); |
|
76 |
$pages = ceil($msg_count / $IMAP->page_size); |
|
77 |
$nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page; |
|
78 |
$remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1); |
|
79 |
|
|
80 |
// jump back one page (user removed the whole last page) |
|
81 |
if ($IMAP->list_page > 1 && $nextpage_count <= 0 && $remaining == 0) { |
|
82 |
$IMAP->set_page($IMAP->list_page-1); |
|
83 |
$_SESSION['page'] = $IMAP->list_page; |
|
84 |
$jump_back = true; |
|
85 |
} |
|
86 |
|
|
87 |
// update message count display |
|
88 |
$OUTPUT->set_env('messagecount', $msg_count); |
|
89 |
$OUTPUT->set_env('current_page', $IMAP->list_page); |
|
90 |
$OUTPUT->set_env('pagecount', $pages); |
|
91 |
|
|
92 |
// update mailboxlist |
|
93 |
$mbox = $IMAP->get_mailbox_name(); |
011b02
|
94 |
$unseen_count = $msg_count ? $IMAP->messagecount($mbox, 'UNSEEN') : 0; |
A |
95 |
$OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX')); |
0b2ce9
|
96 |
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count)); |
A |
97 |
|
|
98 |
// add new rows from next page (if any) |
|
99 |
if (($jump_back || $nextpage_count > 0)) { |
|
100 |
$sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col']; |
|
101 |
$sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; |
|
102 |
|
34ebe0
|
103 |
$a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order, $count); |
0b2ce9
|
104 |
|
34ebe0
|
105 |
rcmail_js_message_list($a_headers, false, false); |
0b2ce9
|
106 |
} |
A |
107 |
} |
|
108 |
} |
|
109 |
|
e70b3b
|
110 |
$OUTPUT->send(); |
f11541
|
111 |
} |
4e17e6
|
112 |
|
T |
113 |
exit; |
0b2ce9
|
114 |
?> |