eZPublish  4.4
eZRole Class Reference

A container for policies in the permission system. More...

+ Inheritance diagram for eZRole:
+ Collaboration diagram for eZRole:

Public Member Functions

 accessArray ($ignoreLimitIdentifier=false)
 
 appendPolicy ($module, $function, $limitations=array())
 
 assignToUser ($userID, $limitIdent= '', $limitValue= '')
 
 copy ()
 
 copyPolicies ($roleID)
 
 createTemporaryVersion ()
 
 eZRole ($row=array())
 
 fetchUserByRole ()
 
 fetchUserID ()
 
 limitIdentifier ()
 
 limitValue ()
 
 policyList ()
 
 removePolicies ($fromDB=true)
 
 removePolicy ($moduleName, $functionName=false)
 
 removeThis ()
 
 removeUserAssignment ($userID)
 
 removeUserAssignmentByID ($id)
 
 revertFromTemporaryVersion ()
 
 turnOffCaching ()
 
 turnOnCaching ()
 
 userRoleID ()
 
- Public Member Functions inherited from eZPersistentObject
 attribute ($attr, $noFunction=false)
 
 attributes ()
 
 eZPersistentObject ($row)
 
 fill ($row)
 
 hasAttribute ($attr)
 
 hasDirtyData ()
 
 remove ($conditions=null, $extraConditions=null)
 
 setAttribute ($attr, $val)
 
 setHasDirtyData ($hasDirtyData)
 
 store ($fieldFilters=null)
 
 sync ($fieldFilters=null)
 

Static Public Member Functions

static accessArrayByUserID ($idArray, $recursive=false)
 Return access array by passing in list of groups user belongs to and his user id. More...
 
static cleanupByNode ($node)
 
static create ($roleName, $version=0)
 
static createNew ()
 
static definition ()
 
static expireCache ()
 
static fetch ($roleID, $version=0)
 
static fetchByName ($roleName, $version=0)
 
static fetchByOffset ($offset, $limit, $asObject=true, $ignoreTemp=false, $ignoreNew=true)
 
static fetchByUser ($idArray, $recursive=false)
 Returns the roles matching the given users' eZContentObject ID array. More...
 
static fetchIDListByUser ($idArray)
 Fetches the list of roles ID matching an array of eZContentObject IDs (either users and/or groups IDs) More...
 
static fetchList ($tempVersions=false)
 
static fetchRolesByLimitation ($limit_identifier, $limit_value)
 
static removeRole ($roleID)
 
static removeTemporary ()
 
static roleCount ()
 
- Static Public Member Functions inherited from eZPersistentObject
static conditionText ($conditions)
 
static conditionTextByRow ($conditions, $row)
 
static count ($def, $conds=null, $field=null)
 
static definition ()
 
static escapeArray ($array)
 
static fetchObject ($def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
 
static fetchObjectList ($def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
 
static getShortAttributeName ($db, $def, $attrName)
 
static handleRows ($rows, $class_name, $asObject)
 
static newObjectOrder ($def, $orderField, $conditions)
 
static removeObject ($def, $conditions=null, $extraConditions=null)
 
static reorderObject ($def, $orderField, $conditions, $down=true)
 
static swapRow ($table, $keys, $order_id, $rows, $id1, $id2)
 
static updateObjectList ($parameters)
 

Public Attributes

 $AccessArray
 
 $CachePolicies = true
 
 $Functions
 
 $ID
 
 $LimitIdentifier
 
 $LimitValue
 
 $Modules
 
 $Name
 
 $Policies
 
 $PolicyArray
 
 $Sets
 
 $UserRoleID
 
- Public Attributes inherited from eZPersistentObject
 $PersistentDataDirty
 Whether the data is dirty, ie needs to be stored, or not. More...
 

Detailed Description

A container for policies in the permission system.

It consists merely of a name() and has a DB id() and a version() number. The actual permissions are stored in policies and policy values which can be fetched with the method policyList().

To fetch permission access array you can use accessArrayByUserID() and accessArray().

There are multiple ways to fetch a role, directly from an id() with fetch(), by a role name() with fetchByName(), by a given user with fetchByUser() or the whole list with fetchList() and fetchByOffset().

Creating roles is done with create(), after which new policies can be added using appendPolicy().

Remove roles with remove() and its policies with removePolicies().

Member Function Documentation

eZRole::accessArray (   $ignoreLimitIdentifier = false)

Fetch access array of current role

Referenced by accessArrayByUserID().

static eZRole::accessArrayByUserID (   $idArray,
  $recursive = false 
)
static

Return access array by passing in list of groups user belongs to and his user id.

Parameters
array$idArrayArray of eZContentObject IDs, either groups + user id or user id's only If only user id's, then remember to set $recursive to true
bool$recursiveSee eZRole::fetchByUser()
Returns
array Hash with complete access limitation description

Referenced by eZUser\generateAccessArray().

eZRole::appendPolicy (   $module,
  $function,
  $limitations = array() 
)

Appends a new policy to the current role and returns it.

Note
The policy and it's limitation values will be stored to the database before returning.
Parameters
$moduleWhich module to give access to or true to give access to all modules.
$functionWhich function to give access to or true to give access to all functions.
$limitationsAn associative array with limitations and their values, use an empty array for no limitations.
// Access to content/read
$policy1 = $role->appendPolicy( 'content', 'read' );
// Access to content/read in section 1
$policy2 = $role->appendPolicy( 'content', 'read', array( 'Section' => 1 ) );
// Access to content/read for class 2 and 5
$policy3 = $role->appendPolicy( 'content', 'read', array( 'Class' => array( 2, 5 ) ) );
Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
eZRole::assignToUser (   $userID,
  $limitIdent = '',
  $limitValue = '' 
)

Assigns the current role to the given user or user group identified by the id.

Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
WARNING: Roles and content caches need to be cleared after calling this function.
static eZRole::cleanupByNode (   $node)
static

Cleans up policies and role assignments related to node when this node is removed

Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Referenced by eZContentObjectTreeNode\removeThis().

eZRole::copy ( )

Copies this role, stores it and returns it.

Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
eZRole::copyPolicies (   $roleID)

Copies all policies for this role and assigns them to the role identified by ID $roleID.

Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Referenced by copy(), and createTemporaryVersion().

static eZRole::create (   $roleName,
  $version = 0 
)
static

Creates a new role with the name $roleName and version $version and returns it.

Note
The role is not stored.

Referenced by eZSiteInstaller\addPoliciesForRole(), eZStepCreateSites\initializePackage(), and eZSiteInstaller\updateRoles().

static eZRole::createNew ( )
static

Creates a new role with the name 'New role', stores it and returns it.

Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Referenced by copy(), and createTemporaryVersion().

eZRole::createTemporaryVersion ( )
Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
static eZRole::definition ( )
static
static eZRole::expireCache ( )
static

Expires all roles, policies and limitations cache.

Referenced by cleanupByNode(), and eZContentObjectTreeNode\move().

eZRole::eZRole (   $row = array())

Constructor

Referenced by create(), createNew(), and fetchByUser().

static eZRole::fetch (   $roleID,
  $version = 0 
)
static

Fetches the role identified by the role ID $roleID and returns it.

Parameters
$versionWhich version to fetch, 0 is the published one. Temporary versions get the id of the role.

Referenced by eZRoleFunctionCollection\fetchRole(), fetchRolesByLimitation(), removeRole(), and revertFromTemporaryVersion().

static eZRole::fetchByName (   $roleName,
  $version = 0 
)
static

Fetches the role identified by the role name $roleName and returns it.

Parameters
$versionWhich version to fetch, 0 is the published one and 1 is the temporary.

Referenced by eZSiteInstaller\addPoliciesForRole(), eZSiteInstaller\assignUserToRole(), eZSiteInstaller\createSiteAccess(), eZStepCreateSites\initializePackage(), eZSiteInstaller\removePoliciesForRole(), and eZSiteInstaller\updateRoles().

static eZRole::fetchByOffset (   $offset,
  $limit,
  $asObject = true,
  $ignoreTemp = false,
  $ignoreNew = true 
)
static
static eZRole::fetchByUser (   $idArray,
  $recursive = false 
)
static

Returns the roles matching the given users' eZContentObject ID array.

Parameters
array$idArrayArray of eZContentObject IDs, either groups + user id or user id's only If only user id's, then remember to set $recursive to true
bool$recursiveIf true, roles will be looked up for all nodes of the id's and it's parents
Returns
array(eZRole)

Referenced by accessArrayByUserID(), eZUserFunctionCollection\fetchMemberOf(), eZUserFunctionCollection\fetchUserRole(), and eZUser\roles().

static eZRole::fetchIDListByUser (   $idArray)
static

Fetches the list of roles ID matching an array of eZContentObject IDs (either users and/or groups IDs)

Parameters
array(eZContentObjectID)$idArray
Returns
array(eZRoleID)

Referenced by eZUser\generateUserCacheForFile(), and eZUser\roleIDList().

static eZRole::fetchList (   $tempVersions = false)
static

Referenced by removeTemporary().

static eZRole::fetchRolesByLimitation (   $limit_identifier,
  $limit_value 
)
static
eZRole::fetchUserByRole ( )
Returns
the users and user groups assigned to the current role.
eZRole::fetchUserID ( )

Fetch user id array which have been assigned to this role.

eZRole::limitIdentifier ( )

Returns the limit identifier if it is set.

Note
This will only be available when fetching roles for a specific user
See Also
limitValue
eZRole::limitValue ( )

Returns the limit value if it is set.

Note
This will only be available when fetching roles for a specific user
See Also
limitIdentifier
eZRole::policyList ( )

Referenced by removePolicy().

eZRole::removePolicies (   $fromDB = true)

Removes the policy object list from this role.

Parameters
$fromDBIf true then the policies are removed from database.
Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.

Referenced by revertFromTemporaryVersion().

eZRole::removePolicy (   $moduleName,
  $functionName = false 
)

Removes the policy object(s) by specified $moduleName and/or $functionName. Removes all policies for module $moduleName if $functionName is false.

Parameters
$moduleNameModule name
$functionNamefunction name. Default is false.
Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
static eZRole::removeRole (   $roleID)
static
See Also
removeThis
static eZRole::removeTemporary ( )
static

Removes all temporary roles and roles without policies from the database.

Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
eZRole::removeThis ( )

Removes the role, it's policies and any assignments to users/groups.

Parameters
$roleIDIf this is false then the function is not static and the ID is fetched from $this.
Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
eZRole::removeUserAssignment (   $userID)

Removes the role assignment

Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
WARNING: Roles and content caches need to be cleared after calling this function.
eZRole::removeUserAssignmentByID (   $id)

Remove ezuser_role by id

Parameters
ezuser_roleid
Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
WARNING: Roles and content caches need to be cleared after calling this function.
eZRole::revertFromTemporaryVersion ( )
Note
Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit.
static eZRole::roleCount ( )
static
Returns
the number of roles in the database.
eZRole::turnOffCaching ( )

Sets caching of policies to off for this role.

eZRole::turnOnCaching ( )

Sets caching of policies to on for this role.

eZRole::userRoleID ( )

Returns the user role ID if it is set.

Note
This will only be available when fetching roles for a specific user
See Also
userRoleID

Member Data Documentation

eZRole::$AccessArray
eZRole::$CachePolicies = true
eZRole::$Functions
eZRole::$ID
eZRole::$LimitIdentifier

Referenced by limitIdentifier().

eZRole::$LimitValue

Referenced by limitValue().

eZRole::$Modules
eZRole::$Name
eZRole::$Policies

Referenced by policyList().

eZRole::$PolicyArray
eZRole::$Sets
eZRole::$UserRoleID

Referenced by userRoleID().


The documentation for this class was generated from the following file: