From a17cbe1f45ff838b599cf8f6579920f6252a91be Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 21 Nov 2023 14:07:59 -0700 Subject: [PATCH] Filtering email search results on just value Should catch even more duplicates, though value has both name & email --- mail/inc/class.mail_compose.inc.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 76270e5c7f..a6abd6b0b2 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -3749,9 +3749,19 @@ class mail_compose // switch regular JSON response handling off Api\Json\Request::isJSONRequest(false); + $results = array_reduce($results, function ($result, $option) + { + $value = $option['value']; + if(!array_key_exists($value, $result)) + { + $result[$value] = $option; + } + return $result; + }, []); + //error_log(__METHOD__.__LINE__.array2string($jsArray)); header('Content-Type: application/json; charset=utf-8'); - echo json_encode(array_values(array_unique($results, SORT_REGULAR))); + echo json_encode(array_values($results)); exit(); }