/**
  * 判断是否有访问某个游戏的条件
  * 
  * @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;
 }
 /**
  * 覆盖
  */
 public function replaceAction()
 {
     if ($this->_request->isPost()) {
         if (Zend_Registry::isRegistered('Zend_Navigation')) {
             $container = Zend_Registry::get('Zend_Navigation');
             if ($container instanceof Zend_Navigation_Container) {
                 $resource = new ZtChart_System_Model_Resource();
                 $resource->import($container, 3);
                 ZtChart_Model_Acl_Loader::resetCache();
                 return;
             }
         }
         $this->_helper->dialog('数据追加错误', Zend_Log::ERR);
     }
 }
 /**
  * 扩展父类功能,设置默认缓存。
  */
 public function getCacheManager()
 {
     if (null != ($cacheManager = parent::getCacheManager())) {
         // 设置图表数据的缓存
         if ($cacheManager->hasCache('chart')) {
             ZtChart_Model_Assemble::setCache($cacheManager->getCache('chart'));
         }
         // 设置权限控制数据的缓存
         if ($cacheManager->hasCache('acl')) {
             ZtChart_Model_Acl_Loader::setCache($cacheManager->getCache('acl'));
         }
         // 设置IP数据的缓存
         if ($cacheManager->hasCache('ip')) {
             ZtChart_Model_Assemble_Ip::setCache($cacheManager->getCache('ip'));
         }
     }
     return $cacheManager;
 }
 /**
  * 设置权限
  */
 public function assignAction()
 {
     if (!$this->_hasParam('role_id')) {
         return $this->render('deny');
     }
     $roleId = $this->_getParam('role_id');
     $resourceAccess = new ZtChart_System_Model_Resource();
     $allowedResourceId = $resourceAccess->findRoleSelfAndDescendants(Zend_Registry::get('user')->getRoleId());
     $roleAccess = new ZtChart_System_Model_Role();
     if ($this->_request->isPost()) {
         if ($roleAccess->saveAcl($this->_request->getPost('resource_id'), $allowedResourceId, $roleId)) {
             ZtChart_Model_Acl_Loader::resetCache();
             $this->_helper->dialog('设置权限成功', Zend_Log::INFO);
         } else {
             $this->_helper->dialog('设置权限失败', Zend_Log::WARN);
         }
     }
     $this->view->resourceId = $roleAccess->fetchResourceId($roleId);
     $this->view->allowedResourceId = $allowedResourceId;
 }
Example #5
0
 /**
  * 获取当前角色
  * 
  * @return string
  */
 protected function _role()
 {
     try {
         $roleId = Zend_Registry::get('user')->getRoleId();
     } catch (ZtChart_Model_User_Exception $e) {
         $roleId = ZtChart_Model_Role::GUEST;
     }
     return ZtChart_Model_Acl_Loader::hash($roleId);
 }
Example #6
0
 /**
  * 返回一个实例
  * 
  * @static
  * @return ZtChart_Model_Acl_Loader
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }