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

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

# bugfixes
+ debugging

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    rc_main::tfk_debug('Moved?: ' . $target . '/' . $uids . '/' . $moved);
32
33    if (!$moved) {
34        // send error message
35        $OUTPUT->command('list_mailbox');
36        $OUTPUT->show_message('errormoving', 'error');
37        $OUTPUT->send();
38        exit;
39    }
40}
41// delete messages
42else if ($_action=='delete' && !empty($_POST['_uid'])) {
43    $count = sizeof(explode(',', ($uids = rc_main::get_input_value('_uid', RCUBE_INPUT_POST))));
44    $del   = $IMAP->delete_message($uids, rc_main::get_input_value('_mbox', RCUBE_INPUT_POST));
45
46    if (!$del) {
47        // send error message
48        $OUTPUT->command('list_mailbox');
49        $OUTPUT->show_message('errordeleting', 'error');
50        $OUTPUT->send();
51        exit;
52    }
53}
54// unknown action or missing query param
55else {
56    //rc_main::tfk_debug('/ unknown action');
57    exit;
58}
59
60// refresh saved seach set after moving some messages
61if (
62    ($search_request = rc_main::get_input_value('_search', RCUBE_INPUT_GPC))
63    && $IMAP->search_set
64) {
65    $_SESSION['search'][$search_request] = $IMAP->refresh_search();
66}
67
68// update message count display
69$msg_count = $IMAP->messagecount();
70$pages     = ceil($msg_count / $IMAP->page_size);
71$OUTPUT->set_env('pagecount', $pages);
72$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
73
74
75// update mailboxlist
76$mbox = $IMAP->get_mailbox_name();
77$OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
78
79if ($_action=='moveto' && $target) {
80    $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN'));
81}
82$OUTPUT->command('set_quota', $IMAP->get_quota());
83
84// add new rows from next page (if any)
85if ($_POST['_from'] != 'show' && $pages > 1 && $IMAP->list_page < $pages) {
86    $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
87    $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
88
89    $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
90    $a_headers = array_slice($a_headers, -$count, $count);
91
92    rcmail_js_message_list($a_headers);
93}
94
95// send response
96$OUTPUT->send();
97?>
Note: See TracBrowser for help on using the repository browser.