\Roles

The Roles class

Handles the roles in the system. Used in conjunction with the Permissions and Users class.

Summary

Methods
Properties
Constants
__construct()
create()
applyPermissionToRole()
getRoleIdByName()
getRoleNameById()
removePermissionOnRole()
getPermissionsByCategory()
getPermissionCategories()
No public properties found
NAME
ID
DESCRIPTION
DEFINITION
No protected methods found
No protected properties found
N/A
No private methods found
$db_handle
N/A

Constants

NAME

NAME

ID

ID

DESCRIPTION

DESCRIPTION

DEFINITION

DEFINITION

Properties

$db_handle

$db_handle : 

Type

Methods

__construct()

__construct(  $db_handle) 

Create a Roles handler object

Parameters

$db_handle

create()

create(  $roleName,   $roleDescription = "") 

Creates a new role and enters it into the system

Parameters

$roleName

the name of the role

$roleDescription

the description (optional)

applyPermissionToRole()

applyPermissionToRole(  $roleId,   $permissionId) : true

Assigns the given permission to the role selected

Parameters

$roleId

the id of the role to assign the permission to

$permissionId

the id of the permission to assign

Returns

true —

if successful, otherwise false

getRoleIdByName()

getRoleIdByName(  $name) : \the

Retrieves the role Id using the name provided

Parameters

$name

Returns

\the —

id or 0 if nothing found

getRoleNameById()

getRoleNameById(  $role_id) : \the

Retrieves the role name using the id provided

Parameters

$role_id

Returns

\the —

name

removePermissionOnRole()

removePermissionOnRole(  $roleId,   $permissionId) 

Parameters

$roleId
$permissionId

getPermissionsByCategory()

getPermissionsByCategory(  $roleId,   $catId) : \an

Gets the permission under a specified category for this role. If nothing found, returns NULL otherwise an array.

The array is a key value pair in the form of: permission name => definition

Parameters

$roleId

the id of the role being requested

$catId

the id of the category of permissions

Returns

\an —

array defined as above, or NULL

getPermissionCategories()

getPermissionCategories(  $roleId) : \an

Gets an array of categories associated with the given role

Parameters

$roleId

the id of the role being requested

Returns

\an —

array of category ids