From 9a3567a28c976548e71d7a93cbe78f3d3683fcea Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 02 Oct 2007 04:42:18 -0400
Subject: [PATCH] Fix of the better fix of the bugfix :-)

---
 program/steps/mail/move_del.inc |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index 03695e9..ff6117d 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -21,6 +21,7 @@
 
 // count messages before changing anything
 $old_count = $IMAP->messagecount();
+$old_pages = ceil($old_count / $IMAP->page_size);
 
 // move messages
 if ($_action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox']))
@@ -64,10 +65,13 @@
   $_SESSION['search'][$search_request] = $IMAP->refresh_search();
 
 
-$remaining = $old_count - $IMAP->page_size * $IMAP->list_page;
+$msg_count = $IMAP->messagecount();
+$pages = ceil($msg_count / $IMAP->page_size);
+$nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
+$remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
 
 // jump back one page (user removed the whole last page)
-if ($IMAP->list_page > 1 && $remaining <= 0)
+if ($IMAP->list_page > 1 && $nextpage_count <= 0 && $remaining == 0)
 {
   $IMAP->set_page($IMAP->list_page-1);
   $_SESSION['page'] = $IMAP->list_page;
@@ -75,8 +79,6 @@
 }
 
 // update message count display
-$msg_count = $IMAP->messagecount();
-$pages = ceil($msg_count / $IMAP->page_size);
 $OUTPUT->set_env('pagecount', $pages);
 $OUTPUT->set_env('current_page', $IMAP->list_page);
 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
@@ -92,7 +94,7 @@
 $OUTPUT->command('set_quota', $IMAP->get_quota());
 
 // add new rows from next page (if any)
-if ($_POST['_from']!='show' && ($jump_back || $remaining > 0))
+if ($_POST['_from']!='show' && ($jump_back || $nextpage_count > 0))
 {
   $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
   $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];

--
Gitblit v1.9.1