Added 'contact_search_name' option to define autocompletion entry format
| | |
| | | CHANGELOG Roundcube Webmail |
| | | =========================== |
| | | |
| | | - Added 'contact_search_name' option to define autocompletion entry format |
| | | - Display quota information for current folder not INBOX only (#1487993) |
| | | - Support images in HTML signatures (#1488676) |
| | | - Display full quota information in popup (#1485769, #1486604) |
| | |
| | | // Note: For LDAP sources fuzzy_search must be enabled to use 'partial' or 'prefix' mode |
| | | $config['addressbook_search_mode'] = 0; |
| | | |
| | | // Template of contact entry on the autocompletion list. |
| | | // You can use contact fields as: name, email, organization, department, etc. |
| | | // See program/steps/addressbook/func.inc for a list |
| | | $config['contact_search_name'] = '{name} <{email}>'; |
| | | |
| | | // ---------------------------------- |
| | | // USER PREFERENCES |
| | | // ---------------------------------- |
| | |
| | | // add each result line to list |
| | | if (results && (len = results.length)) { |
| | | for (i=0; i < len && maxlen > 0; i++) { |
| | | text = typeof results[i] === 'object' ? results[i].name : results[i]; |
| | | text = typeof results[i] === 'object' ? (results[i].display || results[i].name) : results[i]; |
| | | type = typeof results[i] === 'object' ? results[i].type : ''; |
| | | id = i + this.env.contacts.length; |
| | | $('<li>').attr('id', 'rcmkSearchItem' + id) |
| | |
| | | } |
| | | |
| | | /** |
| | | * Build contact display name for autocomplete listing |
| | | * |
| | | * @param array Hash array with contact data as key-value pairs |
| | | * @param string Optional email address |
| | | * @param string Optional name (self::compose_list_name() result) |
| | | * |
| | | * @return string Display name |
| | | */ |
| | | public static function compose_search_name($contact, $email = null, $name = null) |
| | | { |
| | | static $template; |
| | | |
| | | if (!isset($template)) { // cache this |
| | | $template = rcube::get_instance()->config->get('contact_search_name'); |
| | | if (empty($template)) { |
| | | $template = '{name} <{email}>'; |
| | | } |
| | | } |
| | | |
| | | $result = $template; |
| | | |
| | | if (preg_match_all('/\{[a-z]+\}/', $result, $matches)) { |
| | | foreach ($matches[0] as $key) { |
| | | $key = trim($key, '{}'); |
| | | |
| | | switch ($key) { |
| | | case 'name': |
| | | $value = $name ?: self::compose_list_name($contact); |
| | | break; |
| | | |
| | | case 'email': |
| | | $value = $email; |
| | | break; |
| | | } |
| | | |
| | | if (empty($value)) { |
| | | $value = strpos($key, ':') ? $contact[$key] : self::get_col_values($key, $contact, true); |
| | | if (is_array($value)) { |
| | | $value = $value[0]; |
| | | } |
| | | } |
| | | |
| | | $result = str_replace('{' . $key . '}', $value, $result); |
| | | } |
| | | } |
| | | |
| | | $result = preg_replace('/\s+/', ' ', $result); |
| | | $result = trim($result); |
| | | |
| | | return $result; |
| | | } |
| | | |
| | | /** |
| | | * Create a unique key for sorting contacts |
| | | */ |
| | | public static function compose_contact_key($contact, $sort_col) |
| | |
| | | |
| | | // skip duplicates |
| | | if (!in_array($contact, $contacts)) { |
| | | $contacts[] = array('name' => $contact, 'type' => $sql_arr['_type']); |
| | | $sort_keys[] = sprintf('%s %03d', $sql_arr['name'] , $idx++); |
| | | $contact = array('name' => $contact, 'type' => $sql_arr['_type']); |
| | | |
| | | if (($display = rcube_addressbook::compose_search_name($sql_arr, $email, $name)) && $display != $contact['name']) { |
| | | $contact['display'] = $display; |
| | | } |
| | | |
| | | $contacts[] = $contact; |
| | | $sort_keys[] = sprintf('%s %03d', $contact['display'] ?: $name, $idx++); |
| | | |
| | | if (count($contacts) >= $MAXNUM) { |
| | | break 2; |