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