summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/mail/func.inc2
-rw-r--r--program/steps/mail/pagenav.inc51
-rw-r--r--program/steps/mail/search.inc10
-rw-r--r--program/steps/mail/sendmail.inc12
4 files changed, 27 insertions, 48 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index a1db45ec2..7e3a86cb5 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -93,7 +93,7 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
$_SESSION['search'] = $IMAP->get_search_set();
$_SESSION['search_request'] = $search_request;
$OUTPUT->set_env('search_request', $search_request);
- }
+ }
$search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT);
$OUTPUT->set_env('search_mods', $search_mods);
diff --git a/program/steps/mail/pagenav.inc b/program/steps/mail/pagenav.inc
index 974b3b46f..16844f4e1 100644
--- a/program/steps/mail/pagenav.inc
+++ b/program/steps/mail/pagenav.inc
@@ -19,52 +19,29 @@
*/
-$uid = get_input_value('_uid', RCUBE_INPUT_GET);
-
-// Select mailbox first, for better performance
-$mbox_name = $IMAP->get_mailbox_name();
-$IMAP->select_mailbox($mbox_name);
-
-// Get messages count (only messages, no threads here)
-$cnt = $IMAP->messagecount(NULL, 'ALL');
-
-if ($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC'
- && empty($_REQUEST['_search']) && !$CONFIG['skip_deleted'] && !$IMAP->threading
-) {
- // this assumes that we are sorted by date_DESC
- $seq = $IMAP->get_id($uid);
- $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);
-}
-else {
- // Only if we use custom sorting
- $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']);
-
- $index = array_search($IMAP->get_id($uid), $a_msg_index);
-
- $count = count($a_msg_index);
- $prev = isset($a_msg_index[$index-1]) ? $IMAP->get_uid($a_msg_index[$index-1]) : -1;
- $first = $count > 1 ? $IMAP->get_uid($a_msg_index[0]) : -1;
- $next = isset($a_msg_index[$index+1]) ? $IMAP->get_uid($a_msg_index[$index+1]) : -1;
- $last = $count > 1 ? $IMAP->get_uid($a_msg_index[$count-1]) : -1;
+$uid = get_input_value('_uid', RCUBE_INPUT_GET);
+$index = $IMAP->message_index(null, $_SESSION['sort_col'], $_SESSION['sort_order']);
+$cnt = $index->countMessages();
+
+if ($cnt && ($pos = $index->exists($uid, true)) !== false) {
+ $prev = $pos ? $index->getElement($pos-1) : 0;
+ $first = $pos ? $index->getElement('FIRST') : 0;
+ $next = $pos < $cnt-1 ? $index->getElement($pos+1) : 0;
+ $last = $pos < $cnt-1 ? $index->getElement('LAST') : 0;
}
// Set UIDs and activate navigation buttons
-if ($prev > 0) {
+if ($prev) {
$OUTPUT->set_env('prev_uid', $prev);
$OUTPUT->command('enable_command', 'previousmessage', 'firstmessage', true);
}
-if ($next > 0) {
+if ($next) {
$OUTPUT->set_env('next_uid', $next);
$OUTPUT->command('enable_command', 'nextmessage', 'lastmessage', true);
}
-if ($first > 0)
+if ($first)
$OUTPUT->set_env('first_uid', $first);
-if ($last > 0)
+if ($last)
$OUTPUT->set_env('last_uid', $last);
// Don't need a real messages count value
@@ -73,7 +50,7 @@ $OUTPUT->set_env('messagecount', 1);
// Set rowcount text
$OUTPUT->command('set_rowcount', rcube_label(array(
'name' => 'messagenrof',
- 'vars' => array('nr' => $index+1, 'count' => $cnt)
+ 'vars' => array('nr' => $pos+1, 'count' => $cnt)
)));
$OUTPUT->send();
diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
index 49f31e0c1..05ba9d23e 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -109,10 +109,6 @@ $search_str = trim($search_str);
if ($search_str)
$IMAP->search($mbox, $search_str, $imap_charset, $_SESSION['sort_col']);
-// Get the headers
-$result_h = $IMAP->list_headers($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']);
-$count = $IMAP->messagecount(NULL, $IMAP->threading ? 'THREADS' : 'ALL');
-
// save search results in session
if (!is_array($_SESSION['search']))
$_SESSION['search'] = array();
@@ -123,6 +119,12 @@ if ($search_str) {
}
$_SESSION['search_request'] = $search_request;
+
+// Get the headers
+$result_h = $IMAP->list_headers($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']);
+$count = $IMAP->messagecount($mbox, $IMAP->threading ? 'THREADS' : 'ALL');
+
+
// Make sure we got the headers
if (!empty($result_h)) {
rcmail_js_message_list($result_h);
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 64deb73d8..0da1ee342 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -701,11 +701,11 @@ if ($store_target) {
if ($olddraftmessageid) {
// delete previous saved draft
// @TODO: use message UID (remember to check UIDVALIDITY) to skip this SEARCH
- $a_deleteid = $IMAP->search_once($CONFIG['drafts_mbox'],
- 'HEADER Message-ID '.$olddraftmessageid, true);
+ $delete_idx = $IMAP->search_once($CONFIG['drafts_mbox'],
+ 'HEADER Message-ID '.$olddraftmessageid);
- if (!empty($a_deleteid)) {
- $deleted = $IMAP->delete_message($a_deleteid, $CONFIG['drafts_mbox']);
+ if ($del_uid = $delete_idx->getElement('FIRST')) {
+ $deleted = $IMAP->delete_message($del_uid, $CONFIG['drafts_mbox']);
// raise error if deletion of old draft failed
if (!$deleted)
@@ -726,8 +726,8 @@ if ($savedraft) {
// remember new draft-uid ($saved could be an UID or TRUE here)
if (is_bool($saved)) {
- $draftuids = $IMAP->search_once($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid, true);
- $saved = $draftuids[0];
+ $draft_idx = $IMAP->search_once($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid);
+ $saved = $draft_idx->getElement('FIRST');
}
$COMPOSE['param']['draft_uid'] = $saved;