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 2018 2008-10-27 10:53:56Z 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 $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
32 // flag messages as read before moving them
33 if ($CONFIG['read_when_deleted'] && $target == $CONFIG['trash_mbox'])
34 $IMAP->set_flag($uids, 'SEEN');
36 $moved = $IMAP->move_message($uids, $target, $mbox);
40 $OUTPUT->command('list_mailbox');
41 $OUTPUT->show_message('errormoving', 'error');
46 if (!$CONFIG['flag_for_deletion'])
50 else if ($RCMAIL->action=='delete' && !empty($_POST['_uid'])) {
51 $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
52 $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
53 $del = $IMAP->delete_message($uids, $mbox);
57 $OUTPUT->command('list_mailbox');
58 $OUTPUT->show_message('errordeleting', 'error');
65 // unknown action or missing query param
69 // refresh saved search set after moving some messages
70 if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) {
71 $_SESSION['search'][$search_request] = $IMAP->refresh_search();
74 $msg_count = $IMAP->messagecount();
75 $pages = ceil($msg_count / $IMAP->page_size);
76 $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
77 $remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
79 // jump back one page (user removed the whole last page)
80 if ($IMAP->list_page > 1 && $nextpage_count <= 0 && $remaining == 0) {
81 $IMAP->set_page($IMAP->list_page-1);
82 $_SESSION['page'] = $IMAP->list_page;
86 // update message count display
87 $OUTPUT->set_env('pagecount', $pages);
88 $OUTPUT->set_env('messagecount', $msg_count);
89 $OUTPUT->set_env('current_page', $IMAP->list_page);
90 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
93 $mbox = $IMAP->get_mailbox_name();
94 $OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'), ($mbox == 'INBOX'));
96 if ($RCMAIL->action=='moveto' && $target) {
97 $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN'));
100 $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota()));
102 // add new rows from next page (if any)
103 if ($addrows && $_POST['_from']!='show' && ($jump_back || $nextpage_count > 0)) {
104 $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
105 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
107 $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
109 $a_headers = array_slice($a_headers, -$count, $count);
111 rcmail_js_message_list($a_headers);