source: subversion/branches/devel-vnext/program/steps/mail/move_del.inc @ 629

Last change on this file since 629 was 629, checked in by till, 6 years ago

# several smaller bugfixes (mostly introduced when i implemented the registry)
# fixed trash deletion etc.

  • removed some of the debug logging
File size: 3.6 KB
Line 
1<?php
2/*
3 +-----------------------------------------------------------------------+
4 | program/steps/mail/move_del.inc                                       |
5 |                                                                       |
6 | This file is part of the RoundCube Webmail client                     |
7 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
8 | Licensed under the GNU GPL                                            |
9 |                                                                       |
10 | PURPOSE:                                                              |
11 |   Move the submitted messages to a specific mailbox or delete them    |
12 |                                                                       |
13 +-----------------------------------------------------------------------+
14 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
15 +-----------------------------------------------------------------------+
16
17 $Id: move_del.inc 573 2007-05-18 11:29:25Z thomasb $
18
19*/
20
21$registry = rc_registry::getInstance();
22$IMAP     = $registry->get('IMAP', 'core');
23$OUTPUT   = $registry->get('OUTPUT', 'core');
24
25// move messages
26if ($_action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) {
27    $count  = sizeof(explode(',', ($uids = rc_main::get_input_value('_uid', RCUBE_INPUT_POST))));
28    $target = rc_main::get_input_value('_target_mbox', RCUBE_INPUT_POST);
29    $moved  = $IMAP->move_message($uids, $target, rc_main::get_input_value('_mbox', RCUBE_INPUT_POST));
30
31    if (!$moved) {
32        // send error message
33        $OUTPUT->command('list_mailbox');
34        $OUTPUT->show_message('errormoving', 'error');
35        $OUTPUT->send();
36        exit;
37    }
38}
39// delete messages
40else if ($_action=='delete' && !empty($_POST['_uid'])) {
41    $count = sizeof(explode(',', ($uids = rc_main::get_input_value('_uid', RCUBE_INPUT_POST))));
42    $del   = $IMAP->delete_message($uids, rc_main::get_input_value('_mbox', RCUBE_INPUT_POST));
43
44    if (!$del) {
45        // send error message
46        $OUTPUT->command('list_mailbox');
47        $OUTPUT->show_message('errordeleting', 'error');
48        $OUTPUT->send();
49        exit;
50    }
51}
52// unknown action or missing query param
53else {
54    rc_main::tfk_debug('/ unknown action');
55    exit;
56}
57
58// refresh saved seach set after moving some messages
59if (
60    ($search_request = rc_main::get_input_value('_search', RCUBE_INPUT_GPC))
61    && $IMAP->search_set
62) {
63    $_SESSION['search'][$search_request] = $IMAP->refresh_search();
64}
65
66// update message count display
67$msg_count = $IMAP->messagecount();
68$pages     = ceil($msg_count / $IMAP->page_size);
69$OUTPUT->set_env('pagecount', $pages);
70$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
71
72
73// update mailboxlist
74$mbox = $IMAP->get_mailbox_name();
75$OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
76
77if ($_action=='moveto' && $target) {
78    $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN'));
79}
80$OUTPUT->command('set_quota', $IMAP->get_quota());
81
82// add new rows from next page (if any)
83if ($_POST['_from'] != 'show' && $pages > 1 && $IMAP->list_page < $pages) {
84    $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
85    $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
86
87    $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
88    $a_headers = array_slice($a_headers, -$count, $count);
89
90    rcmail_js_message_list($a_headers);
91}
92
93// send response
94$OUTPUT->send();
95?>
Note: See TracBrowser for help on using the repository browser.