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 2960 2009-09-17 12:36:32Z alec $
22 // only process ajax requests
23 if (!$OUTPUT->ajax_call)
26 // count messages before changing anything
27 $old_count = $IMAP->messagecount();
28 $old_pages = ceil($old_count / $IMAP->page_size);
31 if ($RCMAIL->action=='moveto' && !empty($_POST['_uid']) && !empty($_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);
34 $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
36 $moved = $IMAP->move_message($uids, $target, $mbox);
40 if ($_POST['_from'] != 'show')
41 $OUTPUT->command('list_mailbox');
42 $OUTPUT->show_message('errormoving', 'error');
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 if ($_POST['_from'] != 'show')
58 $OUTPUT->command('list_mailbox');
59 $OUTPUT->show_message('errordeleting', 'error');
66 // unknown action or missing query param
71 // refresh saved search set after moving some messages
72 if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) {
73 $_SESSION['search'][$search_request] = $IMAP->refresh_search();
76 if ($_POST['_from'] == 'show')
78 if ($next = get_input_value('_next_uid', RCUBE_INPUT_GPC))
79 $OUTPUT->command('show_message', $next);
81 $OUTPUT->command('command', 'list');
85 $msg_count = $IMAP->messagecount();
86 $pages = ceil($msg_count / $IMAP->page_size);
87 $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
88 $remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
90 // jump back one page (user removed the whole last page)
91 if ($IMAP->list_page > 1 && $nextpage_count <= 0 && $remaining == 0) {
92 $IMAP->set_page($IMAP->list_page-1);
93 $_SESSION['page'] = $IMAP->list_page;
97 // update message count display
98 $OUTPUT->set_env('messagecount', $msg_count);
99 $OUTPUT->set_env('current_page', $IMAP->list_page);
100 $OUTPUT->set_env('pagecount', $pages);
102 // update mailboxlist
103 $mbox = $IMAP->get_mailbox_name();
104 $unseen_count = $msg_count ? $IMAP->messagecount($mbox, 'UNSEEN') : 0;
105 $old_unseen = $_SESSION['unseen_count'][$mbox];
107 if ($old_unseen != $unseen_count) {
108 $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
109 $_SESSION['unseen_count'][$mbox] = $unseen_count;
112 if ($RCMAIL->action=='moveto' && $target) {
113 rcmail_send_unread_count($target, true);
116 $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota()));
117 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
119 // add new rows from next page (if any)
120 if ($addrows && ($jump_back || $nextpage_count > 0)) {
121 $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
122 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
124 $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order, $count);
126 rcmail_js_message_list($a_headers, false, false);