From a14a8681fc17d81fa73fc133edc90ee9a596b8cf Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 7 Mar 2017 10:18:06 -0700 Subject: [PATCH] * Mail- List mailing lists before contacts when searching for email addresses --- mail/inc/class.mail_compose.inc.php | 51 +++++++++++++++-------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 9ef614f6e1..9020e34c09 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -3392,6 +3392,32 @@ class mail_compose $include_lists = (boolean)$_REQUEST['include_lists']; $contacts_obj = new Api\Contacts(); + $results = array(); + + // Add up to 5 matching mailing lists + 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; + } + } + if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength) { //error_log(__METHOD__.__LINE__.array2string($_searchString)); @@ -3428,7 +3454,7 @@ class mail_compose unset($accounts); } } - $results = array(); + if(is_array($contacts)) { foreach($contacts as $contact) { foreach(array($contact['email'],$contact['email_home']) as $email) { @@ -3489,29 +3515,6 @@ class mail_compose ); } - // Add up to 5 matching mailing lists - 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; - } - } // switch regular JSON response handling off Api\Json\Request::isJSONRequest(false);