Class \Scrivo\Role
Class that represents a system role class.
Access to pages and assets is restricted through roles. Users can be registered to one or more roles as well as objects (pages and assets). Do one or more roles of the object and the user match an access level higher than the default for the user is granted.
When access is granted, a distiction is made in editor roles and public roles. A user with User::STATUS_EDITOR can only be registered to one or more Role::EDITOR_ROLE-s, a user with status User::STATUS_MEMBER only to one or more User::PUBLIC_ROLE-s.
For role matching see \Scrivo\AccessController.
TODO currently object ids 1 and 2 are used for system roles, this is not in line with the policy for object ids.
Defined in: Role.php.
Attr. | Name / Description |
---|---|
public |
Role($context) Create an empty role object. |
Name | Description |
---|---|
EDITOR_ROLE | Constant to denote an editor role. |
PUBLIC_ROLE | Constant to denote a public role. |
Attr. | Type | Name | Description |
---|---|---|---|
\..\String | $description | A descriptive name for this role. | |
read-only | int | $id | The role id (DB key). |
\..\String | $title | The role title. | |
int | $type | The role type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE |
Attr. | Type | Name | Description |
---|---|---|---|
private | \..\Context | $context | A Scrivo context. |
private | \..\String | $description | A descriptive name for this role. |
protected | int | $id | The role id (DB key). |
private | \..\String | $title | The role title. |
private | int | $type | The role type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE |
Attr. | Type | Name / Description |
---|---|---|
public | mixed |
__get($name) Implementation of the readable properties using the PHP magic method __get(). |
public |
__set($name, $value) Implementation of the writable properties using the PHP magic method __set(). |
|
public static |
delete($context, $id) Delete existing role data from the database. |
|
public static | \..\Role |
fetch($context, $id) Fetch a role object from the database using its object id. |
public |
insert() Insert new role object data into the database. |
|
public static | \..\Role[] |
select($context, $type) Select roles from the database. |
private |
setDescription($description) Set the descriptive name for this role. |
|
protected |
setFields($context, $rd) Convenience method to set the fields of a role object from an array (result set row). |
|
private |
setTitle($title) Set the role title. |
|
private |
setType($type) Set the role's type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE. |
|
public |
update() Update existing role object data in the database. |
|
private static |
validateDelete($context, $id) Check if deletion of role object data does not violate any business rules. |
|
private |
Check if this role object can be inserted into the database. |
|
private |
Check if this role object can be updated in the database. |
Constructor
- public Role(\Scrivo\Context $context=null)
-
Create an empty role object.
Parameters:
Type Name Def. Description \Scrivo\Context $context null A Scrivo context.
View source: Role.php line 109.
Constants
- EDITOR_ROLE
-
Constant to denote an editor role.
Value: 2
View source: Role.php line 72.
- PUBLIC_ROLE
-
Constant to denote a public role.
Value: 3
View source: Role.php line 67.
Members
- private \Scrivo\Context $context
-
A Scrivo context.
Inital value: null
View source: Role.php line 102.
- private \Scrivo\String $description
-
A descriptive name for this role.
Inital value: null
View source: Role.php line 96.
- protected int $id
-
The role id (DB key).
Inital value: 0
View source: Role.php line 78.
- private \Scrivo\String $title
-
The role title.
Inital value: null
View source: Role.php line 90.
- private int $type
-
The role type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE
Inital value: self::PUBLIC_ROLE
View source: Role.php line 84.
Methods
- public mixed __get(string $name)
-
Implementation of the readable properties using the PHP magic method __get().
Parameters:
Type Name Def. Description string $name The name of the property to get.
Returns:
mixed Implementation of the readable properties using the PHP magic method __get().
View source: Role.php line 128.
- public __set(string $name, mixed $value)
-
Implementation of the writable properties using the PHP magic method __set().
Parameters:
Type Name Def. Description string $name The name of the property to set.
mixed $value The value of the property to set.
View source: Role.php line 145.
- public static delete(\Scrivo\Context $context, int $id)
-
Delete existing role data from the database.
First it is is checked if it's possible to delete role data, then the role data including its dependecies is deleted from the database.
Parameters:
Type Name Def. Description \Scrivo\Context $context A Scrivo context.
int $id The object id of the role to select.
Throws:
Exception Type Description \Scrivo\ApplicationException If the data is not accessible or if it is not possible to delete the role data. View source: Role.php line 321.
- public static \Scrivo\Role fetch(\Scrivo\Context $context, int $id)
-
Fetch a role object from the database using its object id.
Parameters:
Type Name Def. Description \Scrivo\Context $context A Scrivo context.
int $id The object id of the role to select.
Returns:
\Scrivo\Role Fetch a role object from the database using its object id.
View source: Role.php line 356.
- public insert()
-
Insert new role object data into the database.
First it is checked if the data of this role object can be inserted into the database, then the data is inserted into the database. If no id was set a new object id is generated.
Throws:
Exception Type Description \Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data. View source: Role.php line 226.
- public static \Scrivo\Role[id] select(\Scrivo\Context $context, int $type)
-
Select roles from the database.
Depending on the given arguments the public or editor roles can be retrieved.
Parameters:
Type Name Def. Description \Scrivo\Context $context A Scrivo context.
int $type A role type: \Scrivo\Role::PUBLIC_ROLE or \Scrivo\Role::EDITOR_ROLE for which to retrieve the roles.
Returns:
\Scrivo\Role[id] Select roles from the database.
View source: Role.php line 408.
- private setDescription(\Scrivo\String $description)
-
Set the descriptive name for this role.
Parameters:
Type Name Def. Description \Scrivo\String $description A descriptive name for this role.
View source: Role.php line 202.
- protected setFields(\Scrivo\Context $context, array $rd)
-
Convenience method to set the fields of a role object from an array (result set row).
Parameters:
Type Name Def. Description \Scrivo\Context $context A Scrivo context.
array $rd An array containing the field data using the database field names as keys.
View source: Role.php line 162.
- private setTitle(\Scrivo\String $title)
-
Set the role title.
Parameters:
Type Name Def. Description \Scrivo\String $title The role's title.
View source: Role.php line 193.
- private setType(int $type)
-
Set the role's type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE.
Parameters:
Type Name Def. Description int $type The role's type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE.
View source: Role.php line 179.
- public update()
-
Update existing role object data in the database.
First it is checked if the data of this role object can be updated in the database, then the data is updated in the database.
Throws:
Exception Type Description \Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data. View source: Role.php line 270.
- private static validateDelete(\Scrivo\Context $context, int $id)
-
Check if deletion of role object data does not violate any business rules.
Parameters:
Type Name Def. Description \Scrivo\Context $context A Scrivo context.
int $id The object id of the role to select.
Throws:
Exception Type Description \Scrivo\ApplicationException If the data is not accessible or if it is not possible to delete the language data. View source: Role.php line 304.
- private validateInsert()
-
Check if this role object can be inserted into the database.
Throws:
Exception Type Description \Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data. View source: Role.php line 212.
- private validateUpdate()
-
Check if this role object can be updated in the database.
Throws:
Exception Type Description \Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data. View source: Role.php line 257.
Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013