From 07e4fb2e5648dca4a18e1591e61f40566b2ffd32 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 14 Jan 2020 10:01:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=97=E8=A1=A8=E5=92=8C?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=9D=83=E9=99=90=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/AdminController.class.php | 43 ++++++++++--------- .../Controller/MemberController.class.php | 26 ++--------- 2 files changed, 26 insertions(+), 43 deletions(-) diff --git a/Application/Admin/Controller/AdminController.class.php b/Application/Admin/Controller/AdminController.class.php index e05372468..7815625a3 100644 --- a/Application/Admin/Controller/AdminController.class.php +++ b/Application/Admin/Controller/AdminController.class.php @@ -634,28 +634,31 @@ class AdminController extends Controller { * @param [type] $type 0:"_list_check",1:"_count_check" * @return void */ - public function checkListOrCountAuth($type,$checkarr = false) - { - $flag = false; - if(IS_ROOT){ $flag=true; } - $suffix = $type=="list" ? "_list_check" :"_count_check"; - $rule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME.$suffix); - if($this->checkRule($rule,array('in','1,2'))){ - $flag = true; - } - if(!$flag && $checkarr){ - foreach ($checkarr as $v) { - if(isset($_REQUEST[$v])){ - $flag = true; - }; - } - } - if($type == "count"){ - $this->assign("rule_count_check",$flag); + public function checkListOrCountAuthRestMap(&$map,$checkarr = false,$countfield = "rule_count_check"){ + //验证count + if(IS_ROOT){ + $this->assign($countfield,true); }else{ - return $flag; + $countRule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME."_count_check"); + $this->assign($countfield,$this->checkRule($countRule,array('in','1,2'))); + //验证list + $listrule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME."_list_check"); + $listflag = $this->checkRule($listrule,array('in','1,2')); + if(!$listflag && $checkarr){ + foreach ($checkarr as $v) { + if(isset($map[$v])){ + //如果有模糊查询改精准查询 + if($map[$v][0] == "like"){ + $map[$v] = trim($map[$v][1],"%"); + } + $listflag = true; + }; + } + } + if(!$listflag){ + $map["_string"] = "1=0"; + } } - } } diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index 40548f3e6..1ba0f2a9d 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -54,13 +54,7 @@ class MemberController extends ThinkController $map['tab_user.id'] = $_REQUEST['user_id']; } if (isset($_REQUEST['account'])) { - //列表无权限要精准搜索 - if($this->checkListOrCountAuth("list")){ - $map['tab_user.account'] = ['like',I('account') . "%"]; - }else{ - $map['tab_user.account'] =I('account'); - } - + $map['tab_user.account'] = ['like',I('account') . "%"]; } if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { $map['tab_user.register_time'] = ['between', [strtotime(I('time_start')), strtotime(I('time_end')) + 86399]]; @@ -105,15 +99,6 @@ class MemberController extends ThinkController $map['tab_user.device_number'] = $_REQUEST['device_number']; } $promoteRoot = getPowerPromoteIds(); - -// $data_empower_type = session('user_auth')['data_empower_type']; -//// var_dump($promoteRoot);die(); -// -// if ($promoteRoot) { -// $map['tab_user.promote_id'] =array('in',$promoteRoot); -// } else if(!$promoteRoot&&$data_empower_type!=1){ -// $map['tab_user.id'] = array('lt',1); -// } setPowerPromoteIds($map,'tab_user.promote_id'); //1.3 与推广员相关 @@ -142,13 +127,8 @@ class MemberController extends ThinkController } } } - //判断列表权限 - $listauth = $this->checkListOrCountAuth("count"); - $listauth = $this->checkListOrCountAuth("list",["user_id","account","device_number"]); - if(!$listauth){ - //没权限 - $map['tab_user.id'] = 0; - } + //判断是否有列表和统计的权限 + $this->checkListOrCountAuthRestMap($map,["tab_user.id","tab_user.account","tab_user.device_number"]); //计算用户列表 $data = M("user","tab_")