fix: [users:edit] Correctly take into consideration perm-org-group-admin

refacto/CRUDComponent
Sami Mokaddem 2023-10-30 09:46:09 +01:00
parent 3ea5b7830d
commit 1c6c7f346a
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 6 additions and 6 deletions

View File

@ -72,7 +72,7 @@ class UsersController extends AppController
]; ];
$individual_ids = []; $individual_ids = [];
if (!$currentUser['role']['perm_admin']) { if (!$currentUser['role']['perm_admin']) {
if (!$currentUser['role']['perm_group_admin']) { if ($currentUser['role']['perm_group_admin']) {
$validRoles = $this->Users->Roles->find('list')->select(['id', 'name'])->order(['name' => 'asc'])->where(['perm_admin' => 0, 'perm_group_admin' => 0])->all()->toArray(); $validRoles = $this->Users->Roles->find('list')->select(['id', 'name'])->order(['name' => 'asc'])->where(['perm_admin' => 0, 'perm_group_admin' => 0])->all()->toArray();
$individual_ids = $this->Users->Individuals->find('aligned', ['organisation_id' => $currentUser['organisation_id']])->all()->extract('id')->toArray(); $individual_ids = $this->Users->Individuals->find('aligned', ['organisation_id' => $currentUser['organisation_id']])->all()->extract('id')->toArray();
} else { } else {
@ -219,12 +219,12 @@ class UsersController extends AppController
{ {
$currentUser = $this->ACL->getUser(); $currentUser = $this->ACL->getUser();
$validRoles = []; $validRoles = [];
$individuals_params = [
'sort' => ['email' => 'asc']
];
$individual_ids = [];
if (!$currentUser['role']['perm_admin']) { if (!$currentUser['role']['perm_admin']) {
$validRoles = $this->Users->Roles->find('list')->select(['id', 'name'])->order(['name' => 'asc'])->where(['perm_admin' => 0, 'perm_org_admin' => 0])->all()->toArray(); if ($currentUser['role']['perm_group_admin']) {
$validRoles = $this->Users->Roles->find('list')->select(['id', 'name'])->order(['name' => 'asc'])->where(['perm_admin' => 0, 'perm_group_admin' => 0])->all()->toArray();
} else {
$validRoles = $this->Users->Roles->find('list')->select(['id', 'name'])->order(['name' => 'asc'])->where(['perm_admin' => 0, 'perm_group_admin' => 0, 'perm_org_admin' => 0])->all()->toArray();
}
} else { } else {
$validRoles = $this->Users->Roles->find('list')->order(['name' => 'asc'])->all()->toArray(); $validRoles = $this->Users->Roles->find('list')->order(['name' => 'asc'])->all()->toArray();
} }