From e129a044d48c553e7f528cd577db15b1a108bebb Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 27 Feb 2020 10:50:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97-=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthManagerController.class.php | 56 ++++++++++++++++--- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/Application/Admin/Controller/AuthManagerController.class.php b/Application/Admin/Controller/AuthManagerController.class.php index 2505fe021..94dd862f8 100644 --- a/Application/Admin/Controller/AuthManagerController.class.php +++ b/Application/Admin/Controller/AuthManagerController.class.php @@ -223,16 +223,24 @@ class AuthManagerController extends AdminController{ addOperationLog(array( "op_type"=>0, "key"=> $_POST['title'], - "url"=>U("User/index") + "url"=>U("AuthManager/index") )); }else{ \Think\Log::actionLog('AuthManager/editGroup','authGroup',1); - addOperationLog(array( - "op_type"=>1, - "key"=> $_POST['title'], - "url"=>U("User/index") - )); $r = $AuthGroup->save(); + //操作日志,不传title表示是访问授权 + $oparr = array( + "op_type"=>1, + "url"=>U("AuthManager/index") + ); + if(empty($_POST['title'])){ + $oparr['key'] = M("AuthGroup")->where("id={$data['id']}")->field("title")->find()['title']; + $oparr['menu'] = "用户-管理组-角色权限-访问授权"; + }else{ + $oparr['key'] =$_POST['title']; + $oparr['menu'] = "用户-管理组-角色权限-基础信息编辑"; + } + addOperationLog($oparr); } if($r===false){ $this->error('操作失败'.$AuthGroup->getError()); @@ -284,7 +292,7 @@ class AuthManagerController extends AdminController{ "op_type"=>$op_type, "key"=> $v['title'], "menu"=>"用户-管理组-角色权限-".$op_name, - "url"=>U("User/index") + "url"=>U("AuthManager/index") )); } } @@ -406,7 +414,22 @@ class AuthManagerController extends AdminController{ if( $gid && !$AuthGroup->checkGroupId($gid)){ $this->error($AuthGroup->error); } - if ( $AuthGroup->addToGroup($uid,$gid) ){ + $flag = false; + try { + $flag = $AuthGroup->addToGroup($uid,$gid); + } catch (\Throwable $th) { + if(empty($AuthGroup->getError())){ + $this->error("操作失败:请确认添加的用户是否存在或已经有归属"); + }else{ + $this->error($AuthGroup->getError()); + } + } + if($flag){ + addOperationLog(array( + "op_type"=>1, + "key"=> M("AuthGroup")->where("id={$gid}")->field("title")->find()['title'], + "url"=>U("AuthManager/index") + )); $this->success('操作成功'); }else{ $this->error($AuthGroup->getError()); @@ -431,6 +454,11 @@ class AuthManagerController extends AdminController{ $this->error('用户组不存在'); } if ( $AuthGroup->removeFromGroup($uid,$gid) ){ + addOperationLog(array( + "op_type"=>1, + "key"=> M("AuthGroup")->where("id={$gid}")->field("title")->find()['title'], + "url"=>U("AuthManager/index") + )); $this->success('操作成功'); }else{ $this->error('操作失败'); @@ -455,6 +483,12 @@ class AuthManagerController extends AdminController{ $this->error($AuthGroup->error); } if ( $AuthGroup->addToCategory($gid,$cid) ){ + //操作日志 + addOperationLog(array( + "op_type"=>1, + "key"=> M("AuthGroup")->where("id={$gid}")->field("title")->find()['title'], + "url"=>U("AuthManager/index") + )); $this->success('操作成功',U('index')); }else{ $this->error('操作失败'); @@ -534,6 +568,12 @@ class AuthManagerController extends AdminController{ 'data_president'=>$promoteData, 'show_data'=>$show_data ))) { + addOperationLog(array( + "op_type"=>1, + "key"=> M("AuthGroup")->where("id={$gid}")->field("title")->find()['title'], + "menu"=>"用户-管理组-角色权限-数据授权", + "url"=>U("AuthManager/index") + )); $this->success('操作成功',U('AuthManager/index')); } else { $this->success('操作成功',U('AuthManager/index'));