| @@ 71-91 (lines=21) @@ | ||
| 68 | * @throws \Ffcms\Core\Exception\NativeException |
|
| 69 | * @throws \Ffcms\Core\Exception\SyntaxException |
|
| 70 | */ |
|
| 71 | public function actionUpdate($id) |
|
| 72 | { |
|
| 73 | $user = UserRecords::findOrNew($id); |
|
| 74 | // generate model data based on user object |
|
| 75 | $model = new FormUserUpdate($user); |
|
| 76 | ||
| 77 | // check is form is sended |
|
| 78 | if ($model->send()) { |
|
| 79 | if ($model->validate()) { // check validation |
|
| 80 | $model->save(); |
|
| 81 | App::$Session->getFlashBag()->add('success', __('Data was successful updated')); |
|
| 82 | } else { |
|
| 83 | App::$Session->getFlashBag()->add('error', __('Form validation is failed')); |
|
| 84 | } |
|
| 85 | } |
|
| 86 | ||
| 87 | // render viewer |
|
| 88 | return $this->view->render('user_update', [ |
|
| 89 | 'model' => $model |
|
| 90 | ]); |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Delete user row from database |
|
| @@ 159-178 (lines=20) @@ | ||
| 156 | * @throws \Ffcms\Core\Exception\SyntaxException |
|
| 157 | * @throws \Ffcms\Core\Exception\NativeException |
|
| 158 | */ |
|
| 159 | public function actionGroupUpdate($id) |
|
| 160 | { |
|
| 161 | // find role or create new object |
|
| 162 | $role = Role::findOrNew($id); |
|
| 163 | ||
| 164 | $model = new FormUserGroupUpdate($role); |
|
| 165 | if ($model->send()) { // work with post request |
|
| 166 | if ($model->validate()) { |
|
| 167 | $model->save(); |
|
| 168 | App::$Session->getFlashBag()->add('success', __('Data was successful updated')); |
|
| 169 | } else { |
|
| 170 | App::$Session->getFlashBag()->add('error', __('Form validation is failed')); |
|
| 171 | } |
|
| 172 | } |
|
| 173 | ||
| 174 | // render view |
|
| 175 | return $this->view->render('group_update', [ |
|
| 176 | 'model' => $model |
|
| 177 | ]); |
|
| 178 | } |
|
| 179 | ||
| 180 | /** |
|
| 181 | * User identity settings |
|