Exemplo n.º 1
0
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $this->loadModel($id)->delete();
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
 /**
  * Manages all models.
  */
 public function actionIndex()
 {
     if (isset($_POST['opyblic'])) {
         CmsPage::model()->updateByPk($_POST['page_id'], array('status' => 2));
     }
     if (isset($_POST['del'])) {
         CmsPage::model()->updateByPk($_POST['page_id'], array('status' => 3));
     }
     $model = new CmsPage('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['CmsPage'])) {
         $model->attributes = $_GET['CmsPage'];
     }
     $this->render('Index', array('model' => $model));
 }