/**
  * 判断是否有访问某个游戏的条件
  * 
  * @see Zend_Acl_Assert_Interface::assert()
  */
 public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
 {
     if ($this->_request->has('gametype')) {
         $roleData = ZtChart_Model_Acl_Loader::getInstance()->getRole($role->getRoleId());
         return in_array($this->_request->getParam('gametype'), $roleData['role_gametype']);
     }
     return true;
 }
Example #2
0
 /**
  * 在路由结束之后,载入权限分配表。
  * 
  * @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);
 }