HandleRole
A trait that provides various role handling functions for beans that have associated roles.
A role is a <rolecontext, rolename> tuple.
Table of Contents
- addrole() : OODBBean
- Add a role
- addRoleByBean() : OODBBean
- Add a role
- checkrole() : array<, mixed>
- Check that user has one of a set of roles
- delrole() : void
- Delete a role
- editroles() : void
- Deal with the role selecting part of a form
- hasrole() : object|null
- Check for a role
- hasRoleByBean() : object|null
- Check for a role by bean
- roles() : array<, OODBBean>
- Get all currently valid roles for this bean
Methods
addrole()
Add a role
public
addrole(string $contextname, string $rolename, string $otherinfo, string $start[, string $end = '' ]) : OODBBean
Parameters
- $contextname : string
-
The name of a context...
- $rolename : string
-
The name of a role....
- $otherinfo : string
-
Any other info that is to be stored with the role
- $start : string
-
A datetime
- $end : string = ''
-
A datetime or ''
Tags
Return values
OODBBean —addRoleByBean()
Add a role
public
addRoleByBean(OODBBean $rolecontext, OODBBean $rolename, string $otherinfo, string $start[, string $end = '' ]) : OODBBean
Parameters
- $rolecontext : OODBBean
-
Contextname
- $rolename : OODBBean
-
Rolename
- $otherinfo : string
-
Any other info that is to be stored with the role
- $start : string
-
A datetime
- $end : string = ''
-
A datetime or ''
Return values
OODBBean —checkrole()
Check that user has one of a set of roles
public
checkrole(array<, array<, string>> $roles[, bool $or = TRUE ]) : array<, mixed>
Parameters
- $roles : array<, array<, string>>
-
[['context', 'role'],...]]
- $or : bool = TRUE
-
If TRUE then the condition is OR
Tags
Return values
array<, mixed> —delrole()
Delete a role
public
delrole(string $contextname, string $rolename) : void
Parameters
- $contextname : string
-
The name of a context...
- $rolename : string
-
The name of a role....
Tags
Return values
void —editroles()
Deal with the role selecting part of a form
public
editroles(Context $context) : void
Parameters
- $context : Context
-
The context object
Tags
Return values
void —hasrole()
Check for a role
public
hasrole(string $contextname, string $rolename) : object|null
Parameters
- $contextname : string
-
The name of a context...
- $rolename : string
-
The name of a role - if this is the empty string then having the context is enough
Return values
object|null —hasRoleByBean()
Check for a role by bean
public
hasRoleByBean(OODBBean $rolecontext, OODBBean|null $rolename) : object|null
Parameters
- $rolecontext : OODBBean
-
A rolecontext
- $rolename : OODBBean|null
-
A rolename - if this is NULL having the context is enough
Return values
object|null —roles()
Get all currently valid roles for this bean
public
roles([bool $all = FALSE ]) : array<, OODBBean>
Parameters
- $all : bool = FALSE
-
If TRUE then include expired roles