diff -urN ../roundcubemail-1.5.0.orig/config/defaults.inc.php ./config/defaults.inc.php --- ../roundcubemail-1.5.0.orig/config/defaults.inc.php 2021-10-17 23:38:03.000000000 +0300 +++ ./config/defaults.inc.php 2021-11-27 16:31:44.521202000 +0200 @@ -1207,6 +1207,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'] = ''; + // Contact mode. If your contacts are mostly business, switch it to 'business'. // This will prioritize form fields related to 'work' (instead of 'home'). // Default: 'private'. diff -urN ../roundcubemail-1.5.0.orig/program/actions/mail/search_contacts.php ./program/actions/mail/search_contacts.php --- ../roundcubemail-1.5.0.orig/program/actions/mail/search_contacts.php 2021-10-17 23:38:04.000000000 +0300 +++ ./program/actions/mail/search_contacts.php 2021-11-27 16:58:09.075768000 +0200 @@ -100,10 +100,38 @@ $jsresult[$row_id] = format_email_recipient($email, $name); $title = rcube_addressbook::compose_search_name($row, $email, $name); - $link_content = rcube::Q($name ?: $email); - if ($name && count($emails) > 1) { - $link_content .= ' ' . html::span('email', rcube::Q($email)); +// $link_content = rcube::Q($name ?: $email); +// if ($name && count($emails) > 1) { +// $link_content .= ' ' . html::span('email', rcube::Q($email)); +// } + $link_content = rcube::get_instance()->config->get('contact_search_left_pane_name'); + if (empty($link_content)) { + $link_content = rcube::Q($name ?: $email); + if ($name && count($emails) > 1) { + $link_content .= ' ' . html::span('email', rcube::Q($email)); + } + } else { + if ($name and (count($emails) > 1)) $link_content = str_replace('{email}', '', $link_content); + + $link_content = str_replace('{name}', $name, $link_content); + $link_content = str_replace('{email}', $email, $link_content); + + if (preg_match_all('/\{[a-z:]+\}/', $link_content, $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); + $link_content = str_replace('{' . $key . '}', $value, $link_content); + } + } + + $link_content = preg_replace('/\s+/', ' ', $link_content); + $link_content = preg_replace('/\s*(<>|\(\)|\[\])/', '', $link_content); + $link_content = trim($link_content, '/ '); + $link_content = rcube::Q($link_content); } + $link = html::a(['title' => $title], $link_content); $rcmail->output->command('add_contact_row', $row_id, [$keyname => $link], $classname);