public function actionNewComment() { $model = new CmsComment(); $model->attributes = $_POST; $model->page_id = Yii::app()->request->getParam('id'); if (!Yii::app()->user->isGuest) { $model->user_id = Yii::app()->user->id; } if ($model->save()) { return $this->sendResponse(self::STATUS_OK, $model); } else { return $this->sendResponse(self::STATUS_BAD_REQUEST, "Данные не корректны"); } }
public function actionView($id) { $model = CmsPage::model()->findByPk($id); $model1 = new CmsComment(); $ar = $model1->getCommentsTree($id); if (isset($_POST['CmsComment'])) { $model1->page_id = $id; if (!Yii::app()->user->isGuest) { $model1->user_id = Yii::app()->user->id; } // esli polzovatel ne gost tokda soxranaem ego id $model1->attributes = $_POST['CmsComment']; if ($model1->save()) { if ($model1->parent_id != null && !Yii::app()->user->isGuest) { CmsComment::sendOtvet($model1->parent_id); } $this->refresh(); } } if (Yii::app()->user->isGuest) { $model1->scenario = 'ComSet'; } $this->render('view', array('model1' => $model1, 'model' => $model, 'comments' => $ar)); }