diff options
author | alecpl <alec@alec.pl> | 2008-11-14 11:18:00 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2008-11-14 11:18:00 +0000 |
commit | 697cc52cff43176edb809a0cba723ca4a27ba47d (patch) | |
tree | 36b7960df414e8f3cdd35e1ef1cefb6665adcad5 | |
parent | 8abda59ce499bc0a68c15e225cae6df9702457f5 (diff) |
- fixes for status filter
- don't call search second time if first call returns empty (array) result
-rw-r--r-- | program/include/rcube_imap.php | 8 | ||||
-rw-r--r-- | program/lib/imap.inc | 10 | ||||
-rw-r--r-- | program/steps/mail/search.inc | 36 |
3 files changed, 28 insertions, 26 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 765778a20..1617be3ad 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -288,7 +288,7 @@ class rcube_imap */ function set_search_set($str=null, $msgs=null, $charset=null, $sort_field=null) { - if ($msgs == null) + if (is_array($str) && $msgs == null) list($str, $msgs, $charset, $sort_field) = $str; if ($msgs != null && !is_array($msgs)) $msgs = split(',', $msgs); @@ -923,12 +923,16 @@ class rcube_imap */ function search($mbox_name='', $str=NULL, $charset=NULL, $sort_field=NULL) { + if (!$str) + return false; + $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; $results = $this->_search_index($mailbox, $str, $charset, $sort_field); // try search with ISO charset (should be supported by server) - if (empty($results) && !empty($charset) && $charset!='ISO-8859-1') + // only if UTF-8 search is not supported + if (empty($results) && !is_array($results) && !empty($charset) && $charset!='ISO-8859-1') { // convert strings to ISO-8859-1 if(preg_match_all('/\{([0-9]+)\}\r\n/', $str, $matches, PREG_OFFSET_CAPTURE)) diff --git a/program/lib/imap.inc b/program/lib/imap.inc index 8cbb0e02b..8704e78f5 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -941,9 +941,11 @@ function iil_C_Sort(&$conn, $mailbox, $field, $add='', $is_uid=FALSE, } } while (!iil_StartsWith($line, 's ', true)); - if (empty($data)) { - $conn->error = $line; - return false; + $result_code = iil_ParseResult($line); + + if ($result_code != 0) { + $conn->error = 'iil_C_Sort: ' . $line . "\n"; + return false; } $out = explode(' ',$data); @@ -2116,7 +2118,7 @@ function iil_C_Search(&$conn, $folder, $criteria) { $messages = explode(' ', $str); } } while (!iil_StartsWith($line, 'srch1', true)); - + $result_code = iil_ParseResult($line); if ($result_code == 0) { return $messages; diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc index 18335ba15..0fc56bcf0 100644 --- a/program/steps/mail/search.inc +++ b/program/steps/mail/search.inc @@ -85,40 +85,36 @@ else if ($subject) { $search_str = trim($search_str); // execute IMAP search -$result = $IMAP->search($mbox, $search_str, $imap_charset, $_SESSION['sort_col']); -$count = 0; +if ($search_str) + $result = $IMAP->search($mbox, $search_str, $imap_charset, $_SESSION['sort_col']); -// Make sure our $result is legit.. -if (is_array($result) && $result[0] != '') -{ - // Get the headers - $result_h = $IMAP->list_headers($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); - $count = $IMAP->messagecount(); +// Get the headers +$result_h = $IMAP->list_headers($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); +$count = $IMAP->messagecount(); - // save search results in session - if (!is_array($_SESSION['search'])) - $_SESSION['search'] = array(); +// save search results in session +if (!is_array($_SESSION['search'])) + $_SESSION['search'] = array(); - // Make sure we got the headers - if ($result_h != NULL) - { +// Make sure we got the headers +if (!empty($result_h)) +{ + if ($search_str) { $_SESSION['search'][$search_request] = $IMAP->get_search_set(); $_SESSION['last_text_search'] = $str; - rcmail_js_message_list($result_h); - $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); } + rcmail_js_message_list($result_h); + $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); } else { $OUTPUT->show_message('searchnomatch', 'notice'); - $search_request = -1; } // update message count display -$pages = ceil($count/$IMAP->page_size); -$OUTPUT->set_env('search_request', $search_request); +$OUTPUT->set_env('search_request', $search_str ? $search_request : -1); $OUTPUT->set_env('messagecount', $count); -$OUTPUT->set_env('pagecount', $pages); +$OUTPUT->set_env('pagecount', ceil($count/$IMAP->page_size)); $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count, 1)); $OUTPUT->send(); |