From: alex-brainstorm Date: Tue, 4 Nov 2003 00:48:45 +0000 (+0000) Subject: Workaround for EIMS split response to SEARCH X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=75d24fd2e95a9ad8bc0abf20a3f9c54f7f3dc6b0;p=squirrelmail.git Workaround for EIMS split response to SEARCH git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6091 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/imap_asearch.php b/functions/imap_asearch.php index d1c5edfe..6c0cc5a3 100644 --- a/functions/imap_asearch.php +++ b/functions/imap_asearch.php @@ -245,6 +245,19 @@ function sqimap_asearch_build_criteria($opcode, $what, $charset) return $criteria; } +// equivalent to : $to = array_values(array_unique(array_merge($to, $from))); +function sqimap_array_merge_unique($to, $from) +{ + if (empty($to)) + return $from; + $count = count($from); + for ($i = 0; $i < $count; $i++) { + if (!in_array($from[$i], $to)) + $to[] = $from[$i]; + } + return $to; +} + function sqimap_run_search($imapConnection, $search_string, $search_charset) { global $uid_support; @@ -270,28 +283,17 @@ function sqimap_run_search($imapConnection, $search_string, $search_charset) unset($messagelist); - /* Keep going till we find the * SEARCH response */ + // Keep going till we find the * SEARCH response foreach ($readin as $readin_part) { s_debug_dump('S:', $readin_part); if (substr($readin_part, 0, 9) == '* SEARCH ') { - $messagelist = preg_split("/ /", substr($readin_part, 9)); - break; // Should be the last anyway + //workaround for an EIMS singularity (to say the least) + //$messagelist = preg_split("/ /", substr($readin_part, 9)); + //break; //this should be the last anyway + $messagelist = sqimap_array_merge_unique($message_list, preg_split("/ /", substr($readin_part, 9))); } -/* else { - if (isset($errors)) - $errors = $errors . $readin_part; - else - $errors = $readin_part; - }*/ } - /* If nothing is found * SEARCH should be the first error else echo errors */ -/*if (isset($errors)) { - if (strstr($errors,'* SEARCH')) - return array(); - echo ''; - }*/ - if (empty($messagelist)) //Empty search response, ie '* SEARCH' return array(); @@ -319,9 +321,9 @@ function sqimap_run_sort($imapConnection, $search_string, $search_charset, $sort } if (strtoupper($response) != 'OK') { -// sqimap_asearch_error_box($response, $query, $message); -// return array(); - return sqimap_run_search($imapConnection, $search_string, $search_charset); // Fell back to standard search +// sqimap_asearch_error_box($response, $query, $message); +// return array(); + return sqimap_run_search($imapConnection, $search_string, $search_charset); // Fell back to standard search } /* Keep going till we find the * SORT response */ @@ -372,6 +374,11 @@ function sqimap_run_thread($imapConnection, $search_string, $search_charset, $th } if (strtoupper($response) != 'OK') { +/* we should at this point: + - warn the user that the THREAD call has failed + - (offer him a way to) disconnect it permanently in the prefs + - perform the regular search instead or provide a way to do it in one click +*/ // sqimap_asearch_error_box($response, $query, $message); // return array(); return sqimap_run_search($imapConnection, $search_string, $search_charset); // Fell back to standard search @@ -447,18 +454,6 @@ function sqimap_asearch_get_sort_criteria($mailbox, $sort_by) return (($sort_by % 2) ? '' : 'REVERSE ') . $sort_opcodes[$sort_by >> 1]; } -/* replaces $mbox_msgs[$search_mailbox] = array_values(array_unique(array_merge($mbox_msgs[$search_mailbox], sqimap_run_search($imapConnection, $search_string, $search_charset))));*/ -function sqimap_array_merge_unique($to, $from) -{ - if (empty($to)) - return $from; - for ($i=0; $i