Changeset 2061 in subversion


Ignore:
Timestamp:
Nov 17, 2008 7:21:53 AM (5 years ago)
Author:
alec
Message:
  • optimization: don't set first/last/prev/next uids in preview/print mode
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/steps/mail/show.inc

    r2049 r2061  
    103103  } 
    104104 
    105  
    106   $next = $prev = $first = $last = -1; 
    107105  // get previous, first, next and last message UID 
    108   if ((!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') && 
     106  if ($RCMAIL->action != 'preview' && $RCMAIL->action != 'print') 
     107    { 
     108    $next = $prev = $first = $last = -1; 
     109 
     110    if ((!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') && 
    109111      $IMAP->get_capability('sort')) || !empty($_REQUEST['_search'])) 
    110     { 
    111     // Only if we use custom sorting 
    112     $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); 
    113  
    114     $MESSAGE->index = array_search($IMAP->get_id($MESSAGE->uid), $a_msg_index); 
    115  
    116     $prev = isset($a_msg_index[$MESSAGE->index-1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index-1]) : -1 ; 
    117     $first = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[0]) : -1; 
    118     $next = isset($a_msg_index[$MESSAGE->index+1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index+1]) : -1 ; 
    119     $last = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[count($a_msg_index)-1]) : -1; 
    120     } 
    121   else 
    122     { 
    123     // this assumes that we are sorted by date_DESC 
    124     $seq = $IMAP->get_id($MESSAGE->uid); 
    125     $prev = $IMAP->get_uid($seq + 1); 
    126     $first = $IMAP->get_uid($IMAP->messagecount()); 
    127     $next = $IMAP->get_uid($seq - 1); 
    128     $last = $IMAP->get_uid(1); 
    129     $MESSAGE->index = $IMAP->messagecount() - $seq; 
    130     } 
    131    
    132   if ($prev > 0) 
    133     $OUTPUT->set_env('prev_uid', $prev); 
    134   if ($first > 0) 
    135     $OUTPUT->set_env('first_uid', $first); 
    136   if ($next > 0) 
    137     $OUTPUT->set_env('next_uid', $next); 
    138   if ($last > 0) 
    139     $OUTPUT->set_env('last_uid', $last); 
     112      { 
     113      // Only if we use custom sorting 
     114      $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); 
     115 
     116      $MESSAGE->index = array_search($IMAP->get_id($MESSAGE->uid), $a_msg_index); 
     117 
     118      $prev = isset($a_msg_index[$MESSAGE->index-1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index-1]) : -1 ; 
     119      $first = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[0]) : -1; 
     120      $next = isset($a_msg_index[$MESSAGE->index+1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index+1]) : -1 ; 
     121      $last = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[count($a_msg_index)-1]) : -1; 
     122      } 
     123    else 
     124      { 
     125      // this assumes that we are sorted by date_DESC 
     126      $cnt = $IMAP->messagecount(); 
     127      $seq = $IMAP->get_id($MESSAGE->uid); 
     128      $MESSAGE->index = $cnt - $seq; 
     129 
     130      $prev = $IMAP->get_uid($seq + 1); 
     131      $first = $IMAP->get_uid($cnt); 
     132      $next = $IMAP->get_uid($seq - 1); 
     133      $last = $IMAP->get_uid(1); 
     134      } 
     135 
     136    if ($prev > 0) 
     137      $OUTPUT->set_env('prev_uid', $prev); 
     138    if ($first > 0) 
     139      $OUTPUT->set_env('first_uid', $first); 
     140    if ($next > 0) 
     141      $OUTPUT->set_env('next_uid', $next); 
     142    if ($last > 0) 
     143      $OUTPUT->set_env('last_uid', $last); 
     144    } 
    140145 
    141146  // mark message as read 
Note: See TracChangeset for help on using the changeset viewer.