/** * 获取有权限的菜单列表 * * @return array */ public static function getMenus() { $res = []; $authInfo = self::getLoginInfo(); if (!$authInfo) { //登录超时 return $res; } Model::getInstance()->db()->table(['menus' => 'm'])->columns(['distinct m.id', 'm.pid', 'm.title', 'm.url']); //当前登录用户是否为超级管理员 if (!self::isSuperUser()) { Model::getInstance()->db()->join(['access' => 'a'], 'a.menuid=m.id')->lBrackets()->whereIn('a.groupid', $authInfo['groupid'])->_or()->where('a.userid', $authInfo['id'])->rBrackets()->_and(); } $result = Model::getInstance()->db()->where('m.isshow', 1)->orderBy('m.sort', 'DESC')->orderBy('m.id', 'ASC')->limit(0, 5000)->select(); $res = Tree::getTreeNoFormat($result, 0); return $res; }
/** * 获取有权限的菜单列表 * * @return array */ public static function getMenus() { $res = array(); $authInfo = self::getLoginInfo(); if (!$authInfo) { return $res; } //登录超时 Model::getInstance()->db()->table(array('menus' => 'm'))->columns(array('m.id', 'm.pid', 'm.title', 'm.url')); //当前登录用户是否为超级管理员 if (Config::get('administratorid') !== intval($authInfo['id'])) { Model::getInstance()->db()->join(array('access' => 'a'), 'a.menuid=m.id')->lBrackets()->where('a.groupid', $authInfo['groupid'])->_or()->where('a.userid', $authInfo['id'])->rBrackets()->_and(); } $result = Model::getInstance()->db()->where('m.isshow', 1)->orderBy('m.sort', 'DESC')->orderBy('m.id', 'ASC')->limit(0, 2000)->select(); $res = Tree::getTreeNoFormat($result, 0); return $res; }