Пример #1
0
 /**
  * Unlinks a connection between a user and a domain.
  */
 public function actionDelete($domain_id, $user_id)
 {
     if (Yii::app()->request->isPostRequest) {
         $perm = DomainUser::model()->findByAttributes(array('domain_id' => $domain_id, 'user_id' => $user_id));
         if ($perm != null) {
             $perm->delete();
             Yii::app()->audit->log('Unlinked domain ' . $domain_id . ' from user ' . $user_id);
         }
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         //if(!isset($_GET['ajax'])) // TODO: where to redirect?
         //	$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('update','id'=>$id));
     } 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 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         // delete all permissions
         $models = DomainUser::model()->findAllByAttributes(array('user_id' => $id));
         foreach ($models as $model) {
             $model->delete();
         }
         // we only allow deletion via POST request
         $this->loadModel($id)->delete();
         Yii::app()->audit->log('Deleted user: '******'ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }