chg: [userSettings:add] Adhere to the passed user context

cli-modification-summary
Sami Mokaddem 2022-01-27 10:44:47 +01:00
parent dc8710d89e
commit 7de1c14407
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 4 additions and 3 deletions

View File

@ -57,7 +57,7 @@ class UserSettingsController extends AppController
}
}
public function add($user_id = false)
public function add($user_id=null)
{
$currentUser = $this->ACL->getUser();
$this->CRUD->add([
@ -77,6 +77,8 @@ class UserSettingsController extends AppController
if (empty($currentUser['role']['perm_admin'])) {
$allUsers->where(['id' => $currentUser->id]);
$user_id = $currentUser->id;
} else if (!is_null($user_id)) {
$allUsers->where(['id' => $user_id]);
}
$dropdownData = [
'user' => $allUsers->all()->toArray(),

View File

@ -9,8 +9,7 @@
'type' => 'dropdown',
'label' => __('User'),
'options' => $dropdownData['user'],
'value' => !empty($user_id) ? $user_id : '',
'disabled' => !empty($user_id),
'value' => !is_null($user_id) ? $user_id : '',
],
[
'field' => 'name',