Vanilla 1 Documentation Archive

 
 
vanilla:vanilla_role.html
Table of Contents

Class Library: People

Class Role extends Framework::Delegation

Overview


The Role class is a Delegation which represents a specific user role in memory. A role is a set of permissions controlling assigned users’ access to the forum.

Fields


RoleID

Numeric identifier for the role represented by a Role instance. The default value is ‘0’ (denoting a new role that isn’t stored in the database). (New role IDs are assigned for storage incrementally, starting at ‘1’.)

RoleName

The display name for a role.

Icon

A string denoting the location of an icon associated with the role.

Description

Contains information about the role, for aiding administrators in choosing the appropriate role for a user.

Permissions

An associative array of permission names to values (usually boolean) assigned to a role.

PERMISSION_SIGN_IN

Flag for whether users assigned to a role are permitted to log in to the forum.

PERMISSION_HTML_ALLOWED

Flag for whether users assigned to a role are permitted to use HTML in their comments.

PERMISSION_RECEIVE_APPLICATION_NOTIFICATION

Flag for whether users assigned to a role are permitted to receive notification of new membership applicants.

Unauthenticated

Flag for whether a role is defining permissions for users that are not logged in.

Methods


Role [constructor]

Signature
$Role = $Context->ObjectFactory->NewContextObject($Context, 'Role');
Description

Creates a new Role object using the given Context handle. This class will not behave properly without a valid Context.

Clear

Signature
[void] Clear()
Description

Resets a Role object to default values, and loads the Permissions array from the Context configuration. Permission names must begin with ‘PERMISSION_’ to be included.

Before returning, this method calls the ‘DefineRolePermissions’ delegate to allow extensions to define additional permission names.

FormatPropertiesForDatabaseInput

Signature
[void] FormatPropertiesForDatabaseInput()
Description

Serializes the Permissions array and formats the strings for database insertion/update. The hardcoded permissions (those listed with the fields above) are removed from the Permissions array prior to serialization.

FormatPropertiesForDisplay

Signature
[void] FormatPropertiesForDisplay()
Description

Applies the necessary formatting to display role information.

GetPropertiesFromDataSet

Signature
[void] GetPropertiesFromDataSet()
Description

Populates a Role object from a database row. The Permissions array is then deserialized, and the hardcoded permissions added to it.

GetPropertiesFromForm

Signature
[void] GetPropertiesFromForm()
Description

Reads the values posted from a role-update HTML form.

AddPermission

Signature
[void] AddPermission($PermissionKey)
Description

Adds a new permission name to the list of permissions that can be granted/revoked. The value to assign to the new permission is retrieved from the Context configuration.

Delegates


DefineRolePermissions

This delegate is called after a Role object is created, to allow new permission names to be defined (using the AddPermission method).

Delegate Parameters

None.

 
 
 
 
vanilla/vanilla_role.html.txt · Last modified: 2009/06/03 12:46 by sirlancelot
Vanilla 1 Documentation archive (Wiki by DokuWiki)