eZPublishCommunityProject(LegacyStack)  2013.6
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)
 Returns the attribute data for $attr, this is either returned from the member variables or a member function depending on whether the definition field or function attributes matched. More...
 
 attributes ()
 Returns the attributes for this object, taken from the definition fields and function attributes. More...
 
 eZPersistentObject ($row)
 Initializes the object with the $row. More...
 
 fill ($row)
 Tries to fill in the data in the object by using the object definition which is returned by the function definition() and the database row data $row. More...
 
 hasAttribute ($attr)
 Checks if $attr is part of the definition fields or function attributes. More...
 
 hasDirtyData ()
 Returns true if the data is considered dirty and needs to be stored. More...
 
 remove ($conditions=null, $extraConditions=null)
 Removes the object from the database, it will use the keys in the object definition to figure out which table row should be removed unless $conditions is defined as an array with fieldnames. More...
 
 setAttribute ($attr, $val)
 Sets the attribute $attr to the value $val. More...
 
 setHasDirtyData ($hasDirtyData)
 Sets whether the object has dirty data or not. More...
 
 store ($fieldFilters=null)
 Stores the object in the database, uses storeObject() to do the actual job and passes $fieldFilters to it. More...
 
 sync ($fieldFilters=null)
 Makes sure data is stored if the data is considered dirty. More...
 

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 ($ignoreNew=true)
 Fetches the count of created roles. More...
 
- Static Public Member Functions inherited from eZPersistentObject
static conditionText ($conditions)
 Calls conditionTextByRow with an empty row and $conditions. More...
 
static conditionTextByRow ($conditions, $row)
 Generates an SQL sentence from the conditions $conditions and row data $row. More...
 
static count ($def, $conds=null, $field=null)
 Fetches the number of rows by using the object definition. More...
 
static definition ()
 Returns the definition for the object, the default implementation is to return an empty array. More...
 
static escapeArray ($array)
 Escapes strings in an array with the help of eZDBInterface::escapeString(). More...
 
static fetchObject ($def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
 Fetches and returns an object based on the given parameters and returns is either as an object or as an array. More...
 
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)
 Creates an SQL query out of the different parameters and returns an array with the result. More...
 
static getShortAttributeName ($db, $def, $attrName)
 Returns the short attribute name (alias) if it's defined, given attribute name otherwise. More...
 
static handleRows ($rows, $class_name, $asObject)
 Creates PHP objects out of the database rows $rows. More...
 
static newObjectOrder ($def, $orderField, $conditions)
 Returns an order value which can be used for new items in table, for instance placement. More...
 
static removeObject ($def, $conditions=null, $extraConditions=null)
 Deletes the object from the table defined in $def with conditions $conditions and extra conditions $extraConditions. More...
 
static reorderObject ($def, $orderField, $conditions, $down=true)
 Moves a row in a database table. More...
 
static replaceFieldsWithShortNames ($db, $fieldDefs, &$fields)
 For the given array $fields treats its keys (for associative array) or values (for non-associative array) as table fields names and replaces them with short names (aliases) found in $fieldDefs. More...
 
static storeObject ($obj, $fieldFilters=null)
 Stores the data in $obj to database. More...
 
static swapRow ($table, $keys, $order_id, $rows, $id1, $id2)
 Sets row id $id2 to have the placement of row id $id1. More...
 
static updateObjectList ($parameters)
 Updates rows matching the given parameters. More...
 

Public Attributes

 $AccessArray
 
 $CachePolicies = true
 
 $Functions
 
 $ID
 
 $LimitIdentifier
 
 $LimitValue
 
 $Modules
 
 $Name
 
 $Policies
 
 $PolicyArray
 
 $Sets
 
 $UserRoleID
 
- Public Attributes inherited from eZPersistentObject
 $PersistentDataDirty
 

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 (   $ignoreNew = true)
static

Fetches the count of created roles.

Parameters
boolean$ignoreNewWether to ignore draft roles
Returns
int
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: