diff --git a/Application/Admin/Controller/AdminController.class.php b/Application/Admin/Controller/AdminController.class.php index 3c55719ff..7f4eadbc3 100644 --- a/Application/Admin/Controller/AdminController.class.php +++ b/Application/Admin/Controller/AdminController.class.php @@ -673,12 +673,15 @@ class AdminController extends Controller { */ public function addOperationLog($options) { - $checkarr = ['op_type','op_name','url','key']; + $checkarr = ['op_type','url','key']; foreach ($checkarr as $v) { if(!array_key_exists($v,$options)){ $this->error('操作日志添加,参数错误'); } } + if(!array_key_exists("op_name",$options)){ + $options['op_name'] = ($options['op_type'] == 1 ? "编辑" : ($options['op_type'] == 2 ? "删除" :"下载")); + } //获取ip $addarray = [ "op_ip"=>$_SERVER['REMOTE_ADDR'], diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index 8adfd8715..8c0094779 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -807,12 +807,7 @@ class MemberController extends ThinkController if ($res !== false) { \Think\Log::actionLog("Member/edit", "Member", $id); //操作日志 - $this->addOperationLog(array( - "op_type"=>1, - "op_name"=>"编辑用户信息", - "key"=>$this->getUserAccount($id), - "url"=>U("Member/user_info",array("user_id"=>$id)) - )); + $this->userEditOperationLog($id); $this->success("修改成功", U('user_info')); } else { @@ -1019,6 +1014,7 @@ class MemberController extends ThinkController ->where($map) ->setField('phone', $_POST['phone']); if ($pro !== false) { + $this->userEditOperationLog($user['id']); $this->ajaxReturn(array("status" => 1, "msg" => "手机修改成功")); } else { $this->ajaxReturn(array("status" => 0, "msg" => "手机修改失败")); @@ -1038,6 +1034,7 @@ class MemberController extends ThinkController ->where($map) ->setField('real_name', $_POST['real_name']); if ($pro !== false) { + $this->userEditOperationLog($_POST['id']); $this->ajaxReturn(array("status" => 1, "msg" => "真实姓名修改成功")); } else { $this->ajaxReturn(array("status" => 0, "msg" => "真实姓名修改失败")); @@ -1063,6 +1060,7 @@ class MemberController extends ThinkController ->where($map) ->setField('idcard', $_POST['idcard']); if ($pro !== false) { + $this->userEditOperationLog($_POST['id']); $this->ajaxReturn(array("status" => 1, "msg" => "身份证号码修改成功")); } else { $this->ajaxReturn(array("status" => 0, "msg" => "身份证号码修改失败")); @@ -1248,6 +1246,8 @@ class MemberController extends ThinkController foreach ($users as $item) { \Think\Log::actionLog('Member/lock_status', 'Member', $item['id']); } + $this->userEditOperationLog($id,"锁定/解锁"); + $this->success('操作成功!'); } else { $this->error('操作失败!'); @@ -1694,10 +1694,17 @@ class MemberController extends ThinkController return $this->success("解除成功"); } } - //获取用户账号 - public function getUserAccount($id) + public function userEditOperationLog($id,$op_name = false) { - return M("User","tab_")->field("account")->where("id='{$id}'")->find()['account']; + $option = array( + "op_type"=>1, + "key"=>get_user_account($id), + "url"=>U("Member/edit",array("id"=>$id)) + ); + if($op_name){ + $option['op_name'] = $op_name; + } + $this->addOperationLog($option); # code... } } \ No newline at end of file