CAccessRule
| Package |
system.web.auth |
| Inheritance |
class CAccessRule »
CComponent |
| Since |
1.0 |
| Version |
$Id: CAccessControlFilter.php 2192 2010-06-15 21:43:32Z alexander.makarow $ |
Public Properties
Hide inherited properties
| Property | Type | Description | Defined By |
| actions |
array |
list of action IDs that this rule applies to. |
CAccessRule |
| allow |
boolean |
whether this is an 'allow' rule or 'deny' rule. |
CAccessRule |
| controllers |
array |
list of controler IDs that this rule applies to. |
CAccessRule |
| expression |
string |
a PHP expression whose value indicates whether this rule should be applied. |
CAccessRule |
| ips |
array |
IP patterns. |
CAccessRule |
| message |
string |
the error message to be displayed when authorization is denied by this rule. |
CAccessRule |
| roles |
array |
list of roles this rule applies to. |
CAccessRule |
| users |
array |
list of user names that this rule applies to. |
CAccessRule |
| verbs |
array |
list of request types (e. |
CAccessRule |
Property Details
public array $actions;
list of action IDs that this rule applies to. The comparison is case-insensitive.
public boolean $allow;
whether this is an 'allow' rule or 'deny' rule.
public array $controllers;
list of controler IDs that this rule applies to. The comparison is case-insensitive.
public string $expression;
a PHP expression whose value indicates whether this rule should be applied.
In this expression, you can use $user which refers to Yii::app()->user.
Starting from version 1.0.11, the expression can also be a valid PHP callback,
including class method name (array(ClassName/Object, MethodName)),
or anonymous function (PHP 5.3.0+). The function/method signature should be as follows:
function foo($user, $rule) { ... }
where $user is the current application user object and $rule is this access rule.
public array $ips;
IP patterns.
public string $message;
the error message to be displayed when authorization is denied by this rule.
If not set, a default error message will be displayed.
public array $roles;
list of roles this rule applies to. For each role, the current user's
CWebUser::checkAccess method will be invoked. If one of the invocations
returns true, the rule will be applied.
Note, you should mainly use roles in an "allow" rule because by definition,
a role represents a permission collection.
public array $users;
list of user names that this rule applies to. The comparison is case-insensitive.
public array $verbs;
list of request types (e.g. GET, POST) that this rule applies to.
Method Details
protected boolean isActionMatched( CAction $action)
|
| $action |
CAction |
the action |
| {return} |
boolean |
whether the rule applies to the action |
protected boolean isControllerMatched( CAction $controller)
|
| $controller |
CAction |
the action |
| {return} |
boolean |
whether the rule applies to the action |
protected boolean isExpressionMatched( IWebUser $user)
|
| $user |
IWebUser |
the user |
| {return} |
boolean |
the expression value. True if the expression is not specified. |
|
protected boolean isIpMatched(string $ip)
|
| $ip |
string |
the IP address |
| {return} |
boolean |
whether the rule applies to the IP address |
protected boolean isRoleMatched( IWebUser $user)
|
| $user |
IWebUser |
the user object |
| {return} |
boolean |
whether the rule applies to the role |
|
|
| $user |
CWebUser |
the user object |
| $controller |
CController |
the controller currently being executed |
| $action |
CAction |
the action to be performed |
| $ip |
string |
the request IP address |
| $verb |
string |
the request verb (GET, POST, etc.) |
| {return} |
integer |
1 if the user is allowed, -1 if the user is denied, 0 if the rule does not apply to the user |
Checks whether the Web user is allowed to perform the specified action.
protected boolean isUserMatched( IWebUser $user)
|
| $user |
IWebUser |
the user |
| {return} |
boolean |
whether the rule applies to the user |
|
protected boolean isVerbMatched(string $verb)
|
| $verb |
string |
the request method |
| {return} |
boolean |
whether the rule applies to the request |