system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.cubrid system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.gii system.i18n system.i18n.gettext system.logging system.test system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.form system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers zii.behaviors zii.widgets zii.widgets.grid zii.widgets.jui

CAuthItem

system.web.auth
继承 class CAuthItem » CComponent
可用自 1.0
源码 framework/web/auth/CAuthItem.php
CAuthItem represents an authorization item. An authorization item can be an operation, a task or a role. They form an authorization hierarchy. Items on higher levels of the hierarchy inherit the permissions represented by items on lower levels. A user may be assigned one or several authorization items (called assignments. He can perform an operation only when it is among his assigned items.

公共属性

隐藏继承的属性

属性类型描述被定义在
authManager IAuthManager the authorization manager CAuthItem
bizRule string the business rule associated with this item CAuthItem
children array Returns the children of this item. CAuthItem
data mixed the additional data associated with this item CAuthItem
description string the item description CAuthItem
name string the item name CAuthItem
type integer the authorization item type. CAuthItem

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. CComponent
__construct() Constructor. CAuthItem
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
addChild() Adds a child item. CAuthItem
asa() Returns the named behavior object. CComponent
assign() Assigns this item to a user. CAuthItem
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
checkAccess() Checks to see if the specified item is within the hierarchy starting from this item. CAuthItem
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
evaluateExpression() Evaluates a PHP expression or callback under the context of this component. CComponent
getAssignment() Returns the item assignment information. CAuthItem
getAuthManager() Returns the authorization manager CAuthItem
getBizRule() Returns the business rule associated with this item CAuthItem
getChildren() Returns the children of this item. CAuthItem
getData() Returns the additional data associated with this item CAuthItem
getDescription() Returns the item description CAuthItem
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getName() Returns the item name CAuthItem
getType() Returns the authorization item type. This could be 0 (operation), 1 (task) or 2 (role). CAuthItem
hasChild() Returns a value indicating whether a child exists CAuthItem
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
isAssigned() Returns a value indicating whether this item has been assigned to the user. CAuthItem
raiseEvent() Raises an event. CComponent
removeChild() Removes a child item. CAuthItem
revoke() Revokes an authorization assignment from a user. CAuthItem
setBizRule() Sets the business rule associated with this item CAuthItem
setData() Sets the additional data associated with this item CAuthItem
setDescription() Sets the item description CAuthItem
setName() Sets the item name CAuthItem

属性详情

authManager 属性 只读

the authorization manager

bizRule 属性
public string getBizRule()
public void setBizRule(string $value)

the business rule associated with this item

children 属性 只读
public array getChildren()

Returns the children of this item.

data 属性
public mixed getData()
public void setData(mixed $value)

the additional data associated with this item

description 属性
public string getDescription()
public void setDescription(string $value)

the item description

name 属性
public string getName()
public void setName(string $value)

the item name

type 属性 只读
public integer getType()

the authorization item type. This could be 0 (operation), 1 (task) or 2 (role).

方法详情

__construct() 方法
public void __construct(IAuthManager $auth, string $name, integer $type, string $description='', string $bizRule=NULL, mixed $data=NULL)
$auth IAuthManager authorization manager
$name string authorization item name
$type integer authorization item type. This can be 0 (operation), 1 (task) or 2 (role).
$description string the description
$bizRule string the business rule associated with this item
$data mixed additional data for this item
源码: framework/web/auth/CAuthItem.php#53 (显示)
public function __construct($auth,$name,$type,$description='',$bizRule=null,$data=null)
{
    
$this->_type=(int)$type;
    
$this->_auth=$auth;
    
$this->_name=$name;
    
$this->_description=$description;
    
$this->_bizRule=$bizRule;
    
$this->_data=$data;
}

Constructor.

addChild() 方法
public boolean addChild(string $name)
$name string the name of the child item
{return} boolean whether the item is added successfully
源码: framework/web/auth/CAuthItem.php#191 (显示)
public function addChild($name)
{
    return 
$this->_auth->addItemChild($this->_name,$name);
}

Adds a child item.

assign() 方法
public CAuthAssignment assign(mixed $userId, string $bizRule=NULL, mixed $data=NULL)
$userId mixed the user ID (see IWebUser::getId)
$bizRule string the business rule to be executed when checkAccess is called for this particular authorization item.
$data mixed additional data associated with this assignment
{return} CAuthAssignment the authorization assignment information.
源码: framework/web/auth/CAuthItem.php#239 (显示)
public function assign($userId,$bizRule=null,$data=null)
{
    return 
$this->_auth->assign($this->_name,$userId,$bizRule,$data);
}

Assigns this item to a user.

checkAccess() 方法
public boolean checkAccess(string $itemName, array $params=array ( ))
$itemName string the name of the item to be checked
$params array the parameters to be passed to business rule evaluation
{return} boolean whether the specified item is within the hierarchy starting from this item.
源码: framework/web/auth/CAuthItem.php#71 (显示)
public function checkAccess($itemName,$params=array())
{
    
Yii::trace('Checking permission "'.$this->_name.'"','system.web.auth.CAuthItem');
    if(
$this->_auth->executeBizRule($this->_bizRule,$params,$this->_data))
    {
        if(
$this->_name==$itemName)
            return 
true;
        foreach(
$this->_auth->getItemChildren($this->_name) as $item)
        {
            if(
$item->checkAccess($itemName,$params))
                return 
true;
        }
    }
    return 
false;
}

Checks to see if the specified item is within the hierarchy starting from this item. This method is expected to be internally used by the actual implementations of the IAuthManager::checkAccess.

getAssignment() 方法
public CAuthAssignment getAssignment(mixed $userId)
$userId mixed the user ID (see IWebUser::getId)
{return} CAuthAssignment the item assignment information. Null is returned if this item is not assigned to the user.
源码: framework/web/auth/CAuthItem.php#273 (显示)
public function getAssignment($userId)
{
    return 
$this->_auth->getAuthAssignment($this->_name,$userId);
}

Returns the item assignment information.

getAuthManager() 方法
public IAuthManager getAuthManager()
{return} IAuthManager the authorization manager
源码: framework/web/auth/CAuthItem.php#90 (显示)
public function getAuthManager()
{
    return 
$this->_auth;
}

getBizRule() 方法
public string getBizRule()
{return} string the business rule associated with this item
源码: framework/web/auth/CAuthItem.php#147 (显示)
public function getBizRule()
{
    return 
$this->_bizRule;
}

getChildren() 方法
public array getChildren()
{return} array all child items of this item.
源码: framework/web/auth/CAuthItem.php#224 (显示)
public function getChildren()
{
    return 
$this->_auth->getItemChildren($this->_name);
}

Returns the children of this item.

getData() 方法
public mixed getData()
{return} mixed the additional data associated with this item
源码: framework/web/auth/CAuthItem.php#167 (显示)
public function getData()
{
    return 
$this->_data;
}

getDescription() 方法
public string getDescription()
{return} string the item description
源码: framework/web/auth/CAuthItem.php#127 (显示)
public function getDescription()
{
    return 
$this->_description;
}

getName() 方法
public string getName()
{return} string the item name
源码: framework/web/auth/CAuthItem.php#106 (显示)
public function getName()
{
    return 
$this->_name;
}

getType() 方法
public integer getType()
{return} integer the authorization item type. This could be 0 (operation), 1 (task) or 2 (role).
源码: framework/web/auth/CAuthItem.php#98 (显示)
public function getType()
{
    return 
$this->_type;
}

hasChild() 方法
public boolean hasChild(string $name)
$name string the child item name
{return} boolean whether the child exists
源码: framework/web/auth/CAuthItem.php#214 (显示)
public function hasChild($name)
{
    return 
$this->_auth->hasItemChild($this->_name,$name);
}

Returns a value indicating whether a child exists

isAssigned() 方法
public boolean isAssigned(mixed $userId)
$userId mixed the user ID (see IWebUser::getId)
{return} boolean whether the item has been assigned to the user.
源码: framework/web/auth/CAuthItem.php#261 (显示)
public function isAssigned($userId)
{
    return 
$this->_auth->isAssigned($this->_name,$userId);
}

Returns a value indicating whether this item has been assigned to the user.

removeChild() 方法
public boolean removeChild(string $name)
$name string the child item name
{return} boolean whether the removal is successful
源码: framework/web/auth/CAuthItem.php#203 (显示)
public function removeChild($name)
{
    return 
$this->_auth->removeItemChild($this->_name,$name);
}

Removes a child item. Note, the child item is not deleted. Only the parent-child relationship is removed.

revoke() 方法
public boolean revoke(mixed $userId)
$userId mixed the user ID (see IWebUser::getId)
{return} boolean whether removal is successful
源码: framework/web/auth/CAuthItem.php#250 (显示)
public function revoke($userId)
{
    return 
$this->_auth->revoke($this->_name,$userId);
}

Revokes an authorization assignment from a user.

setBizRule() 方法
public void setBizRule(string $value)
$value string the business rule associated with this item
源码: framework/web/auth/CAuthItem.php#155 (显示)
public function setBizRule($value)
{
    if(
$this->_bizRule!==$value)
    {
        
$this->_bizRule=$value;
        
$this->_auth->saveAuthItem($this);
    }
}

setData() 方法
public void setData(mixed $value)
$value mixed the additional data associated with this item
源码: framework/web/auth/CAuthItem.php#175 (显示)
public function setData($value)
{
    if(
$this->_data!==$value)
    {
        
$this->_data=$value;
        
$this->_auth->saveAuthItem($this);
    }
}

setDescription() 方法
public void setDescription(string $value)
$value string the item description
源码: framework/web/auth/CAuthItem.php#135 (显示)
public function setDescription($value)
{
    if(
$this->_description!==$value)
    {
        
$this->_description=$value;
        
$this->_auth->saveAuthItem($this);
    }
}

setName() 方法
public void setName(string $value)
$value string the item name
源码: framework/web/auth/CAuthItem.php#114 (显示)
public function setName($value)
{
    if(
$this->_name!==$value)
    {
        
$oldName=$this->_name;
        
$this->_name=$value;
        
$this->_auth->saveAuthItem($this,$oldName);
    }
}