Api: Make sure the current user is always in the list of accounts sent to client

This commit is contained in:
nathan 2023-05-18 14:46:20 -06:00
parent bea2659fe3
commit 00b48f3b04
2 changed files with 24 additions and 10 deletions

View File

@ -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'],

View File

@ -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);