/** * 编辑界面展示 */ public function editAction() { $rid = $this->getInput('rid'); $role = $this->_loadRoleService()->findRoleById($rid); if ($role instanceof PwError) { $this->showError($role->getError()); } /* @var $menuService AdminMenuService */ $menuService = Wekit::load('ADMIN:service.srv.AdminMenuService'); $auths = $menuService->getMenuTable(); $auths = AdminMenuHelper::resetMenuStruts($auths); //remove the admin right setting unset($auths['admin']); $roles = $this->_loadRoleService()->findRoles(); $_tmp = array(); foreach ($roles as $value) { $_tmp[$value['name']] = empty($value['auths']) ? array() : explode(',', $value['auths']); } $_cAuths = $_tmp[$role['name']]; $this->setOutput($_tmp, 'roleTable'); $this->setOutput($roles, 'roles'); $this->setOutput($_cAuths, 'cAuths'); $this->setOutput($role, 'role'); $this->setOutput($auths, 'auths'); }
public function run() { $menuService = Wekit::load('ADMIN:service.srv.AdminMenuService'); $userService = Wekit::load('ADMIN:service.srv.AdminUserService'); $myMenus = $userService->getAuths($this->loginUser); $menuTables = $menuService->getMenuTable(); if ($myMenus !== '-1') { foreach ($menuTables as $key => $value) { if (isset($value['url']) && !in_array($key, (array) $myMenus)) { unset($menuTables[$key]); } } } $menus = AdminMenuHelper::resetMenuStruts($menuTables); foreach ($menus as $key => $value) { if (isset($value['items']) && empty($value['items'])) { unset($menus[$key]); } } $this->setOutput($menus, 'menus'); $myMenu = $this->_loadCustomDs()->findByUsername($this->loginUser->username); $this->setOutput($myMenu ? explode(',', $myMenu['custom']) : array(), 'myMenu'); }
/** * 获得菜单数据table,该菜单节点table并不展示节点间的层级关系. * * 该方法解析所有扩展菜单表或者扩展菜单配置文件,并将菜单合并为一份完整的菜单table并返回. * * @example <code> 节点列表'admin' => array('admin', array()), * 'admin_install' => array('应用菜单安装', 'install/run', '', '', * 'admin'), * 'admin_auth' => array('菜单权限', 'auth/*', '', '', 'admin'),</code> * @return array */ private function _getMenuTable() { if ($this->menuTable === null) { /* @var $_configParser WindConfigParser */ $_configParser = Wind::getComponent('configParser'); // 'ADMIN:conf.mainmenu.php' $mainMenuConfFile = Wind::getRealPath(Wekit::app()->menuPath, true); $menus = $_configParser->parse($mainMenuConfFile); /* extend menus by file */ if (isset($menus['_extensions'])) { $_extensions = $menus['_extensions']; foreach ($_extensions as $_extName => $_ext) { if (!isset($_ext['resource'])) { continue; } $_tmp = Wind::getRealPath($_ext['resource'], true); $cacheKey .= filemtime($_tmp); $_extensions[$_extName]['resource'] = $_tmp; } unset($menus['_extensions']); } else { $_extensions = array(); } $menus = PwSimpleHook::getInstance('admin_menu')->runWithFilters($menus); foreach ($_extensions as $key => $value) { if (!isset($value['resource'])) { continue; } $_tmp = $_configParser->parse($value['resource']); $menus = WindUtility::mergeArray($menus, $_tmp); } AdminMenuHelper::verifyMenuConfig($menus, $menus, $this->menuTable); } return $this->menuTable; }