/** * 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.'); } }
/** * 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.'); } }
/** * Creates a deep copy of a domain and it's associated records. */ public function actionCopy($id) { $oldmodel = $this->loadModel($id); $model = new Domain(); $model->name = $oldmodel->name; $model->master = $oldmodel->master; $model->last_check = $oldmodel->last_check; $model->type = $oldmodel->type; $model->notified_serial = $oldmodel->notified_serial; $model->account = $oldmodel->account; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Domain'])) { $model->attributes = $_POST['Domain']; if ($model->save()) { // copy records if ($model->copy_records == 1) { foreach ($oldmodel->records as $or) { $record = new Record(); $record->domain_id = $model->id; $record->name = $or->name; $record->type = $or->type; $record->content = $or->content; $record->ttl = $or->ttl; $record->prio = $or->prio; $record->change_date = $or->change_date; $record->save(); } } // copy permissions if ($model->copy_permissions == 1) { foreach ($oldmodel->users as $user) { $perm = new DomainUser(); $perm->domain_id = $model->id; $perm->user_id = $user->id; $perm->save(); } } Yii::app()->audit->log('Copied domain: ' . $model->id); $this->redirect(array('update', 'id' => $model->id)); } } $this->render('copy', array('model' => $model)); }