diff options
-rw-r--r-- | program/include/rcube_imap.php | 13 | ||||
-rw-r--r-- | program/steps/mail/mark.inc | 7 | ||||
-rw-r--r-- | program/steps/mail/move_del.inc | 8 |
3 files changed, 15 insertions, 13 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 9b8d7d056..5bd3542d1 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -537,13 +537,14 @@ class rcube_imap * @param int Current page to list * @param string Header field to sort by * @param string Sort order [ASC|DESC] + * @param boolean Number of slice items to extract from result array * @return array Indexed array with message header objects * @access public */ - function list_headers($mbox_name='', $page=NULL, $sort_field=NULL, $sort_order=NULL) + function list_headers($mbox_name='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0) { $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; - return $this->_list_headers($mailbox, $page, $sort_field, $sort_order); + return $this->_list_headers($mailbox, $page, $sort_field, $sort_order, false, $slice); } @@ -553,7 +554,7 @@ class rcube_imap * @access private * @see rcube_imap::list_headers */ - private function _list_headers($mailbox='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $recursive=FALSE) + private function _list_headers($mailbox='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $recursive=FALSE, $slice=0) { if (!strlen($mailbox)) return array(); @@ -591,6 +592,9 @@ class rcube_imap $max = max($msg_index); $msg_index = array_slice($msg_index, $begin, $end-$begin); + if ($slice) + $msg_index = array_slice($msg_index, ($this->sort_order == 'DESC' ? 0 : -$slice), $slice); + // fetch reqested headers from server $this->_fetch_headers($mailbox, join(',', $msg_index), $a_msg_headers, $cache_key); } @@ -607,6 +611,9 @@ class rcube_imap list($begin, $end) = $this->_get_message_range(count($msg_index), $page); $msg_index = array_slice($msg_index, $begin, $end-$begin); + if ($slice) + $msg_index = array_slice($msg_index, ($this->sort_order == 'DESC' ? 0 : -$slice), $slice); + // fetch reqested headers from server $this->_fetch_headers($mailbox, join(",", $msg_index), $a_msg_headers, $cache_key); } diff --git a/program/steps/mail/mark.inc b/program/steps/mail/mark.inc index 6a8a3ca90..b5ba4af33 100644 --- a/program/steps/mail/mark.inc +++ b/program/steps/mail/mark.inc @@ -100,12 +100,9 @@ if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_va $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']; - $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order); - if (!$jump_back) { - $a_headers = array_slice($a_headers, -$count, $count); - } + $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order, $count); - rcmail_js_message_list($a_headers, false, false); + rcmail_js_message_list($a_headers, false, false); } } } diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc index df7bef981..d22cd35bd 100644 --- a/program/steps/mail/move_del.inc +++ b/program/steps/mail/move_del.inc @@ -115,11 +115,9 @@ else if ($addrows && ($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']; - - $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order); - if (!$jump_back) { - $a_headers = array_slice($a_headers, -$count, $count); - } + + $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order, $count); + rcmail_js_message_list($a_headers, false, false); } } |