@@ 51-74 (lines=24) @@ | ||
48 | } |
|
49 | ||
50 | // edit user profiles |
|
51 | public function actionUpdate($id) |
|
52 | { |
|
53 | $user = UserRecords::findOrNew($id); |
|
54 | ||
55 | // find user identify object |
|
56 | //$user = App::$User->identity($id); |
|
57 | // generate model data based on user object |
|
58 | $model = new FormUserUpdate($user); |
|
59 | ||
60 | // check is form is sended |
|
61 | if ($model->send()) { |
|
62 | if ($model->validate()) { // check validation |
|
63 | $model->save(); |
|
64 | App::$Session->getFlashBag()->add('success', __('Data was successful updated')); |
|
65 | } else { |
|
66 | App::$Session->getFlashBag()->add('error', __('Form validation is failed')); |
|
67 | } |
|
68 | } |
|
69 | ||
70 | // render viewer |
|
71 | $this->response = App::$View->render('user_update', [ |
|
72 | 'model' => $model->export() |
|
73 | ]); |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * Delete user data |
|
@@ 121-140 (lines=20) @@ | ||
118 | * Edit and add groups |
|
119 | * @param $id |
|
120 | */ |
|
121 | public function actionGroupUpdate($id) |
|
122 | { |
|
123 | // find role or create new object |
|
124 | $role = Role::findOrNew($id); |
|
125 | ||
126 | $model = new FormUserGroupUpdate($role); |
|
127 | if ($model->send()) { // work with post request |
|
128 | if ($model->validate()) { |
|
129 | $model->save(); |
|
130 | App::$Session->getFlashBag()->add('success', __('Data was successful updated')); |
|
131 | } else { |
|
132 | App::$Session->getFlashBag()->add('error', __('Form validation is failed')); |
|
133 | } |
|
134 | } |
|
135 | ||
136 | // render view |
|
137 | $this->response = App::$View->render('group_update', [ |
|
138 | 'model' => $model |
|
139 | ]); |
|
140 | } |
|
141 | ||
142 | /** |
|
143 | * User identity settings |