From 562e690f85da69b7c61d9b496216f25e2d3df761 Mon Sep 17 00:00:00 2001 From: nathangray Date: Fri, 16 Feb 2018 11:19:47 -0700 Subject: [PATCH] * Mail - Improvements to list display in address search results Now automatic group lists & created distribution lists limited to 10 each If there are more, this is indicated with ellipsis --- api/templates/default/etemplate2.css | 8 ++++ mail/inc/class.mail_compose.inc.php | 64 +++++++++++++++++++--------- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/api/templates/default/etemplate2.css b/api/templates/default/etemplate2.css index 54a12b3505..734d1feac8 100644 --- a/api/templates/default/etemplate2.css +++ b/api/templates/default/etemplate2.css @@ -1072,6 +1072,14 @@ ul.et2_link_string { background-repeat: no-repeat; font-weight: bold; } +.et2_taglist .ms-res-item[data-json*='more_results']:after { + content:'…'; + display: block; + font-size: 200%; + padding: 5px; + padding-left: 3ex; + margin-top: -1ex; +} /* min-height to fix calculations done while hidden */ .et2_taglist, .et2_taglist > div.ms-ctn { min-height: 23px; diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index a0f5aa8f9b..447cd5ac10 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -3456,28 +3456,10 @@ class mail_compose $contacts_obj = new Api\Contacts(); $results = array(); - // Add up to 5 matching mailing lists + // Add up to 10 matching mailing lists, and 10 groups if($include_lists) { - $lists = array_filter( - $contacts_obj->get_lists(Acl::READ), - function($element) use($_searchString) { - return (stripos($element, $_searchString) !== false); - } - ); - $list_count = 0; - foreach($lists as $key => $list_name) - { - $results[] = array( - 'id' => $key, - 'name' => $list_name, - 'label' => $list_name, - 'class' => 'mailinglist', - 'title' => lang('Mailinglist'), - 'data' => $key - ); - if($list_count++ > 5) break; - } + $results += static::get_lists($_searchString, $contacts_obj); } if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength) @@ -3586,6 +3568,48 @@ class mail_compose exit(); } + /** + * Get list of matching distribution lists when searching for email addresses + * + * The results are limited to 10 each of group lists and normal lists + * + * @param String $_searchString + * @param Contacts $contacts_obj + * @return array + */ + protected static function get_lists($_searchString, &$contacts_obj) + { + $group_lists = array(); + $manual_lists = array(); + $lists = array_filter( + $contacts_obj->get_lists(Acl::READ), + function($element) use($_searchString) { + return (stripos($element, $_searchString) !== false); + } + ); + + foreach($lists as $key => $list_name) + { + $type = $key > 0 ? 'manual' : 'group'; + $list = array( + 'id' => $key, + 'name' => $list_name, + 'label' => $list_name, + 'class' => 'mailinglist ' . "{$type}_list", + 'title' => lang('Mailinglist'), + 'data' => $key + ); + ${"${type}_lists"}[] = $list; + } + $trim = function($list) { + $limit = 10; + if(count($list) <= $limit) return $list; + $list[$limit-1]['class'].= ' more_results'; + $list[$limit-1]['title'] .= ' (' . lang('%1 more', count($list) - $limit) . ')'; + return array_slice($list, 0, $limit); + }; + return array_merge($trim($group_lists), $trim($manual_lists)); + } /** * Merge the selected contact ID into the document given in $_REQUEST['document'] * and send it.