source: subversion/trunk/roundcubemail/program/steps/mail/move_del.inc @ 846

Last change on this file since 846 was 846, checked in by thomasb, 6 years ago

Fix loading of next messages after moving/deleting (#1484307)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/mail/move_del.inc                                       |
6 |                                                                       |
7 | This file is part of the RoundCube Webmail client                     |
8 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Move the submitted messages to a specific mailbox or delete them    |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16 +-----------------------------------------------------------------------+
17
18 $Id$
19
20*/
21
22// count pages before changing anything
23$old_count = $IMAP->messagecount();
24$old_pages = ceil($old_count / $IMAP->page_size);
25
26// move messages
27if ($_action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox']))
28{
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));
32 
33  if (!$moved)
34  {
35    // send error message
36    $OUTPUT->command('list_mailbox');
37    $OUTPUT->show_message('errormoving', 'error');
38    $OUTPUT->send();
39    exit;
40  }
41}
42
43// delete messages
44else if ($_action=='delete' && !empty($_POST['_uid']))
45{
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));
48 
49  if (!$del)
50  {
51    // send error message
52    $OUTPUT->command('list_mailbox');
53    $OUTPUT->show_message('errordeleting', 'error');
54    $OUTPUT->send();
55    exit;
56  }
57}
58 
59// unknown action or missing query param
60else
61  exit;
62
63// refresh saved seach set after moving some messages
64if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set)
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' && $old_pages>1 && $IMAP->list_page < $old_pages)
86{
87  $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
88  $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
89 
90  $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
91  $a_headers = array_slice($a_headers, -$count, $count);
92
93  rcmail_js_message_list($a_headers);
94}
95
96
97// send response
98$OUTPUT->send();
99
100?>
Note: See TracBrowser for help on using the repository browser.