\Dvivier\SmarticopsRole

The Role model for the Smarticops features.

Summary

Methods
Properties
Constants
users()
permissions()
getName()
byName()
loadPermissions()
getPermissions()
givePermission()
hasPermission()
removePermission()
removeAllPermissions()
No public properties found
No constants found
No protected methods found
$dates
$_permissions
N/A
No private methods found
No private properties found
N/A

Properties

$dates

$dates : 

Type

$_permissions

$_permissions : array

Allows to temporarly store the permissions that a role has.

Avoids too many useless queries to the database

Type

array

Methods

users()

users() 

permissions()

permissions() 

getName()

getName() 

byName()

byName(  $name) : null

Retrieves a role by its name

Parameters

$name

string The name of the desired role

Returns

null —

if no role of this name

loadPermissions()

loadPermissions() 

Loads all the permissions associated to the role from the database.

To avoid too many requests to the DB

getPermissions()

getPermissions() 

givePermission()

givePermission(  $permissionCode, boolean  $value = true) 

Gives a specific permission to the role.

The permission must exist before giving it to the role. By default the permission is set to true, you may set it to false to explicitly mean that the role does NOT have that permission.

Parameters

$permissionCode
boolean $value

Value of the permission, usually true

hasPermission()

hasPermission(  $permissionCode) : boolean

Checks if a role has a permission or not.

Parameters

$permissionCode

the code of the permission to test

Returns

boolean —

true if the role has the permission

removePermission()

removePermission(string  $permissionCode) 

Removes a Permission from a role

Parameters

string $permissionCode

removeAllPermissions()

removeAllPermissions() 

Removes all the permissions from the role