diff --git a/api/src/Accounts.php b/api/src/Accounts.php index 5c140dfe02..f9f6675aa4 100644 --- a/api/src/Accounts.php +++ b/api/src/Accounts.php @@ -212,7 +212,10 @@ class Accounts if (empty($account_ids)) { $account_ids = $hidden_account_ids; - if ($hidden === false) $account_ids[] = '!'; + if ($hidden === false && $account_ids) + { + $account_ids[] = '!'; + } } elseif ($hidden === true) { @@ -289,9 +292,10 @@ class Accounts $serial = self::cacheKey($param, $serial_unlimited); // implement $param['hidden'] via $param['account_id'] - if (isset($param['hidden']) && !in_array($param['type'],['groups', 'owngroups'])) + if (isset($param['hidden']) && !in_array($param['type'],['groups', 'owngroups']) && + ($account_id_filter = self::hidden2account_id($param['hidden'], (array)($param['account_id']??null)))) { - $param['account_id'] = self::hidden2account_id($param['hidden'], (array)$param['account_id']); + $param['account_id'] = $account_id_filter; } unset($param['hidden']); diff --git a/api/src/Contacts/Sql.php b/api/src/Contacts/Sql.php index 6b2cea3b9b..82ec97e7d9 100644 --- a/api/src/Contacts/Sql.php +++ b/api/src/Contacts/Sql.php @@ -719,6 +719,7 @@ class Sql extends Api\Storage // implement negated account_id filter if (!empty($filter['account_id']) && ($not_account_ids = array_search('!', $filter['account_id'])) !== false) { + unset($filter['account_id'][$not_account_ids]); $filter[] = $this->db->expression($this->table_name, ' NOT ', $this->table_name.'.', ['account_id' => $filter['account_id']]); unset($filter['account_id']); } diff --git a/api/src/Contacts/Storage.php b/api/src/Contacts/Storage.php index dbf4ae0b35..8a36b6308c 100755 --- a/api/src/Contacts/Storage.php +++ b/api/src/Contacts/Storage.php @@ -660,9 +660,10 @@ class Storage //error_log(__METHOD__.'('.array2string($criteria,true).','.array2string($only_keys).",'$order_by','$extra_cols','$wildcard','$empty','$op',".array2string($start).','.array2string($filter,true).",'$join')"); // add hidden user filter for non-admins - if (empty($GLOBALS['egw_info']['user']['apps']['admin']) && empty($filter['owner'])) + if (empty($GLOBALS['egw_info']['user']['apps']['admin']) && empty($filter['owner']) && + ($account_id_filter = Api\Accounts::hidden2account_id(false, $filter['account_id'] ?? null))) { - $filter['account_id'] = Api\Accounts::hidden2account_id(false, $filter['account_id']); + $filter['account_id'] = $account_id_filter; } // Handle 'None' country option if(is_array($filter) && isset($filter['adr_one_countrycode']) && $filter['adr_one_countrycode'] === '-custom-')