Example #1
0
 public function actionDelete()
 {
     $model = BlogPost::findByPk($_POST['BlogPost']);
     $model->status = BlogPost::STATUS_DELETED;
     $model->save();
     $this->goToAction('index');
 }
Example #2
0
 public function actionRead($id)
 {
     $this->assign('article', $art = BlogPost::findByPk($id));
     if ($art->allow_comments) {
         $model = new BlogComment();
         $model->post_id = $id;
         if (isset($_POST['BlogComment']) && $model->setAttributes($_POST['BlogComment'])->save()) {
             Messages::get()->success("Comment saved!");
             $this->goBack();
         }
         $this->assign('model', $model);
         $this->assign('comments', BlogComment::findAllByAttributes(['post_id' => $id, 'status' => BlogComment::STATUS_OK]));
     }
 }