public function actionUpdatebookmark($id) { $app = Yii::app(); if ($app->user->isGuest) { $header = 'Доступно после регистрации'; $this->render('bookmark-form-guest', array('app' => $app, 'header' => $header)); } else { $modelBookmark = Bookmarks::model()->findByPk($id); if ($modelBookmark === null) { throw new CHttpException(404, 'Ошибка загрузки раздела'); } if ($modelBookmark->user_id != $app->user->id) { throw new CHttpException(401, 'Ошибка доступа'); } if (isset($_POST['delete'])) { $modelBookmark->delete(); Yii::app()->user->setFlash('success', 'Закладка удалена'); if ($modelBookmark->section_id == 0) { $return_arr = array('my/index'); } else { $return_arr = array('my/section', 'id' => $modelBookmark->section_id); } $app->cache->delete(Bookmarks::CACHE_BOOKMARKS_LIST . $modelBookmark->section_id . $app->user->id); return $this->redirect($return_arr); } $model = new BookmarkForm(); $model->attributes = $modelBookmark->attributes; $header = 'Редактирование закладки'; if ($model->section_id == 0) { $cancel_url = $this->createUrl('my/index'); } else { $cancel_url = $this->createUrl('my/section', array('id' => $model->section_id)); } $icons_list = Bookmarks::model()->getBookMarkIconsList(); if (isset($_POST['BookmarkForm'])) { $model->attributes = $_POST['BookmarkForm']; if ($model->validate()) { $modelBookmark->attributes = $model->attributes; $modelBookmark->save(); Yii::app()->user->setFlash('success', 'Сохранено'); if ($modelBookmark->section_id == 0) { $return_arr = array('my/index'); } else { $return_arr = array('my/section', 'id' => $modelBookmark->section_id); } return $this->redirect($return_arr); } //echo'<pre>';print_r($model);echo'</pre>';die; } $this->render('bookmark-form-update', array('app' => $app, 'model' => $model, 'header' => $header, 'cancel_url' => $cancel_url, 'icons_list' => $icons_list)); } }