diff -urN ../roundcubemail-1.3.3.orig/config/defaults.inc.php ./config/defaults.inc.php --- ../roundcubemail-1.3.3.orig/config/defaults.inc.php 2017-11-08 20:42:03.000000000 +0200 +++ ./config/defaults.inc.php 2018-02-04 20:57:23.271937000 +0200 @@ -1021,6 +1021,13 @@ // See program/steps/addressbook/func.inc for a list $config['contact_search_name'] = '{name} <{email}>'; +// Template of contact entry on the left pane contacts list. +// You can use contact fields as: email, name, firstname, surname, nickname, +// organization, department, jobtitle, address:work, address:home, +// phone:mobile, phone:work, phone:work2, phone:home, phone:home2 +//$config['contact_search_left_pane_name'] = '{name} <{email}>'; +$config['contact_search_left_pane_name'] = ''; + // ---------------------------------- // USER PREFERENCES // ---------------------------------- diff -urN ../roundcubemail-1.3.3.orig/program/steps/mail/search_contacts.inc ./program/steps/mail/search_contacts.inc --- ../roundcubemail-1.3.3.orig/program/steps/mail/search_contacts.inc 2017-11-08 20:42:05.000000000 +0200 +++ ./program/steps/mail/search_contacts.inc 2018-02-04 22:52:34.628954000 +0200 @@ -88,8 +88,32 @@ $jsresult[$row_id] = format_email_recipient($email, $name); $title = rcube_addressbook::compose_search_name($row, $email, $name); + $display_name = rcube::get_instance()->config->get('contact_search_left_pane_name'); + if (empty($display_name)) { + $display_name = ($name ?: $email); + } else { + if ($name and (count($emails) > 1)) $display_name = str_replace('{email}', '', $display_name); + + $display_name = str_replace('{name}', $name, $display_name); + $display_name = str_replace('{email}', $email, $display_name); + + if (preg_match_all('/\{[a-z:]+\}/', $display_name, $matches)) { + foreach ($matches[0] as $key) { + $key = trim($key, '{}'); + $value = ((isset($row[$key])) ? $row[$key] : ''); + if (is_array($value)) $value = $value[0]; + if (is_array($value)) $value = implode(', ', $value); + $display_name = str_replace('{' . $key . '}', $value, $display_name); + } + } + + $display_name = preg_replace('/\s+/', ' ', $display_name); + $display_name = preg_replace('/\s*(<>|\(\)|\[\])/', '', $display_name); + $display_name = trim($display_name, '/ '); + } + $OUTPUT->command('add_contact_row', $row_id, array( - $keyname => html::a(array('title' => $title), rcube::Q($name ?: $email) . + $keyname => html::a(array('title' => $title), rcube::Q($display_name) . ($name && count($emails) > 1 ? ' ' . html::span('email', rcube::Q($email)) : '') )), $classname); }