Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
eZTemplateRoleOperator Class Reference

## Public Member Functions
| __construct ()
| operatorList ()
| namedParameterPerOperator ()
| namedParameterList ()
| modify ( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
| isMemberOfRole ( $userId, $roleName)
| isMemberOfRoleId ( $userId, $roleId)
| isMemberOfAnyRole ( $userId, $roles, $matchAll=false)
| userHasPolicy ( $userId, $module, $function)

## Static Public Member Functions
static | memberOfRoleByUser ( $user, $roleID)
static | memberOfRoleByUserId ( $userID, $roleID)
static | hasPolicyByUser ( $user, $module, $function)

## Private Attributes
| $Operators

## Detailed Description

The eZTemplateRoleOperator class provides template operators for checking user role membership

Template usage examples: {if $current_user|has_role('Administrator')} {if $current_user|has_role_id(1)} {if $current_user|has_any_role(array('Editor', 'Administrator'))} {if $current_user|has_any_role(array(1, 2, 3))} {if $current_user|has_any_role(array('Editor', 2, 'Publisher'), match_all=true())} {if $user_object|has_role_by_user(1)} {if 42|has_role_by_user_id(1)}

Definition at line 23 of file eztemplateroleoperator.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZTemplateRoleOperator::__construct | ( |  | ) |

Constructor

Definition at line 35 of file eztemplateroleoperator.php.

## Member Function Documentation

## ◆ hasPolicyByUser()

static eZTemplateRoleOperator::hasPolicyByUser | ( |  | $user,
|  |  | $module,
|  |  | $function
| ) |  |
| static

Check if user object has a specific policy by module and function

Parameters

  eZUser | $user | User object
  string | $module | Policy module name (e.g., 'content', 'user')
  string | $function | Policy function name (e.g., 'read', 'edit', 'create')

Returns
  bool True if user has the policy, false otherwise

Definition at line 584 of file eztemplateroleoperator.php.

Referenced by modify().

## ◆ isMemberOfAnyRole()

eZTemplateRoleOperator::isMemberOfAnyRole | ( |  | $userId,
|  |  | $roles,
|  |  | $matchAll = `false`
| ) |  |

Check if user is member of any role from provided roles (by name or ID)

Parameters

  int | $userId | User ID
  array | $roles | Array of role names (strings) or role IDs (integers)
  bool | $matchAll | If true, user must have all roles; if false, user must have at least one role

Returns
  bool True if condition is met, false otherwise

Definition at line 364 of file eztemplateroleoperator.php.

References eZUser\fetch().

Referenced by modify().

## ◆ isMemberOfRole()

eZTemplateRoleOperator::isMemberOfRole | ( |  | $userId,
|  |  | $roleName
| ) |  |

Check if user is member of a specific role by role name

Parameters

  int | $userId | User ID
  string | $roleName | Role name to check

Returns
  bool True if user has the role, false otherwise

Definition at line 297 of file eztemplateroleoperator.php.

References eZPersistentObject\attribute(), and eZUser\fetch().

Referenced by modify().

## ◆ isMemberOfRoleId()

eZTemplateRoleOperator::isMemberOfRoleId | ( |  | $userId,
|  |  | $roleId
| ) |  |

Check if user is member of a specific role by role ID

Parameters

  int | $userId | User ID
  int | $roleId | Role ID to check

Returns
  bool True if user has the role, false otherwise

Definition at line 330 of file eztemplateroleoperator.php.

References eZPersistentObject\attribute(), and eZUser\fetch().

Referenced by modify().

## ◆ memberOfRoleByUser()

static eZTemplateRoleOperator::memberOfRoleByUser | ( |  | $user,
|  |  | $roleID
| ) |  |
| static

Return true if user roles of the provided user object match provided roleID

Parameters

  eZUser | $user | User object
  int | $roleID | Role ID to check

Returns
  bool True if user roles contain a match of the roleID parameter, false otherwise

Definition at line 459 of file eztemplateroleoperator.php.

References memberOfRoleByUserId().

Referenced by modify().

## ◆ memberOfRoleByUserId()

static eZTemplateRoleOperator::memberOfRoleByUserId | ( |  | $userID,
|  |  | $roleID
| ) |  |
| static

Return true if user roles of the provided userID match provided roleID

Parameters

  int | $userID | User content object ID
  int | $roleID | Role ID to check

Returns
  bool True if user roles contain a match of the roleID parameter, false otherwise

Definition at line 480 of file eztemplateroleoperator.php.

References eZPersistentObject\attribute(), and eZUser\fetch().

Referenced by memberOfRoleByUser(), and modify().

## ◆ modify()

eZTemplateRoleOperator::modify | ( |  | $tpl,
|  |  | $operatorName,
|  |  | $operatorParameters,
|  |  | $rootNamespace,
|  |  | $currentNamespace,
|  | & | $operatorValue,
|  |  | $namedParameters
| ) |  |

Executes the operator

Parameters

  eZTemplate | $tpl | Template object
  string | $operatorName | The operator name
  array | $operatorParameters | Operator parameters
  string | $rootNamespace | Root namespace
  string | $currentNamespace | Current namespace
  mixed | &$operatorValue | The value to operate on
  array | $namedParameters | Named parameters

Definition at line 190 of file eztemplateroleoperator.php.

References eZUser\currentUserID(), hasPolicyByUser(), isMemberOfAnyRole(), isMemberOfRole(), isMemberOfRoleId(), memberOfRoleByUser(), memberOfRoleByUserId(), and userHasPolicy().

## ◆ namedParameterList()

eZTemplateRoleOperator::namedParameterList | ( |  | ) |

Returns the named parameters for each operator

Returns
  array

Definition at line 74 of file eztemplateroleoperator.php.

## ◆ namedParameterPerOperator()

eZTemplateRoleOperator::namedParameterPerOperator | ( |  | ) |

Returns true to tell the template engine that the parameter list exists per operator type

Returns
  bool

Definition at line 64 of file eztemplateroleoperator.php.

## ◆ operatorList()

eZTemplateRoleOperator::operatorList | ( |  | ) |

Returns the operators in this class

Returns
  array

Definition at line 53 of file eztemplateroleoperator.php.

References $Operators.

## ◆ userHasPolicy()

eZTemplateRoleOperator::userHasPolicy | ( |  | $userId,
|  |  | $module,
|  |  | $function
| ) |  |

Check if user has a specific policy by module and function

Parameters

  int | $userId | User ID
  string | $module | Policy module name (e.g., 'content', 'user')
  string | $function | Policy function name (e.g., 'read', 'edit', 'create')

Returns
  bool True if user has the policy, false otherwise

Definition at line 517 of file eztemplateroleoperator.php.

References eZUser\fetch().

Referenced by modify().

## Member Data Documentation

## ◆ $Operators

eZTemplateRoleOperator::$Operators
| private

Definition at line 30 of file eztemplateroleoperator.php.

Referenced by operatorList().

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

- eztemplateroleoperator.php

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