Exemplo n.º 1
0
 /**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             if (Yii::app()->user->isGuest) {
                 $condition = 'status=' . Blogpost::STATUS_PUBLISHED . ' OR status=' . Blogpost::STATUS_ARCHIVED;
             } else {
                 $condition = '';
             }
             $this->_model = Blogpost::model()->findByPk($_GET['id'], $condition);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }