/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return PostItem the loaded model * @throws CHttpException */ public function loadModel($id) { $model = PostItem::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionDisableReply($reply_id, $complaint_id) { if ($reply_id) { $reply = Reply::model()->findByPk($reply_id); $reply->is_active = 0; $reply->save(); Complaint::model()->deleteByPk($complaint_id); } else { $thread = PostItem::model()->findByPk(Complaint::model()->findByPk($complaint_id)->post_item_id); $thread->is_active = $thread->is_active ? 0 : 1; $thread->save(false); } if (!Yii::app()->request->isAjaxRequest) { $this->redirect(array('admin')); } }
public function actionReadPosting($id) { $typeId = PostItem::model()->findByPk($id)->getAttribute("post_type_id"); switch ($typeId) { case Article::POST_TYPE: $this->_displayArticle($id); break; case Event::POST_TYPE: break; case Article::POST_TYPE_NEWS: $this->_displayNews($id); break; default: throw new CHttpException(404, 'Invalid Posting Type.'); } }
public function actionToggle($id, $attribute = null) { $model = PostItem::model()->findByPk($id); $model->is_active = $model->is_active ? 0 : 1; $model->save(false); if (!Yii::app()->request->isAjaxRequest) { $this->redirect(Yii::app()->user->hasState('adminView') ? Yii::app()->user->getState('adminView') : array('admin')); } }