Changeset 3715 in subversion


Ignore:
Timestamp:
Jun 4, 2010 7:51:50 AM (3 years ago)
Author:
alec
Message:
  • Remove duplicates in autocomplete result (#1486772)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/steps/mail/autocomplete.inc

    r3609 r3715  
    3838else if ($book_types && $search = get_input_value('_search', RCUBE_INPUT_GPC, true)) { 
    3939  $contacts = array(); 
     40  $books_num = count($book_types); 
    4041 
    4142  foreach ($book_types as $id) { 
     
    4546    if ($result = $abook->search(array('email','name'), $search, false, true, true, 'email')) { 
    4647      while ($sql_arr = $result->iterate()) { 
    47           $contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']); 
     48        $contact = format_email_recipient($sql_arr['email'], $sql_arr['name']); 
     49        // when we've got more than one book, we need to skip duplicates 
     50        if ($books_num == 1 || !in_array($contact, $contacts)) { 
     51          $contacts[] = $contact; 
    4852          if (count($contacts) >= $MAXNUM) 
    4953            break 2; 
     54        } 
    5055      } 
    5156    } 
Note: See TracChangeset for help on using the changeset viewer.