Esempio n. 1
0
 /**
  * 以指定的格式输出角色列表
  * 
  * @param integer|null $roleId 父角色ID
  * @param array $attributes 需要显示的HTML标签的属性
  * @param string $style 输出的HTML类型,为空则返回PHP数组
  * @param integer|null $count 总共取出多少数据
  * @param integer $offset 从哪一行开始取数据
  * @return string|array
  */
 public function roleList($roleId, $attributes = array(), $style = 'select', $count = null, $offset = 0)
 {
     $role = new ZtChart_Model_Role($roleId);
     $rowset = $role->getSelfAndChildRoles($count, $offset);
     if (empty($style)) {
         return $rowset->toArray();
     }
     return $this->_html($rowset, $style, $attributes);
 }
Esempio n. 2
0
 /**
  * 返回指定的角色名称
  * 
  * @param integer $roleId 角色数据表中的自增ID 
  * @return string
  */
 public function roleName($roleId)
 {
     $role = new ZtChart_Model_Role($roleId);
     return $role->getRoleName();
 }
Esempio n. 3
0
 /**
  * 取得指定角色的所有资源节点ID
  * 
  * @param integer $roleId
  * @return array:
  */
 public function findRoleSelfAndDescendants($roleId)
 {
     $resources = array();
     $role = new ZtChart_Model_Role($roleId);
     foreach ($role->getResourcesId() as $resourceId) {
         $resources = array_merge($resources, $this->findDescendants($resourceId), (array) $resourceId);
     }
     return $resources;
 }