3 +-----------------------------------------------------------------------+
4 | program/steps/mail/mark.inc |
6 | This file is part of the Roundcube Webmail client |
7 | Copyright (C) 2005-2009, Roundcube Dev. - Switzerland |
8 | Licensed under the GNU GPL |
11 | Mark the submitted messages with the specified flag |
13 +-----------------------------------------------------------------------+
14 | Author: Thomas Bruederli <roundcube@gmail.com> |
15 +-----------------------------------------------------------------------+
17 $Id: mark.inc 4321 2010-12-08 12:52:04Z alec $
21 // only process ajax requests
22 if (!$OUTPUT->ajax_call)
26 'undelete' => 'UNDELETED',
27 'delete' => 'DELETED',
30 'flagged' => 'FLAGGED',
31 'unflagged' => 'UNFLAGGED');
33 if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_value('_flag', RCUBE_INPUT_POST)))
35 $flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag);
37 if ($flag == 'DELETED' && $CONFIG['skip_deleted'] && $_POST['_from'] != 'show') {
38 // count messages before changing anything
39 $old_count = $IMAP->messagecount(NULL, $IMAP->threading ? 'THREADS' : 'ALL');
40 $old_pages = ceil($old_count / $IMAP->page_size);
41 $count = sizeof(explode(',', $uids));
44 $marked = $IMAP->set_flag($uids, $flag);
48 if ($_POST['_from'] != 'show')
49 $OUTPUT->command('list_mailbox');
50 rcmail_display_server_error('errormarking');
54 else if (empty($_POST['_quiet'])) {
55 $OUTPUT->show_message('messagemarked', 'confirmation');
58 if ($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid'])) {
59 $ruids = get_input_value('_ruid', RCUBE_INPUT_POST);
60 $read = $IMAP->set_flag($ruids, 'SEEN');
62 if ($read && !$CONFIG['skip_deleted'])
63 $OUTPUT->command('flag_deleted_as_read', $ruids);
66 if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) {
67 rcmail_send_unread_count($IMAP->get_mailbox_name());
69 else if ($flag == 'DELETED' && $CONFIG['skip_deleted']) {
70 if ($_POST['_from'] == 'show') {
71 if ($next = get_input_value('_next_uid', RCUBE_INPUT_GPC))
72 $OUTPUT->command('show_message', $next);
74 $OUTPUT->command('command', 'list');
76 // refresh saved search set after moving some messages
77 if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) {
78 $_SESSION['search'] = $IMAP->refresh_search();
81 $msg_count = $IMAP->messagecount(NULL, $IMAP->threading ? 'THREADS' : 'ALL');
82 $pages = ceil($msg_count / $IMAP->page_size);
83 $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
84 $remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
86 // jump back one page (user removed the whole last page)
87 if ($IMAP->list_page > 1 && $remaining == 0) {
88 $IMAP->set_page($IMAP->list_page-1);
89 $_SESSION['page'] = $IMAP->list_page;
93 // update message count display
94 $OUTPUT->set_env('messagecount', $msg_count);
95 $OUTPUT->set_env('current_page', $IMAP->list_page);
96 $OUTPUT->set_env('pagecount', $pages);
99 $mbox = $IMAP->get_mailbox_name();
100 $unseen_count = $msg_count ? $IMAP->messagecount($mbox, 'UNSEEN') : 0;
101 $old_unseen = rcmail_get_unseen_count($mbox);
103 if ($old_unseen != $unseen_count) {
104 $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
105 rcmail_set_unseen_count($mbox, $unseen_count);
107 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
109 if ($IMAP->threading)
110 $count = get_input_value('_count', RCUBE_INPUT_POST);
112 // add new rows from next page (if any)
113 if ($count && $uids != '*' && ($jump_back || $nextpage_count > 0)) {
114 $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
115 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
117 $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order,
118 $jump_back ? NULL : $count);
120 rcmail_js_message_list($a_headers, false);