/** * Deletes an existing DcmdOprCmdRepeatExec model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { if (Yii::$app->user->getIdentity()->admin != 1) { Yii::$app->getSession()->setFlash('success', NULL); Yii::$app->getSession()->setFlash('error', "对不起,你没有权限!"); return $this->redirect(array('dcmd-opr-cmd-repeat-exec/index')); } ///删除dcmd_group_repeat_cmd DcmdGroupRepeatCmd::deleteAll('repeat_cmd_id=' . $id); $model = $this->findModel($id); $this->oprlog(3, "delete repeat exec cmd:" . $model->repeat_cmd_name); $model->delete(); Yii::$app->getSession()->setFlash('success', '删除成功!'); return $this->redirect(['index']); }
/** * Deletes an existing DcmdGroup model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { /*$node = DcmdUserGroup::find()->where(['gid' => $id])->one(); if($node) { Yii::$app->getSession()->setFlash('error', '用户组内有用户,不可删除!'); }else { $this->findModel($id)->delete(); Yii::$app->getSession()->setFlash('success', '删除成功!'); }*/ if (Yii::$app->user->getIdentity()->admin != 1 || Yii::$app->user->getIdentity()->sa != 1) { Yii::$app->getSession()->setFlash('success', NULL); Yii::$app->getSession()->setFlash('error', "Sorry, You don't have priority!"); return $this->redirect(array('index')); } DcmdUserGroup::deleteAll("gid=" . $id); DcmdGroupCmd::deleteAll('gid=' . $id); DcmdGroupRepeatCmd::deleteAll('gid=' . $id); $model = $this->findModel($id); $this->oprlog(3, "delete group:" . $model->gname); $model->delete(); Yii::$app->getSession()->setFlash('success', '删除成功!'); return $this->redirect(['index']); }