/** * 在路由结束之后,载入权限分配表。 * * @see Zend_Controller_Request_Abstract::routeShutdown() * @param Zend_Controller_Plugin_Abstract $request * @return void */ public function routeShutdown(Zend_Controller_Request_Abstract $request) { $user = Zend_Registry::get('user'); $role = ZtChart_Model_Acl_Loader::hash($user->getRoleId()); Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($role); ZtChart_Model_Acl_Loader::getInstance()->load($this->_acl); Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($this->_acl); // 如果拥有全部游戏,则设置为NULL。 if (($gameTypes = $user->getRole()->getGameTypes(true)) == array_keys(ZtChart_Model_GameType::getGames())) { $gameTypes = null; } ZtChart_Model_Assemble_Backend_Abstract::setAllowedGameTypes($gameTypes); }
/** * 取得可访问的游戏类型 * * @param boolean $onlycode * @return array */ public function getGameTypes($onlycode = false) { $allowedGameTypes = ZtChart_Model_GameType::getGames(); if (!$this->isAdmin()) { $gameTypes = empty($this->_roleRow) ? array() : Zend_Json::decode($this->_roleRow->role_gametype); $allowedGameTypes = array_intersect_key($allowedGameTypes, array_fill_keys($gameTypes, null)); } if ($onlycode && is_array($allowedGameTypes)) { $allowedGameTypes = array_keys($allowedGameTypes); } return $allowedGameTypes; }