Changeset 2052 in subversion


Ignore:
Timestamp:
Nov 14, 2008 6:18:00 AM (5 years ago)
Author:
alec
Message:
  • fixes for status filter
  • don't call search second time if first call returns empty (array) result
Location:
trunk/roundcubemail/program
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcube_imap.php

    r2049 r2052  
    289289  function set_search_set($str=null, $msgs=null, $charset=null, $sort_field=null) 
    290290    { 
    291     if ($msgs == null) 
     291    if (is_array($str) && $msgs == null) 
    292292      list($str, $msgs, $charset, $sort_field) = $str; 
    293293    if ($msgs != null && !is_array($msgs)) 
     
    924924  function search($mbox_name='', $str=NULL, $charset=NULL, $sort_field=NULL) 
    925925    { 
     926    if (!$str) 
     927      return false; 
     928     
    926929    $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; 
    927930 
     
    929932 
    930933    // try search with ISO charset (should be supported by server) 
    931     if (empty($results) && !empty($charset) && $charset!='ISO-8859-1') 
     934    // only if UTF-8 search is not supported 
     935    if (empty($results) && !is_array($results) && !empty($charset) && $charset!='ISO-8859-1') 
    932936      { 
    933937        // convert strings to ISO-8859-1 
  • trunk/roundcubemail/program/lib/imap.inc

    r2046 r2052  
    942942        } while (!iil_StartsWith($line, 's ', true)); 
    943943         
    944         if (empty($data)) { 
    945                 $conn->error = $line; 
    946                 return false; 
     944        $result_code = iil_ParseResult($line); 
     945         
     946        if ($result_code != 0) { 
     947                $conn->error = 'iil_C_Sort: ' . $line . "\n"; 
     948                return false; 
    947949        } 
    948950         
     
    21172119                        } 
    21182120                } while (!iil_StartsWith($line, 'srch1', true)); 
    2119                  
     2121 
    21202122                $result_code = iil_ParseResult($line); 
    21212123                if ($result_code == 0) { 
  • trunk/roundcubemail/program/steps/mail/search.inc

    r2049 r2052  
    8686 
    8787// execute IMAP search 
    88 $result = $IMAP->search($mbox, $search_str, $imap_charset, $_SESSION['sort_col']); 
    89 $count = 0; 
     88if ($search_str) 
     89  $result = $IMAP->search($mbox, $search_str, $imap_charset, $_SESSION['sort_col']); 
    9090 
    91 // Make sure our $result is legit.. 
    92 if (is_array($result) && $result[0] != '') 
     91// Get the headers 
     92$result_h = $IMAP->list_headers($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); 
     93$count = $IMAP->messagecount(); 
     94 
     95// save search results in session 
     96if (!is_array($_SESSION['search'])) 
     97  $_SESSION['search'] = array(); 
     98 
     99// Make sure we got the headers 
     100if (!empty($result_h)) 
    93101{ 
    94   // Get the headers 
    95   $result_h = $IMAP->list_headers($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); 
    96   $count = $IMAP->messagecount(); 
    97  
    98   // save search results in session 
    99   if (!is_array($_SESSION['search'])) 
    100     $_SESSION['search'] = array(); 
    101  
    102   // Make sure we got the headers 
    103   if ($result_h != NULL) 
    104   { 
     102  if ($search_str) { 
    105103    $_SESSION['search'][$search_request] = $IMAP->get_search_set(); 
    106104    $_SESSION['last_text_search'] = $str; 
    107     rcmail_js_message_list($result_h); 
    108     $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); 
    109105  } 
     106  rcmail_js_message_list($result_h); 
     107  $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); 
    110108} 
    111109else 
    112110{ 
    113111  $OUTPUT->show_message('searchnomatch', 'notice'); 
    114   $search_request = -1; 
    115112} 
    116113 
    117114// update message count display 
    118 $pages = ceil($count/$IMAP->page_size); 
    119 $OUTPUT->set_env('search_request', $search_request); 
     115$OUTPUT->set_env('search_request', $search_str ? $search_request : -1); 
    120116$OUTPUT->set_env('messagecount', $count); 
    121 $OUTPUT->set_env('pagecount', $pages); 
     117$OUTPUT->set_env('pagecount', ceil($count/$IMAP->page_size)); 
    122118$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count, 1)); 
    123119$OUTPUT->send(); 
Note: See TracChangeset for help on using the changeset viewer.