* Addressbook: fix non-active accounts where visible for non-admins, if hidden accounts exist

also fix not working sorting by account_lid/username
This commit is contained in:
ralf 2025-01-12 10:25:22 +01:00
parent 73d8d77354
commit c66da42846
2 changed files with 8 additions and 2 deletions

View File

@ -1900,6 +1900,7 @@ class addressbook_ui extends addressbook_bo
break;
}
$query['order'] = 'n_family';
// fall-through
case 'n_family':
$order = "n_family<>'' DESC,n_family $sort,n_given $sort,org_name $sort";
break;
@ -1919,6 +1920,10 @@ class addressbook_ui extends addressbook_bo
break;
case 'contact_id':
$order = "egw_addressbook.$query[order] $sort";
break;
case 'account_lid':
$order = "account_lid<>'' DESC,account_lid $sort,n_family $sort,n_given $sort";
break;
}
if ($query['searchletter']) // only show contacts if the order-criteria starts with the given letter
{

View File

@ -603,8 +603,9 @@ class Sql extends Api\Storage
unset($filter['list']);
}
// add join to show only active accounts (only if accounts are shown and in sql and we not already join the accounts table, eg. used by admin)
if ((is_array($owner) ? in_array(0, $owner) : !$owner) && substr($this->account_repository,0,3) == 'sql' &&
strpos($join,$GLOBALS['egw']->accounts->backend->table) === false && !array_key_exists('account_id',$filter))
if ((is_array($owner) ? in_array(0, $owner) : !$owner) &&
substr($this->account_repository,0,3) == 'sql' &&
strpos($join,$GLOBALS['egw']->accounts->backend->table) === false)
{
$join .= self::ACCOUNT_ACTIVE_JOIN;
$extra_cols[] = 'account_lid AS account_lid';