diff --git a/api/src/Accounts.php b/api/src/Accounts.php index c9c0a06505..517ed968fd 100644 --- a/api/src/Accounts.php +++ b/api/src/Accounts.php @@ -428,18 +428,24 @@ class Accounts break; } $accounts = array(); - foreach(self::getInstance()->search(array( - 'type' => $options['filter']['group'] < 0 ? $options['filter']['group'] : $type, - 'query' => $pattern, - 'query_type' => 'all', - 'order' => $order, - 'offset' => $options['num_rows'] - )) as $account) + $params = array( + 'type' => $options['filter']['group'] < 0 ? $options['filter']['group'] : $type, + 'query' => $pattern, + 'query_type' => $options['filter']['query_type'] ?: 'all', + 'order' => $order, + 'offset' => $options['num_rows'] + ); + if(array_key_exists('account_id', $options)) + { + $params['account_id'] = $options['account_id']; + } + foreach(self::getInstance()->search($params) as $account) { $displayName = self::format_username($account['account_lid'], - $account['account_firstname'],$account['account_lastname'],$account['account_id']); + $account['account_firstname'], $account['account_lastname'], $account['account_id'] + ); - if (!empty($options['tag_list'])) + if(!empty($options['tag_list'])) { $result = [ 'value' => $account['account_id'], diff --git a/api/src/Framework.php b/api/src/Framework.php index e8e930f375..ddc07fd1fc 100644 --- a/api/src/Framework.php +++ b/api/src/Framework.php @@ -1678,7 +1678,15 @@ abstract class Framework extends Framework\Extra foreach($list as $type => &$accounts) { $options = array('account_type' => $type, 'tag_list' => true) + $accounts; - $accounts = Accounts::link_query('',$options); + $accounts = Accounts::link_query('', $options); + } + unset($list["accounts"][9]); + // Make sure the user themselves is in there + if(!array_key_exists($GLOBALS['egw_info']['user']['account_id'], $list['accounts'])) + { + $options = array('account_type' => 'accounts', 'tag_list' => true, + 'account_id' => $GLOBALS['egw_info']['user']['account_id']) + $list['accounts']; + $list['accounts'] += Accounts::link_query('', $options); } Json\Response::get()->data($list);