Class X2PermissionsBehavior
CModelBehavior class for permissions lookups on classes.
X2PermissionsBehavior is a CModelBehavior which allows consistent lookup of access levels and whether or not a user is allowed to view or edit a record.
- CComponent
- CBehavior implements IBehavior
- CModelBehavior
- CActiveRecordBehavior
- ModelPermissionsBehavior
- X2PermissionsBehavior
Author: Jake Houser <jake@x2engine.com>, Demitri Morgan <demitri@x2engine.com> TODO: replace hard-coded references to ", " delimeter with Fields::MULTI_ASSIGNMENT_DELIM
Located at x2engine/protected/components/permissions/X2PermissionsBehavior.php
public
|
|
public
CDbCriteria
|
#
getAccessCriteria( mixed $tableAlias = 't', mixed $paramsNamespace = 'X2PermissionsBehavior', mixed $showHidden = false )
Returns a CDbCriteria containing record-level access conditions. |
public
array
|
|
public
integer
|
#
getAccessLevel( mixed $uid = null )
Returns a number from 0 to 3 representing the current user's access level using the Yii auth manager. Assumes authItem naming scheme like "ContactsViewPrivate", etc. This method probably ought to overridden, as there is no reliable way to determine the module a model "belongs" to. |
public
type
|
|
public
|
|
public static
type
|
|
public
String
|
#
getAccessConditions( Integer $accessLevel, mixed $tableAlias = 't', mixed $paramsNamespace = 'X2PermissionsBehavior', mixed $showHidden = false )
Generates SQL condition to filter out records the user doesn't have permission to see. |
public
boolean
|
#
isAssignedTo( string $username, boolean $excludeAnyone = false )
Checks assignment list, including membership to groups in assignment list |
public
|
|
public
type
|
#
isVisibleTo(
Uses the visibility attribute and the assignment of the model to determine if a given named user has permission to view it. |
public
array
|
#
getAssignedToCondition( boolean $includeAnyone = true, mixed $alias = null, mixed $username = null, mixed $paramsNamespace = 'X2PermissionsBehavior' )
Returns SQL condition which can be used to determine if an action is assigned
to the |
public
|
|
public
array
|
#
getAssignees( boolean $getUsernamesFromGroups = false )
Determines all users to whom a record is assigned. |
public static
string
|
#
getGroupIdRegex( mixed $username = null )
Returns regex for performing SQL assignedTo field comparisons. |
public static
|
|
public static
|
getUserNameRegex()
|
afterDelete(),
afterFind(),
afterSave(),
beforeCount(),
beforeDelete(),
beforeFind(),
beforeSave(),
events()
|
afterConstruct(),
afterValidate(),
beforeValidate()
|
attach(),
detach(),
getEnabled(),
getOwner(),
setEnabled()
|
__call(),
__get(),
__isset(),
__set(),
__unset(),
asa(),
attachBehavior(),
attachBehaviors(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
detachBehavior(),
detachBehaviors(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
getEventHandlers(),
hasEvent(),
hasEventHandler(),
hasProperty(),
raiseEvent()
|
integer |
QUERY_ALL
|
3 |
#
The access level for administrators. |
integer |
QUERY_PUBLIC
|
2 |
#
The access level for users granted general access. |
integer |
QUERY_SELF
|
1 |
#
The access level for users granted "private" access. |
integer |
QUERY_NONE
|
0 |
#
The access level for users granted no access. |
integer |
VISIBILITY_PRIVATE
|
0 |
#
This visibility value implies "private"; ordinarily visible only to assignee(s)/owner(s) of the record |
integer |
VISIBILITY_PUBLIC
|
1 |
#
This visibility setting implies the record is public/shared, and anyone can view. |
integer |
VISIBILITY_GROUPS
|
2 |
#
This visibility setting implies that the record is visible to the owners and other members of groups to which the owners belong ("groupmates"). |
string |
SQL_PARAMS_PREFIX
|
'X2PermissionsBehavior' |
#
Used to prefix sql parameters to prevent parameter name conflicts |
public
string
|
$assignmentAttr |
#
Name of the attribute to use for permissions |
public
string
|
$visibilityAttr |
#
Name of the attribute to use for visibility setting |
$owner
|
$enabled
|