public function handle_request_internel() { $userlevel = Bll_Authority::get_user_level($this->get_user_id()); if (intval($userlevel) === Const_Cms::CMS_USER_LEVEL_SUPPER) { //只有超级管理员可以访问 $params = $this->getParam(); $DataCount = Bll_Authority::get_user_info_by_authority_count($params['searchText']); if ($DataCount > 0) { $page = isset($params['p']) ? intval($params['p']) : 1; if ($this->request->is_post_method()) { $page = 1; } $page_size = 10; $show_num = 10; $DataInfo = Bll_Authority::get_user_info_by_authority($params['searchText'], $page, $page_size); $this->setAttribute('datainfo', $DataInfo); $m_url = $this->build_url(__CLASS__); $this->set_multipage($page, $page_size, $DataCount, $m_url, $show_num, $params); } $this->setAttribute('params', $params); $this->setAttribute('Count', $DataCount); } else { $cUrl = $this->build_url("/error"); $this->response->redirect($cUrl); exit; } $this->setAttribute('user_id', $this->get_user_id()); return 'Permissions_Authority'; }
public function handle_request_internel() { $params = $this->getParam(); $DataCount = Bll_Authority::get_groupinfo_count($params['searchText']); if ($DataCount > 0) { $page = isset($params['p']) ? (int) $params['p'] : 1; if ($this->request->is_post_method()) { $page = 1; } $page_size = 25; $show_num = 10; $DataInfo = Bll_Authority::get_groupinfo($params['searchText'], $page, $page_size); $this->setAttribute('datainfo', $DataInfo); $group_id_str = $this->returnStrKey($DataInfo, 'id'); if (!empty($group_id_str)) { //获取各个角色的成员数量 $groupCountArr = Bll_Authority::get_userinfo($group_id_str); if (!empty($groupCountArr)) { //根据组ID重组数组数据 $groupCountArr = Tool_Array::init_new_arr_by_key($groupCountArr, 'group_id'); $this->setAttribute('groupCountArr', $groupCountArr); } } $m_url = $this->build_url(__CLASS__); $this->set_multipage($page, $page_size, $DataCount, $m_url, $show_num, $params); } $this->setAttribute('params', $params); $this->setAttribute('Count', $DataCount); return 'Permissions_RoleList'; }
private function AddData($params) { $rolename = $params['rolename']; unset($params['rolename']); $menusArr = array_keys($params); $ch_groupname = Bll_Authority::check_group_info_by_group_name($rolename); if (empty($ch_groupname)) { //添加角色表 $data = array('group_name' => $rolename, 'operation_name' => $this->get_user_name(), 'operation_id' => $this->get_user_id(), 'status' => '1', 'create_time' => time()); $result = BLL_Authority::insert_group_info($data); //给角色添加菜单权限表 if (!empty($menusArr)) { foreach ($menusArr as $menusArrVal) { $AddAuthoritydata = array('group_id' => $result, 'menu_code' => $menusArrVal, 'operation_name' => $this->get_user_name(), 'operation_id' => $this->get_user_id(), 'status' => '1', 'create_time' => time()); BLL_Authority::insert_authority_info($AddAuthoritydata); } } $url = $this->build_url(__CLASS__, array('action' => 0)); $this->response->redirect($url); exit; } else { //表示用户名已存在 $url = $this->build_url(__CLASS__, array('action' => 1)); $this->response->redirect($url); exit; } }
public function handle_request_internel() { $params = $this->getParam(); //修改角色权限 if (!empty($params['modify'])) { $userlevel = Bll_Authority::get_user_level($this->get_user_id()); if (!empty($userlevel)) { $roleid = $params['roleid']; $rolename = $params['rolename']; //获取权限菜单,删除不必要的参数 $params = $this->unsetParams($params); $updategroupwhere = array('id' => $roleid); $updategroupset = array('group_name' => $rolename); Bll_Authority::update_group_info($updategroupset, $updategroupwhere); $menusArr = array_keys($params); //删除原来菜单权限 $whereArr = array('group_id' => $roleid); $setArr = array('status' => 0); Bll_Authority::update_authority_info($setArr, $whereArr); //给角色添加菜单权限表 if (!empty($menusArr)) { foreach ($menusArr as $menusArrVal) { $AddAuthoritydata = array('group_id' => $roleid, 'menu_code' => $menusArrVal, 'operation_name' => $this->get_user_name(), 'operation_id' => $this->get_user_id(), 'status' => '1', 'create_time' => time()); BLL_Authority::insert_authority_info($AddAuthoritydata); } } echo "<script>alert('修改成功!')</script>"; $cUrl = $this->build_url("/permissions/rolelist", array()); $this->response->redirect($cUrl); exit; } else { echo "<script>alert('无权限操作!')</script>"; } } if (!empty($params['roleid'])) { $existmenu = BLL_Authority::get_all_menus_by_group_id($params['roleid']); $existmenuArr = $this->init_arr_exist_menus($existmenu); $this->setAttribute('existmenuArr', $existmenuArr); } //拼接树形菜单 $menusparent = APF::get_instance()->get_config('big_menus', 'menus'); $menusinfo = Bll_Authority::get_tree_menus(); $menu_arr = array_merge($menusparent, $menusinfo); $dataarr = $this->Tree_Arr($menu_arr); $TreeArr = $this->unset_Invalid_data($dataarr['treeArr'][0]); $maxdeep = $dataarr['maxdeep']; //最小菜单级别数 //传递值到页面 $this->setAttribute('params', $params); $this->setAttribute('TreeArr', $TreeArr); $this->setAttribute('maxdeep', $maxdeep); return 'Permissions_RoleInfo'; }
private function _edit_user($params) { if (!empty($params['userid']) && !empty($params['groupid']) && !empty($params['groupname'])) { $data = array('citys' => implode(',', $params['citys']), 'group_id' => $params['groupid'], 'group_name' => $params['groupname']); $whereArr = array('user_id' => $params['userid']); $result = Bll_Authority::update_user_info($data, $whereArr); if ($result) { $_res = array("code" => "success", "mes" => "成功!", "info" => $result); } else { $_res = array("code" => "fail", "mes" => "无权操作!", "info" => $result); } echo json_encode($_res); exit; } }
public function handle_request_internel() { $params = $this->getParam(); $res = $this->_res; switch ($params['page']) { case 'authority': $userlevel = Bll_Authority::get_user_level($this->get_user_id()); if ($userlevel != Const_Cms::CMS_USER_LEVEL_SUPPER) { //不是超级管理员 $res = $this->init_res('', false); } else { if (!empty($params['userid']) && !empty($params['level'])) { $data = array('level' => $params['level']); $whereArr = array('user_id' => $params['userid']); $result = Bll_Authority::update_user_info($data, $whereArr); $res = $this->init_res($result); } } break; case 'delete': //删除用户 $userlevel = Bll_Authority::get_user_level($this->get_user_id()); if ($userlevel != Const_Cms::CMS_USER_LEVEL_SUPPER) { //不是超级管理员 $res = $this->init_res('', false); } else { if ($params['userid'] == $this->get_user_id()) { //不可以删除自己 $res = $this->init_res('', false); } if (!empty($params['userid'])) { $result = Bll_Authority::delete_user_info_by_user_id($params['userid']); $res = $this->init_res($result); } } break; default: $res = $this->_res; break; } echo json_encode($res); exit; }
/** * 检查用户是否有访问权限 * @param $itemCode * @param $selfMenuArr 权限菜单code * @param $userlevel 用户等级 * @return bool */ private function _check_authority($itemCode, &$selfMenuArr, &$userlevel) { $userinfo = $this->_userInfo; if (empty($userinfo)) { return false; } $this->userlevel = $userlevel = $userinfo['level']; $selfMenuArr = Bll_Authority::get_all_menus_by_group_id($userinfo['group_id']); $selfMenu = Bll_Menus::init_menus_arr($selfMenuArr); $isSupperMan = intval($userlevel) == Const_Cms::CMS_USER_LEVEL_SUPPER ? true : false; //标记系统设置是否需要展示 if ($isSupperMan || in_array('G004', $selfMenu)) { $this->setAttribute('system_show_' . $this->get_user_id(), true); } $itemCodeCur = str_replace('_', '', $itemCode); if (!$isSupperMan) { //超级管理员不需要判断是否有访问权限 //城市权限判断 $cityid = $this->get_city_id(); $this->setAttribute('setcookiecityid', $cityid); $selfcityArr = array_filter(explode(',', $userinfo['citys'])); $cityAuthority = true; if (!empty($cityid)) { if (!in_array($cityid, $selfcityArr)) { //不能访问的城市 $cityAuthority = false; } } else { $cityAuthority = false; } if (strlen($itemCode) == Const_Cms::CMS_YIJI_MENU_CODE_LEN) { //如果是各个app首页,直接返回true if (!$cityAuthority) { //如果是不能访问的城市,菜单则不显示 $selfMenuArr = array(); } return true; } if (!$cityAuthority) { return false; } if (!in_array($itemCodeCur, $selfMenu)) { //不能访问的菜单 return false; } } return true; }
/** * 根据用户ID获取用户权限 * @return array|bool */ public function get_user_level() { return Bll_Authority::get_user_level(self::get_user_id()); }