diff --git a/api/js/etemplate/Et2Select/Et2SelectAccount.ts b/api/js/etemplate/Et2Select/Et2SelectAccount.ts index f9ec6ec657..e12714ac1d 100644 --- a/api/js/etemplate/Et2Select/Et2SelectAccount.ts +++ b/api/js/etemplate/Et2Select/Et2SelectAccount.ts @@ -32,15 +32,25 @@ export class Et2SelectAccount extends Et2Select constructor() { super(); - - this.searchUrl = "EGroupware\\Api\\Etemplate\\Widget\\Taglist::ajax_search"; + // currently only account_selection "Primary group and search" needs the search, + // all other types have the accounts fully local + if (this.egw().preference('account_selection', 'common') === 'primary_group') + { + this.searchUrl = "EGroupware\\Api\\Etemplate\\Widget\\Taglist::ajax_search"; + } + else // always allow local search + { + this.search = true; + } + this.searchOptions = { type: 'account', account_type: 'accounts' }; this.__accountType = 'accounts'; } set accountType(type : AccountType) { this.__accountType = type; + this.searchOptions.account_type = type; super.select_options = this.select_options; } diff --git a/api/src/Etemplate/Widget/Taglist.php b/api/src/Etemplate/Widget/Taglist.php index 57426a7ac5..93c3f2f643 100644 --- a/api/src/Etemplate/Widget/Taglist.php +++ b/api/src/Etemplate/Widget/Taglist.php @@ -63,38 +63,33 @@ class Taglist extends Etemplate\Widget * Find entries that match query parameter (from link system) and format them * as the widget expects, a list of {id: ..., label: ...} objects */ - public static function ajax_search($search_text, $search_options = []) + public static function ajax_search($search_text=null, array $search_options = []) { $app = $_REQUEST['app']; $type = $_REQUEST['type']; - $query = $_REQUEST['query']; - $options = array(); - $links = array(); - if($type == "account") + $query = $search_text ?? $_REQUEST['query']; + $options = $search_options; + $results = []; + if (empty($query)) { - // Only search if a query was provided - don't search for all accounts - if($query) + // do NOT search without a query + } + elseif($type === "account") + { + $options['account_type'] = $_REQUEST['account_type']; + $options['tag_list'] = true; + $results = Api\Accounts::link_query($query, $options); + } + else + { + foreach(Api\Link::query($app, $query, $options) as $id => $name) { - $options['account_type'] = $_REQUEST['account_type']; - $links = Api\Accounts::link_query($query, $options); + $results[] = ['value' => $id, 'label' => $name]; } } - elseif($query) // Only search if there's a query, avoid searching for all - { - $links = Api\Link::query($app, $query, $options); - } - $results = array(); - foreach($links as $id => $name) - { - $results[] = array('id' => $id, 'label' => $name); - } - - usort($results, function ($a, $b) use ($query) { - $a_label = is_array($a["label"]) ? $a["label"]["label"] : $a["label"]; - $b_label = is_array($b["label"]) ? $b["label"]["label"] : $b["label"]; - - similar_text($query, $a_label, $percent_a); - similar_text($query, $b_label, $percent_b); + usort($results, static function ($a, $b) use ($query) { + similar_text($query, $a["label"], $percent_a); + similar_text($query, $b["label"], $percent_b); return $percent_a === $percent_b ? 0 : ($percent_a > $percent_b ? -1 : 1); }); diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 5eccbc6702..c074417d61 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -3689,7 +3689,7 @@ class mail_compose $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); if(!empty($email) && in_array($completeMailString ,$results) === false) { $results[] = array( - 'id'=>$completeMailString, + 'value' => $completeMailString, 'label' => $completeMailString, // Add just name for nice display, with title for hover 'name' => $contact['n_fn'],