/** * 获取经过检测权限的菜单 * @param $menus 菜单数组 */ public function getActMenus($menus) { if (!is_array($menus)) { return array(); } $this->_userSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession'); foreach ($menus as $key => &$val) { if (isset($val['child'])) { if ($val['display'] == false) { unset($menus[$key]); continue; } if ($this->_userSession->checkAct($key) != 1) { unset($menus[$key]); continue; } foreach ($val['child'] as $childKey => &$childVal) { if ($childVal['display'] == false) { unset($val['child'][$childKey]); continue; } if ($this->_userSession->checkAct($childKey) != 1) { unset($val['child'][$childKey]); continue; } $childVal['url'] = url(str_replace('_', '/', $childKey)); } } } return $menus; }
/** * 初始化 */ public function cIndex() { $this->_userSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession'); define('VIEW_PAGE', 'system/common/main'); //默认显示主页面 define('SUCCESS', 1); define('ERROR', -2); define('WARNING', -1); define('CUR_ACT', __MODULE__ . '_' . __CONTROL__ . '_' . __ACTION__); $act = $this->_userSession->checkAct(CUR_ACT); $msg = array(-1 => '您没有权限', -2 => '您还未登录'); $url = array(-1 => 1, -2 => url('index/index/login')); if ($act != 1) { $this->error($msg[$act], $url[$act]); } }