4 +-----------------------------------------------------------------------+
5 | program/steps/mail/move_del.inc |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2005-2009, Roundcube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Move the submitted messages to a specific mailbox or delete them |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: move_del.inc 4321 2010-12-08 12:52:04Z alec $
22 // only process ajax requests
23 if (!$OUTPUT->ajax_call)
26 // count messages before changing anything
27 $old_count = $IMAP->messagecount(NULL, $IMAP->threading ? 'THREADS' : 'ALL');
28 $old_pages = ceil($old_count / $IMAP->page_size);
31 if ($RCMAIL->action=='moveto' && !empty($_POST['_uid']) && strlen($_POST['_target_mbox'])) {
32 $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
33 $target = get_input_value('_target_mbox', RCUBE_INPUT_POST, true);
34 $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true);
36 $moved = $IMAP->move_message($uids, $target, $mbox);
40 if ($_POST['_from'] != 'show')
41 $OUTPUT->command('list_mailbox');
42 rcmail_display_server_error('errormoving');
47 $OUTPUT->show_message('messagemoved', 'confirmation');
53 else if ($RCMAIL->action=='delete' && !empty($_POST['_uid'])) {
54 $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
55 $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true);
57 $del = $IMAP->delete_message($uids, $mbox);
61 if ($_POST['_from'] != 'show')
62 $OUTPUT->command('list_mailbox');
63 rcmail_display_server_error('errordeleting');
68 $OUTPUT->show_message('messagedeleted', 'confirmation');
73 // unknown action or missing query param
78 // refresh saved search set after moving some messages
79 if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) {
80 $_SESSION['search'] = $IMAP->refresh_search();
83 if ($_POST['_from'] == 'show')
85 if ($next = get_input_value('_next_uid', RCUBE_INPUT_GPC))
86 $OUTPUT->command('show_message', $next);
88 $OUTPUT->command('command', 'list');
92 $msg_count = $IMAP->messagecount(NULL, $IMAP->threading ? 'THREADS' : 'ALL');
93 $pages = ceil($msg_count / $IMAP->page_size);
94 $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
95 $remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
97 // jump back one page (user removed the whole last page)
98 if ($IMAP->list_page > 1 && $remaining == 0) {
99 $IMAP->set_page($IMAP->list_page-1);
100 $_SESSION['page'] = $IMAP->list_page;
104 // update message count display
105 $OUTPUT->set_env('messagecount', $msg_count);
106 $OUTPUT->set_env('current_page', $IMAP->list_page);
107 $OUTPUT->set_env('pagecount', $pages);
109 // update mailboxlist
110 $mbox = $IMAP->get_mailbox_name();
111 $unseen_count = $msg_count ? $IMAP->messagecount($mbox, 'UNSEEN') : 0;
112 $old_unseen = rcmail_get_unseen_count($mbox);
114 if ($old_unseen != $unseen_count) {
115 $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
116 rcmail_set_unseen_count($mbox, $unseen_count);
119 if ($RCMAIL->action=='moveto' && strlen($target)) {
120 rcmail_send_unread_count($target, true);
123 $OUTPUT->command('set_quota', rcmail_quota_content());
124 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
126 if ($IMAP->threading)
127 $count = get_input_value('_count', RCUBE_INPUT_POST);
129 // add new rows from next page (if any)
130 if ($addrows && $count && $uids != '*' && ($jump_back || $nextpage_count > 0)) {
131 $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
132 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
134 $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order,
135 $jump_back ? NULL : $count);
137 rcmail_js_message_list($a_headers, false);