summaryrefslogtreecommitdiff
path: root/program/steps/mail/show.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-11-17 12:21:53 +0000
committeralecpl <alec@alec.pl>2008-11-17 12:21:53 +0000
commit14d953befcc7e8131bac266611fb1d990f7211bc (patch)
tree5306aff17fd0800c79fd823199cc1b10254033e2 /program/steps/mail/show.inc
parent14de18d5f4636ca86ed8cac4c8c725e07bd2ff79 (diff)
- optimization: don't set first/last/prev/next uids in preview/print mode
Diffstat (limited to 'program/steps/mail/show.inc')
-rw-r--r--program/steps/mail/show.inc65
1 files changed, 35 insertions, 30 deletions
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 15c1c54a6..89da3b11d 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -102,41 +102,46 @@ if ($_GET['_uid']) {
}
}
-
- $next = $prev = $first = $last = -1;
// get previous, first, next and last message UID
- if ((!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') &&
- $IMAP->get_capability('sort')) || !empty($_REQUEST['_search']))
+ if ($RCMAIL->action != 'preview' && $RCMAIL->action != 'print')
{
- // Only if we use custom sorting
- $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']);
+ $next = $prev = $first = $last = -1;
- $MESSAGE->index = array_search($IMAP->get_id($MESSAGE->uid), $a_msg_index);
+ if ((!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') &&
+ $IMAP->get_capability('sort')) || !empty($_REQUEST['_search']))
+ {
+ // Only if we use custom sorting
+ $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']);
- $prev = isset($a_msg_index[$MESSAGE->index-1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index-1]) : -1 ;
- $first = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[0]) : -1;
- $next = isset($a_msg_index[$MESSAGE->index+1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index+1]) : -1 ;
- $last = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[count($a_msg_index)-1]) : -1;
- }
- else
- {
- // this assumes that we are sorted by date_DESC
- $seq = $IMAP->get_id($MESSAGE->uid);
- $prev = $IMAP->get_uid($seq + 1);
- $first = $IMAP->get_uid($IMAP->messagecount());
- $next = $IMAP->get_uid($seq - 1);
- $last = $IMAP->get_uid(1);
- $MESSAGE->index = $IMAP->messagecount() - $seq;
+ $MESSAGE->index = array_search($IMAP->get_id($MESSAGE->uid), $a_msg_index);
+
+ $prev = isset($a_msg_index[$MESSAGE->index-1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index-1]) : -1 ;
+ $first = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[0]) : -1;
+ $next = isset($a_msg_index[$MESSAGE->index+1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index+1]) : -1 ;
+ $last = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[count($a_msg_index)-1]) : -1;
+ }
+ else
+ {
+ // this assumes that we are sorted by date_DESC
+ $cnt = $IMAP->messagecount();
+ $seq = $IMAP->get_id($MESSAGE->uid);
+ $MESSAGE->index = $cnt - $seq;
+
+ $prev = $IMAP->get_uid($seq + 1);
+ $first = $IMAP->get_uid($cnt);
+ $next = $IMAP->get_uid($seq - 1);
+ $last = $IMAP->get_uid(1);
+ }
+
+ if ($prev > 0)
+ $OUTPUT->set_env('prev_uid', $prev);
+ if ($first > 0)
+ $OUTPUT->set_env('first_uid', $first);
+ if ($next > 0)
+ $OUTPUT->set_env('next_uid', $next);
+ if ($last > 0)
+ $OUTPUT->set_env('last_uid', $last);
}
-
- if ($prev > 0)
- $OUTPUT->set_env('prev_uid', $prev);
- if ($first > 0)
- $OUTPUT->set_env('first_uid', $first);
- if ($next > 0)
- $OUTPUT->set_env('next_uid', $next);
- if ($last > 0)
- $OUTPUT->set_env('last_uid', $last);
// mark message as read
if (!$MESSAGE->headers->seen)