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 848 2007-10-02 08:42:18Z thomasb $
22 // count messages before changing anything
23 $old_count = $IMAP->messagecount();
24 $old_pages = ceil($old_count / $IMAP->page_size);
27 if ($_action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox']))
29 $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
30 $target = get_input_value('_target_mbox', RCUBE_INPUT_POST);
31 $moved = $IMAP->move_message($uids, $target, get_input_value('_mbox', RCUBE_INPUT_POST));
36 $OUTPUT->command('list_mailbox');
37 $OUTPUT->show_message('errormoving', 'error');
44 else if ($_action=='delete' && !empty($_POST['_uid']))
46 $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
47 $del = $IMAP->delete_message($uids, get_input_value('_mbox', RCUBE_INPUT_POST));
52 $OUTPUT->command('list_mailbox');
53 $OUTPUT->show_message('errordeleting', 'error');
59 // unknown action or missing query param
63 // refresh saved seach set after moving some messages
64 if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set)
65 $_SESSION['search'][$search_request] = $IMAP->refresh_search();
68 $msg_count = $IMAP->messagecount();
69 $pages = ceil($msg_count / $IMAP->page_size);
70 $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
71 $remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
73 // jump back one page (user removed the whole last page)
74 if ($IMAP->list_page > 1 && $nextpage_count <= 0 && $remaining == 0)
76 $IMAP->set_page($IMAP->list_page-1);
77 $_SESSION['page'] = $IMAP->list_page;
81 // update message count display
82 $OUTPUT->set_env('pagecount', $pages);
83 $OUTPUT->set_env('current_page', $IMAP->list_page);
84 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
88 $mbox = $IMAP->get_mailbox_name();
89 $OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
91 if ($_action=='moveto' && $target)
92 $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN'));
94 $OUTPUT->command('set_quota', $IMAP->get_quota());
96 // add new rows from next page (if any)
97 if ($_POST['_from']!='show' && ($jump_back || $nextpage_count > 0))
99 $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
100 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
102 $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
104 $a_headers = array_slice($a_headers, -$count, $count);
106 rcmail_js_message_list($a_headers);