4 +-----------------------------------------------------------------------+
5 | program/steps/mail/move_del.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005-2007, 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 1359 2008-05-06 16:56:42Z alec $
22 // count messages before changing anything
23 $old_count = $IMAP->messagecount();
24 $old_pages = ceil($old_count / $IMAP->page_size);
27 if ($RCMAIL->action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) {
28 $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
29 $target = get_input_value('_target_mbox', RCUBE_INPUT_POST);
30 $moved = $IMAP->move_message($uids, $target, get_input_value('_mbox', RCUBE_INPUT_POST));
34 $OUTPUT->command('list_mailbox');
35 $OUTPUT->show_message('errormoving', 'error');
41 else if ($RCMAIL->action=='delete' && !empty($_POST['_uid'])) {
42 $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
43 $del = $IMAP->delete_message($uids, get_input_value('_mbox', RCUBE_INPUT_POST));
47 $OUTPUT->command('list_mailbox');
48 $OUTPUT->show_message('errordeleting', 'error');
53 // unknown action or missing query param
57 // refresh saved search set after moving some messages
58 if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) {
59 $_SESSION['search'][$search_request] = $IMAP->refresh_search();
62 $msg_count = $IMAP->messagecount();
63 $pages = ceil($msg_count / $IMAP->page_size);
64 $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
65 $remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
67 // jump back one page (user removed the whole last page)
68 if ($IMAP->list_page > 1 && $nextpage_count <= 0 && $remaining == 0) {
69 $IMAP->set_page($IMAP->list_page-1);
70 $_SESSION['page'] = $IMAP->list_page;
74 // update message count display
75 $OUTPUT->set_env('pagecount', $pages);
76 $OUTPUT->set_env('messagecount', $msg_count);
77 $OUTPUT->set_env('current_page', $IMAP->list_page);
78 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
82 $mbox = $IMAP->get_mailbox_name();
83 $OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'), ($mbox == 'INBOX'));
85 if ($RCMAIL->action=='moveto' && $target) {
86 $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN'));
89 $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota()));
91 // add new rows from next page (if any)
92 if ($_POST['_from']!='show' && ($jump_back || $nextpage_count > 0)) {
93 $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
94 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
96 $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
98 $a_headers = array_slice($a_headers, -$count, $count);
100 rcmail_js_message_list($a_headers);