示例#1
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  */
 public function actionDelete()
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         if (LocationService::loadModel()->delete()) {
             Flashes::addInfoFlash(Yii::t('amo', 'Location deleted'));
         } else {
             Flashes::addErrorFlash(Yii::t('amo', 'Could not delete the location.') . '  ' . Yii::t('amo', 'Please, try again later.'));
         }
         $this->redirect(array('index'));
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
示例#2
0
 /** Deletes a particular model. If deletion is successful, the browser will be redirected to the 'list' page. */
 public function actionDelete()
 {
     $model = $this->loadVehicle();
     if (Yii::app()->user->checkAccess('editOwnVehicle', array('vehicle' => $model), false)) {
         if (Yii::app()->request->isPostRequest) {
             // we only allow deletion via POST request
             if ($model->delete()) {
                 Flashes::addInfoFlash(Yii::t('amo', 'Vehicle deleted successfully'));
             } else {
                 Flashes::addErrorFlash(Yii::t('amo', 'Could not delete the vehicle.') . '  ' . Yii::t('amo', 'Please, try again later.'));
             }
             $this->redirect(array('list'));
         } else {
             throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
         }
     } else {
         $this->accessDenied(Yii::app()->user);
     }
 }