示例#1
0
 /**
  * @Author: ANH DUNG Feb 11, 2015
  * @Todo: delete tenancy
  * @Param: $id
  */
 public function actionDelete_tenancy($id)
 {
     try {
         if (Yii::app()->request->isPostRequest) {
             // we only allow deletion via POST request
             $model = MyFormat::loadModelByClass($id, 'ProTransactions');
             if ($model && ProTransactions::CanDeleteTenancy($model)) {
                 if ($model->delete()) {
                     Yii::log("Delete record " . print_r($model->attributes, true), 'info');
                 }
             }
             // 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('index'));
             }
         } else {
             Yii::log("Invalid request. Please do not repeat this request again.");
             throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
         }
     } catch (Exception $e) {
         Yii::log("Exception " . print_r($e, true), 'error');
         throw new CHttpException(400, $e->getMessage());
     }
 }