Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
eZRole Class Reference
Role based permission system

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

Inheritance diagram for eZRole:

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

## Static Public Member Functions
static | definition ()
static | createNew ()
static | create ( $roleName, $version=0)
static | removeTemporary ()
static | removeRole ( $roleID)
static | cleanupByNode ( $node)
static | fetchByUser ( $idArray, $recursive=false)
static | expireCache ()
static | accessArrayByUserID ( $idArray, $recursive=false)
static | fetchIDListByUser ( $idArray)
static | fetchRolesByLimitation ( $limit_identifier, $limit_value)
static | fetch ( $roleID, $version=0)
static | fetchByName ( $roleName, $version=0)
static | fetchList ( $tempVersions=false)
static | fetchByOffset ( $offset, $limit, $asObject=true, $ignoreTemp=false, $ignoreNew=true)
static | roleCount ( $ignoreNew=true)
Static Public Member Functions inherited from eZPersistentObject
static | replaceFieldsWithShortNames (eZDBInterface $db, array $fieldDefs, &$fields)
static | count ( $def, $conds=null, $field=null)
static | fetchObject ( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
static | removeObject ( $def, $conditions=null, $extraConditions=null)
static | storeObject ( $obj, $fieldFilters=null)
static | conditionText ( $conditions)
static | conditionTextByRow ( $conditions, $row)
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 | handleRows ( $rows, $class_name, $asObject)
static | swapRow ( $table, $keys, $order_id, $rows, $id1, $id2)
static | newObjectOrder ( $def, $orderField, $conditions)
static | reorderObject ( $def, $orderField, $conditions, $down=true)
static | escapeArray ( $array)
static | updateObjectList ( $parameters)
static | getShortAttributeName ( $db, $def, $attrName)

## Public Attributes
| $ID
| $Name
| $Modules
| $Functions
| $LimitValue
| $LimitIdentifier
| $UserRoleID
| $PolicyArray
| $Sets
| $Policies
| $AccessArray
| $CachePolicies = true
| $Version
| $IsNew
Public Attributes inherited from eZPersistentObject
| $PersistentDataDirty
| $ID
| $ContentObjectID
| $SectionID
| $OwnerID
| $ClassID
| $Published
| $Modified
| $CurrentVersion
| $Status
| $RemoteID
| $LanguageMask
| $InitialLanguageID
| $NodeID
| $ParentNodeID
| $MainNodeID
| $ContentObjectVersion
| $ContentObjectIsPublished
| $Depth
| $SortField
| $SortOrder
| $Priority
| $ModifiedSubNode
| $PathString
| $PathIdentificationString
| $IsHidden
| $IsInvisible
| $UserID
| $Name
| $Locale
| $Identifier
| $NavigationPartIdentifier
| $SerializedDescriptionList
| $URLAliasName
| $AlwaysAvailable
| $CanTranslate
| $DataInt1
| $DataInt2
| $DataInt3
| $DataInt4
| $DataFloat1
| $DataFloat2
| $DataFloat3
| $DataFloat4
| $DataText1
| $DataText2
| $DataText3
| $DataText4
| $DataText5
| $SerializedDataText
| $Category
| $PolicyID
| $Values
| $Created
| $CurrencyCode
| $ProductCollectionID
| $ItemCount
| $Price
| $IsVATIncluded
| $VATValue
| $DiscountValue
| $Email
| $IsTemporary
| $IsArchived
| $IsActive
| $OrderID
| $ModifierID
| $Code
| $Symbol
| $AutoRateValue
| $CustomRateValue
| $RateFactor
| $Main
| $MementoKey
| $MainKey
| $WorkflowEventPos
| $LanguageID
| $ContentObjectStateGroupID
| $contentobject_attribute_id
| $contentobject_id
| $rating
| $rating_count
| $rating_average

## Additional Inherited Members
Static Protected Member Functions inherited from eZPersistentObject
static | replaceFieldsWithLongNames (eZDBInterface $db, array $fieldDefs, &$fields)

## 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().

Definition at line 34 of file ezrole.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZRole::__construct | ( |  | $row = `array()` | ) |

Initializes the object with the $row.

It will try to set each field taken from the database row. Calls fill to do the job. If $row is an integer, it will try to fetch it from the database using it as the unique ID.

Parameters

  int | array | $row |

Reimplemented from eZPersistentObject.

Definition at line 36 of file ezrole.php.

## Member Function Documentation

## ◆ accessArray()

eZRole::accessArray | ( |  | $ignoreLimitIdentifier = `false` | ) |

Fetch access array of current role

Definition at line 630 of file ezrole.php.

References eZPersistentObject\attribute().

Referenced by accessArrayByUserID().

## ◆ 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 | $idArray | Array 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 | $recursive | See eZRole::fetchByUser()

Returns
  array Hash with complete access limitation description

Definition at line 587 of file ezrole.php.

References accessArray(), eZPersistentObject\attribute(), and fetchByUser().

Referenced by eZUser\generateAccessArray().

## ◆ appendPolicy()

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

  $module | Which module to give access to or `true` to give access to all modules.
  $function | Which function to give access to or `true` to give access to all functions.
  $limitations | An 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.

Definition at line 195 of file ezrole.php.

References eZPersistentObject\count(), eZPolicy\create(), and eZDB\instance().

## ◆ assignToUser()

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.

Definition at line 702 of file ezrole.php.

References eZPersistentObject\attribute(), eZPersistentObject\count(), eZContentObject\fetch(), eZContentObjectTreeNode\fetch(), eZDB\instance(), and eZAudit\writeAudit().

## ◆ cleanupByNode()

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.

Definition at line 418 of file ezrole.php.

References eZPersistentObject\count(), expireCache(), eZPolicy\fetch(), eZPolicyLimitation\findByType(), and eZDB\instance().

Referenced by eZContentObjectTreeNode\removeThis().

## ◆ copy()

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.

Definition at line 115 of file ezrole.php.

References eZPersistentObject\attribute(), copyPolicies(), createNew(), eZDB\instance(), and ezpI18n\tr().

## ◆ copyPolicies()

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.

Definition at line 225 of file ezrole.php.

References eZPersistentObject\attribute(), and eZDB\instance().

Referenced by copy(), and createTemporaryVersion().

## ◆ create()

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.

Definition at line 167 of file ezrole.php.

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

## ◆ createNew()

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.

Definition at line 154 of file ezrole.php.

References ezpI18n\tr().

Referenced by copy(), and createTemporaryVersion().

## ◆ 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.

Definition at line 133 of file ezrole.php.

References eZPersistentObject\attribute(), copyPolicies(), createNew(), and eZDB\instance().

## ◆ definition()

static eZRole::definition | ( |  | ) |
| static

Returns the definition for the object, the default implementation is to return an empty array. It's upto each inheriting class to return a proper definition array.

The definition array is an associative array consists of these keys:

- fields: an associative array of fields which defines which database field (the key) is to fetched and how they map to object member variables (the value).
- keys: an array of fields which is used for uniquely identifying the object in the table.
- function_attributes: an associative array of attributes which maps to member functions, used for fetching data with functions.
- set_functions: an associative array of attributes which maps to member functions, used for setting data with functions.
- increment_key: the field which is incremented on table inserts.
- class_name: the classname which is used for instantiating new objecs when fetching from the database.
- sort: an associative array which defines the default sorting of lists, the key is the table field while the value is the sorting method which is either 'asc' or 'desc'.
- name: the name of the database table

Example: `public static function definition() { return array( "fields" => array( "id" => "ID", "version" => "Version", "name" => "Name" ), "keys" => array( "id", "version" ), "function_attributes" => array( "current" => "currentVersion", "class_name" => "className" ), "increment_key" => "id", "class_name" => "eZContentClass", "sort" => array( "id" => "asc" ), "name" => "ezcontentclass" ); }`

Returns
  array

Reimplemented from eZPersistentObject.

Definition at line 50 of file ezrole.php.

Referenced by fetch(), fetchByName(), fetchByOffset(), fetchList(), eZPolicy\role(), and roleCount().

## ◆ expireCache()

static eZRole::expireCache | ( |  | ) |
| static

Expires all roles, policies and limitations cache.

Definition at line 568 of file ezrole.php.

References eZUser\cleanupCache(), and eZHTTPTool\instance().

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

## ◆ fetch()

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

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

Parameters

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

Definition at line 866 of file ezrole.php.

References definition(), and eZPersistentObject\fetchObject().

Referenced by fetchRolesByLimitation(), removeRole(), and revertFromTemporaryVersion().

## ◆ fetchByName()

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

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

Parameters

  $version | Which version to fetch, 0 is the published one and 1 is the temporary.

Definition at line 881 of file ezrole.php.

References definition(), and eZPersistentObject\fetchObject().

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

## ◆ fetchByOffset()

static eZRole::fetchByOffset | ( |  | $offset,
|  |  | $limit,
|  |  | $asObject = `true`,
|  |  | $ignoreTemp = `false`,
|  |  | $ignoreNew = `true`
| ) |  |
| static

Definition at line 904 of file ezrole.php.

References definition(), and eZPersistentObject\fetchObjectList().

## ◆ fetchByUser()

static eZRole::fetchByUser | ( |  | $idArray,
|  |  | $recursive = `false`
| ) |  |
| static

Returns the roles matching the given users' eZContentObject ID array

Parameters

  array | $idArray | Array 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 | $recursive | If true, roles will be looked up for all nodes of the id's and it's parents

Returns
  array(eZRole)

Definition at line 500 of file ezrole.php.

References eZPersistentObject\count(), eZContentObjectTreeNode\fetchByContentObjectID(), and eZDB\instance().

Referenced by accessArrayByUserID(), and eZUser\roles().

## ◆ fetchIDListByUser()

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)

Definition at line 677 of file ezrole.php.

References eZDB\instance().

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

## ◆ fetchList()

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

Definition at line 888 of file ezrole.php.

References definition(), and eZPersistentObject\fetchObjectList().

Referenced by removeTemporary().

## ◆ fetchRolesByLimitation()

static eZRole::fetchRolesByLimitation | ( |  | $limit_identifier,
|  |  | $limit_value
| ) |  |
| static

Definition at line 835 of file ezrole.php.

References eZContentObject\fetch(), fetch(), and eZDB\instance().

Referenced by eZSection\canBeRemoved().

## ◆ fetchUserByRole()

eZRole::fetchUserByRole | ( |  | ) |

Returns
  the users and user groups assigned to the current role.

Definition at line 805 of file ezrole.php.

References eZContentObject\fetch(), and eZDB\instance().

## ◆ fetchUserID()

eZRole::fetchUserID | ( |  | ) |

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

Definition at line 759 of file ezrole.php.

References eZDB\instance().

## ◆ hasPolicy()

eZRole::hasPolicy | ( |  | $moduleName,
|  |  | $functionName = `false`
| ) |  |

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

Parameters

  $moduleName | Module name
  $functionName | function 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.

Definition at line 244 of file ezrole.php.

References eZPersistentObject\count(), eZDB\instance(), and policyList().

## ◆ limitIdentifier()

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

Definition at line 85 of file ezrole.php.

References $LimitIdentifier.

## ◆ 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

Definition at line 95 of file ezrole.php.

References $LimitValue.

## ◆ policyList()

eZRole::policyList | ( |  | ) |

Definition at line 643 of file ezrole.php.

References $Policies, eZPersistentObject\attribute(), eZPolicy\definition(), and eZPersistentObject\fetchObjectList().

Referenced by hasPolicy(), and removePolicy().

## ◆ removePolicies()

eZRole::removePolicies | ( |  | $fromDB = `true` | ) |

Removes the policy object list from this role.

Parameters

  $fromDB | If `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.

Definition at line 362 of file ezrole.php.

References eZPersistentObject\attribute(), and eZDB\instance().

Referenced by revertFromTemporaryVersion().

## ◆ removePolicy()

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

  $moduleName | Module name
  $functionName | function 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.

Definition at line 385 of file ezrole.php.

References eZPersistentObject\count(), eZDB\instance(), and policyList().

## ◆ removeRole()

static eZRole::removeRole | ( |  | $roleID | ) |
| static

See also
  removeThis

Definition at line 328 of file ezrole.php.

References fetch().

## ◆ removeTemporary()

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.

Definition at line 311 of file ezrole.php.

References fetchList(), and eZDB\instance().

## ◆ removeThis()

eZRole::removeThis | ( |  | ) |

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

Parameters

  $roleID | If 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.

Definition at line 343 of file ezrole.php.

References eZPersistentObject\attribute(), and eZDB\instance().

## ◆ removeUserAssignment()

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.

Definition at line 775 of file ezrole.php.

References eZDB\instance().

## ◆ removeUserAssignmentByID()

eZRole::removeUserAssignmentByID | ( |  | $id | ) |

Remove ezuser_role by id

Parameters

  ezuser_role | 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.

Definition at line 793 of file ezrole.php.

References eZDB\instance().

## ◆ revertFromTemporaryVersion()

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.

Definition at line 277 of file ezrole.php.

References eZPersistentObject\attribute(), fetch(), eZDB\instance(), removePolicies(), eZPersistentObject\setAttribute(), and eZPersistentObject\store().

## ◆ roleCount()

static eZRole::roleCount | ( |  | $ignoreNew = `true` | ) |
| static

Fetches the count of created roles

Parameters

  boolean | $ignoreNew | Wether to ignore draft roles

Returns
  int

Definition at line 933 of file ezrole.php.

References eZPersistentObject\count(), and definition().

## ◆ turnOffCaching()

eZRole::turnOffCaching | ( |  | ) |

Sets caching of policies to off for this role.

Definition at line 946 of file ezrole.php.

## ◆ turnOnCaching()

eZRole::turnOnCaching | ( |  | ) |

Sets caching of policies to on for this role.

Definition at line 954 of file ezrole.php.

## ◆ userRoleID()

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

Definition at line 105 of file ezrole.php.

References $UserRoleID.

## Member Data Documentation

## ◆ $AccessArray

eZRole::$AccessArray

Definition at line 971 of file ezrole.php.

## ◆ $CachePolicies

eZRole::$CachePolicies = true

Definition at line 972 of file ezrole.php.

## ◆ $Functions

eZRole::$Functions

Definition at line 964 of file ezrole.php.

## ◆ $ID

eZRole::$ID

Definition at line 961 of file ezrole.php.

## ◆ $IsNew

eZRole::$IsNew

Definition at line 974 of file ezrole.php.

## ◆ $LimitIdentifier

eZRole::$LimitIdentifier

Definition at line 966 of file ezrole.php.

Referenced by limitIdentifier().

## ◆ $LimitValue

eZRole::$LimitValue

Definition at line 965 of file ezrole.php.

Referenced by limitValue().

## ◆ $Modules

eZRole::$Modules

Definition at line 963 of file ezrole.php.

## ◆ $Name

eZRole::$Name

Definition at line 962 of file ezrole.php.

## ◆ $Policies

eZRole::$Policies

Definition at line 970 of file ezrole.php.

Referenced by policyList().

## ◆ $PolicyArray

eZRole::$PolicyArray

Definition at line 968 of file ezrole.php.

## ◆ $Sets

eZRole::$Sets

Definition at line 969 of file ezrole.php.

## ◆ $UserRoleID

eZRole::$UserRoleID

Definition at line 967 of file ezrole.php.

Referenced by userRoleID().

## ◆ $Version

eZRole::$Version

Definition at line 973 of file ezrole.php.

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

- ezrole.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.