Ejemplo n.º 1
0
 /**
  * 取得用户的角色ID
  * 
  * @return integer
  */
 public function getRoleId()
 {
     $roleKey = 'User_' . $this->getUserId() . '_roleId';
     if (!Zend_Registry::isRegistered($roleKey)) {
         if (null === $this->_userRow->findParentRow('ZtChart_Model_DbTable_Role') && ZtChart_Model_Role::ADMIN != $this->_userRow['user_roleid'] && ZtChart_Model_Role::GUEST != $this->_userRow['user_roleid']) {
             throw new ZtChart_Model_User_Exception('The user: '******' does not belong to any role.');
         }
         Zend_Registry::set($roleKey, $this->_userRow['user_roleid']);
     }
     return (int) Zend_Registry::get($roleKey);
 }
Ejemplo n.º 2
0
 /**
  * 取得角色所拥有的资源
  * 
  * @return ZtChart_Model_Db_Table_Rowset
  */
 public function getResources()
 {
     $resourceDAO = new ZtChart_Model_DbTable_Resource();
     $select = $resourceDAO->select()->order('resource_order');
     return $this->isAdmin() ? $resourceDAO->fetchAll($select->where('resource_parent = 0')) : (!empty($this->_roleRow) ? $this->_roleRow->findManyToManyRowset('ZtChart_Model_DbTable_Resource', 'ZtChart_Model_DbTable_Acl', null, null, $select) : array());
 }