Exemplo n.º 1
0
 /**
  * 检查用户是否有访问权限
  * @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;
 }