[Svn] r3715 - trunk/roundcubemail/program/steps/mail

trac at roundcube.net trac at roundcube.net
Fri Jun 4 13:51:50 CEST 2010


Author: alec
Date: 2010-06-04 06:51:50 -0500 (Fri, 04 Jun 2010)
New Revision: 3715

Modified:
   trunk/roundcubemail/program/steps/mail/autocomplete.inc
Log:
- Remove duplicates in autocomplete result (#1486772)


Modified: trunk/roundcubemail/program/steps/mail/autocomplete.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/autocomplete.inc	2010-06-04 11:05:59 UTC (rev 3714)
+++ trunk/roundcubemail/program/steps/mail/autocomplete.inc	2010-06-04 11:51:50 UTC (rev 3715)
@@ -37,6 +37,7 @@
 }
 else if ($book_types && $search = get_input_value('_search', RCUBE_INPUT_GPC, true)) {
   $contacts = array();
+  $books_num = count($book_types);
 
   foreach ($book_types as $id) {
     $abook = $RCMAIL->get_address_book($id);
@@ -44,9 +45,13 @@
 
     if ($result = $abook->search(array('email','name'), $search, false, true, true, 'email')) {
       while ($sql_arr = $result->iterate()) {
-          $contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
+        $contact = format_email_recipient($sql_arr['email'], $sql_arr['name']);
+        // when we've got more than one book, we need to skip duplicates
+        if ($books_num == 1 || !in_array($contact, $contacts)) {
+          $contacts[] = $contact;
           if (count($contacts) >= $MAXNUM)
             break 2;
+        }
       }
     }
 

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list