优化列表和统计权限函数

master
chenzhi 5 years ago
parent 4e1567f013
commit 07e4fb2e56

@ -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";
}
}
}
}

@ -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_")

Loading…
Cancel
Save