Changeset e0c9741 in github


Ignore:
Timestamp:
Nov 7, 2008 9:32:16 AM (5 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
47369b2
Parents:
68af648
Message:
  • improve messages searching with many criterias (call one SEARCH command)
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r68af648 re0c9741  
    55---------- 
    66- Fix empty file sending (#1485389) 
     7- Improved searching with many criterias (calling one SEARCH command) 
    78 
    892008/11/05 (alec) 
  • program/include/rcube_imap.php

    r8498dce re0c9741  
    286286   * @param  array  List of message ids or NULL if empty 
    287287   */ 
    288   function set_search_set($subject, $str=null, $msgs=null, $charset=null) 
     288  function set_search_set($subject, $str=null, $msgs=null, $charset=null, $sorted=null) 
    289289    { 
    290290    if (is_array($subject) && $str == null && $msgs == null) 
    291       list($subject, $str, $msgs, $charset) = $subject; 
     291      list($subject, $str, $msgs, $charset, $sorted) = $subject; 
    292292    if ($msgs != null && !is_array($msgs)) 
    293293      $msgs = split(',', $msgs); 
     
    901901    { 
    902902    $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; 
    903  
    904     // have an array of criterias => execute multiple searches 
    905     if (is_array($criteria) && $str) 
    906       { 
    907       $results = array(); 
    908       foreach ($criteria as $crit) 
    909         if ($search_result = $this->search($mbox_name, $crit, $str, $charset)) 
    910           $results = array_merge($results, $search_result); 
    911        
    912       $results = array_unique($results); 
    913       $this->set_search_set($criteria, $str, $results, $charset); 
    914       return $results; 
    915       } 
    916     else if ($str && $criteria) 
    917       { 
    918       $search = (!empty($charset) ? "CHARSET $charset " : '') . sprintf("%s {%d}\r\n%s", $criteria, strlen($str), $str); 
    919       $results = $this->_search_index($mailbox, $search); 
    920  
    921       // try search with ISO charset (should be supported by server) 
    922       if (empty($results) && !empty($charset) && $charset!='ISO-8859-1') 
    923         $results = $this->search($mbox_name, $criteria, rcube_charset_convert($str, $charset, 'ISO-8859-1'), 'ISO-8859-1'); 
    924        
    925       $this->set_search_set($criteria, $str, $results, $charset); 
    926       return $results; 
    927       } 
    928     else 
    929       return $this->_search_index($mailbox, $criteria); 
     903    $search = ''; 
     904 
     905    // have an array of criterias => create search string 
     906    if (is_array($criteria)) 
     907      $search .= 'OR'; 
     908 
     909    $criteria = (array) $criteria; 
     910    foreach($criteria as $idx => $crit) 
     911      if ($str) 
     912        $search .= sprintf(" (%s {%d}\r\n%s)", $crit, strlen($str), $str); 
     913      else 
     914        $search .= '('. $crit .')'; 
     915 
     916    $results = $this->_search_index($mailbox, (!empty($charset) ? "CHARSET $charset " : '') . $search); 
     917 
     918    // try search with ISO charset (should be supported by server) 
     919    if (empty($results) && !empty($charset) && $charset!='ISO-8859-1') 
     920      $results = $this->search($mbox_name, $criteria, rcube_charset_convert($str, $charset, 'ISO-8859-1'), 'ISO-8859-1'); 
     921 
     922    $this->set_search_set($criteria, $str, $results, $charset); 
     923    return $results; 
    930924    }     
    931925 
     
    941935    { 
    942936    $a_messages = iil_C_Search($this->conn, $mailbox, $criteria); 
     937 
    943938    // clean message list (there might be some empty entries) 
    944939    if (is_array($a_messages)) 
Note: See TracChangeset for help on using the changeset viewer.