Revision: 556
http://hastymail.svn.sourceforge.net/hastymail/?rev=556&view=rev
Author: sailfrog
Date: 2008-09-02 00:47:31 +0000 (Tue, 02 Sep 2008)
Log Message:
-----------
little fix for reported problem with loading a mailbox page that has no messages (after deleting all of the last page for example).
Modified Paths:
--------------
trunk/hastymail2/lib/url_action_class.php
Modified: trunk/hastymail2/lib/url_action_class.php
===================================================================
--- trunk/hastymail2/lib/url_action_class.php 2008-09-02 00:22:03 UTC (rev 555)
+++ trunk/hastymail2/lib/url_action_class.php 2008-09-02 00:47:31 UTC (rev 556)
@@ -735,13 +735,13 @@
else {
$user->page_data['toggle_all'] = 0;
}
- $uids = $this->build_page_uids($mailbox, $page, $user->page_data['settings']['mailbox_per_page_count'], $_SESSION['uid_cache'][$mailbox]['uids']);
+ list($page, $uids) = $this->build_page_uids($mailbox, $page, $user->page_data['settings']['mailbox_per_page_count'], $_SESSION['uid_cache'][$mailbox]['uids']);
$total = $_SESSION['uid_cache'][$mailbox]['total'];
$user->page_data['mailbox_page'] = $page;
if (!empty($uids)) {
/*if (!empty($_SESSION['uid_cache'][$mailbox]['thread_data'])) {
$total = count($_SESSION['uid_cache'][$mailbox]['threads']);
- $uids = $this->build_page_uids($mailbox, $page, $user->page_data['settings']['mailbox_per_page_count'], $_SESSION['uid_cache'][$mailbox]['threads']);
+ list($page, $uids) = $this->build_page_uids($mailbox, $page, $user->page_data['settings']['mailbox_per_page_count'], $_SESSION['uid_cache'][$mailbox]['threads']);
}*/
$user->page_data['header_list'] = $imap->get_mailbox_page($mailbox, $uids, $page);
$user->page_data['page_count'] = count($user->page_data['header_list']);
@@ -2122,7 +2122,7 @@
$_SESSION['user_settings'] = $user->page_data['settings'];
}
}
-function build_page_uids($mailbox, $page, $per_page_count, $uids) {
+function build_page_uids($mailbox, $page, $per_page_count, $uids, $break=false) {
$res = array();
$start = ($page - 1)*$per_page_count;
if ($start < 0) {
@@ -2131,7 +2131,13 @@
if (isset($uids[$start])) {
$res = array_slice($uids, $start, $per_page_count);
}
- return $res;
+ elseif (!$break && !empty($uids)) {
+ $max_page = ceil(count($uids)/$per_page_count);
+ if ($max_page < $page && $max_page > 0) {
+ return $this->build_page_uids($mailbox, $max_page, $per_page_count, $uids, true);
+ }
+ }
+ return array($page, $res);
}
function find_message_part($struct, $part, $type='text', $subtype=false) {
$res = array();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|