PHP Class BookStack\Services\PermissionService

Afficher le fichier Open project: ssddanbrown/bookstack Class Usage Examples

Méthodes publiques

Свойство Type Description
$book
$chapter
$page

Protected Properties

Свойство Type Description
$currentAction
$currentUserModel
$entityCache
$isAdminUser
$jointPermission
$role
$userRoles

Méthodes publiques

Méthode Description
__construct ( JointPermission $jointPermission, Book $book, Chapter $chapter, Page $page, Role $role ) PermissionService constructor.
buildJointPermissionForRole ( Role $role ) Build the entity jointPermissions for a particular role.
buildJointPermissions ( ) Re-generate all entity permission from scratch.
buildJointPermissionsForEntities ( Collection $entities ) Rebuild the entity jointPermissions for a collection of entities.
buildJointPermissionsForEntity ( Entity $entity ) Rebuild the entity jointPermissions for a particular entity.
checkIfRestrictionsSet ( Entity $entity, $action ) : boolean | mixed Check if an entity has restrictions set on itself or its parent tree.
checkOwnableUserAccess ( Ownable $ownable, $permission ) : boolean Checks if an entity has a restriction set upon it.
deleteJointPermissionsForEntity ( Entity $entity ) Delete the entity jointPermissions for a particular entity.
deleteJointPermissionsForRole ( Role $role ) Delete the entity jointPermissions attached to a particular role.
enforceBookRestrictions ( $query, string $action = 'view' ) : mixed Add restrictions to a book query.
enforceChapterRestrictions ( $query, string $action = 'view' ) : mixed Add on permission restrictions to a chapter query.
enforceEntityRestrictions ( $query, string $action = 'view' ) : mixed Add restrictions for a generic entity
enforcePageRestrictions ( $query, string $action = 'view' ) : mixed Add restrictions for a page query
filterRelatedPages ( $query, $tableName, $entityIdColumn ) : mixed Filters pages that are a direct relation to another item.
filterRestrictedEntityRelations ( $query, string $tableName, string $entityIdColumn, string $entityTypeColumn ) : mixed Filter items that have entities set a a polymorphic relation.

Méthodes protégées

Méthode Description
createJointPermissionData ( Entity $entity, Role $role, $action ) : array Create entity permission data for an entity and role for a particular action.
createJointPermissionDataArray ( Entity $entity, Role $role, $action, $permissionAll, $permissionOwn ) : array Create an array of data with the information of an entity jointPermissions.
createManyJointPermissions ( Collection $entities, Collection $roles ) Create & Save entity jointPermissions for many entities and jointPermissions.
deleteManyJointPermissionsForEntities ( Entity[] $entities ) Delete all of the entity jointPermissions for a list of entities.
deleteManyJointPermissionsForRoles ( Role[] $roles ) Delete all of the entity jointPermissions for a list of entities.
entityRestrictionQuery ( $query ) : mixed The general query filter to remove all entities that the current user does not have access to.
getActions ( $entity ) : array Get the actions related to an entity.
getBook ( $bookId ) : Book Get a book via ID, Checks local cache
getChapter ( $chapterId ) : Book Get a chapter via ID, Checks local cache
getRoles ( ) : array | boolean Get the roles for the current user;
readyEntityCache ( ) Prepare the local entity cache and ensure it's empty

Private Methods

Méthode Description
clean ( ) Clean the cached user elements.
currentUser ( ) : User Get the current user
isAdmin ( ) : boolean Check if the current user is an admin.

Method Details

__construct() public méthode

PermissionService constructor.
public __construct ( JointPermission $jointPermission, Book $book, Chapter $chapter, Page $page, Role $role )
$jointPermission BookStack\JointPermission
$book BookStack\Book
$chapter BookStack\Chapter
$page BookStack\Page
$role BookStack\Role

buildJointPermissionForRole() public méthode

Build the entity jointPermissions for a particular role.
public buildJointPermissionForRole ( Role $role )
$role BookStack\Role

buildJointPermissions() public méthode

Re-generate all entity permission from scratch.

buildJointPermissionsForEntities() public méthode

Rebuild the entity jointPermissions for a collection of entities.
public buildJointPermissionsForEntities ( Collection $entities )
$entities Illuminate\Support\Collection

buildJointPermissionsForEntity() public méthode

Rebuild the entity jointPermissions for a particular entity.
public buildJointPermissionsForEntity ( Entity $entity )
$entity BookStack\Entity

checkIfRestrictionsSet() public méthode

Check if an entity has restrictions set on itself or its parent tree.
public checkIfRestrictionsSet ( Entity $entity, $action ) : boolean | mixed
$entity BookStack\Entity
$action
Résultat boolean | mixed

checkOwnableUserAccess() public méthode

Checks if an entity has a restriction set upon it.
public checkOwnableUserAccess ( Ownable $ownable, $permission ) : boolean
$ownable BookStack\Ownable
$permission
Résultat boolean

createJointPermissionData() protected méthode

Create entity permission data for an entity and role for a particular action.
protected createJointPermissionData ( Entity $entity, Role $role, $action ) : array
$entity BookStack\Entity
$role BookStack\Role
$action
Résultat array

createJointPermissionDataArray() protected méthode

Used to build data for bulk insertion.
protected createJointPermissionDataArray ( Entity $entity, Role $role, $action, $permissionAll, $permissionOwn ) : array
$entity BookStack\Entity
$role BookStack\Role
$action
$permissionAll
$permissionOwn
Résultat array

createManyJointPermissions() protected méthode

Create & Save entity jointPermissions for many entities and jointPermissions.
protected createManyJointPermissions ( Collection $entities, Collection $roles )
$entities Illuminate\Support\Collection
$roles Illuminate\Support\Collection

deleteJointPermissionsForEntity() public méthode

Delete the entity jointPermissions for a particular entity.
public deleteJointPermissionsForEntity ( Entity $entity )
$entity BookStack\Entity

deleteJointPermissionsForRole() public méthode

Delete the entity jointPermissions attached to a particular role.
public deleteJointPermissionsForRole ( Role $role )
$role BookStack\Role

deleteManyJointPermissionsForEntities() protected méthode

Delete all of the entity jointPermissions for a list of entities.
protected deleteManyJointPermissionsForEntities ( Entity[] $entities )
$entities BookStack\Entity[]

deleteManyJointPermissionsForRoles() protected méthode

Delete all of the entity jointPermissions for a list of entities.
protected deleteManyJointPermissionsForRoles ( Role[] $roles )
$roles BookStack\Role[]

enforceBookRestrictions() public méthode

Add restrictions to a book query.
public enforceBookRestrictions ( $query, string $action = 'view' ) : mixed
$query
$action string
Résultat mixed

enforceChapterRestrictions() public méthode

Add on permission restrictions to a chapter query.
public enforceChapterRestrictions ( $query, string $action = 'view' ) : mixed
$query
$action string
Résultat mixed

enforceEntityRestrictions() public méthode

Add restrictions for a generic entity
public enforceEntityRestrictions ( $query, string $action = 'view' ) : mixed
$query
$action string
Résultat mixed

enforcePageRestrictions() public méthode

Add restrictions for a page query
public enforcePageRestrictions ( $query, string $action = 'view' ) : mixed
$query
$action string
Résultat mixed

entityRestrictionQuery() protected méthode

The general query filter to remove all entities that the current user does not have access to.
protected entityRestrictionQuery ( $query ) : mixed
$query
Résultat mixed

filterRelatedPages() public méthode

Filters pages that are a direct relation to another item.
public filterRelatedPages ( $query, $tableName, $entityIdColumn ) : mixed
$query
$tableName
$entityIdColumn
Résultat mixed

filterRestrictedEntityRelations() public méthode

Filter items that have entities set a a polymorphic relation.
public filterRestrictedEntityRelations ( $query, string $tableName, string $entityIdColumn, string $entityTypeColumn ) : mixed
$query
$tableName string
$entityIdColumn string
$entityTypeColumn string
Résultat mixed

getActions() protected méthode

Get the actions related to an entity.
protected getActions ( $entity ) : array
$entity
Résultat array

getBook() protected méthode

Get a book via ID, Checks local cache
protected getBook ( $bookId ) : Book
$bookId
Résultat BookStack\Book

getChapter() protected méthode

Get a chapter via ID, Checks local cache
protected getChapter ( $chapterId ) : Book
$chapterId
Résultat BookStack\Book

getRoles() protected méthode

Get the roles for the current user;
protected getRoles ( ) : array | boolean
Résultat array | boolean

readyEntityCache() protected méthode

Prepare the local entity cache and ensure it's empty
protected readyEntityCache ( )

Property Details

$book public_oe property

public $book

$chapter public_oe property

public $chapter

$currentAction protected_oe property

protected $currentAction

$currentUserModel protected_oe property

protected $currentUserModel

$entityCache protected_oe property

protected $entityCache

$isAdminUser protected_oe property

protected $isAdminUser

$jointPermission protected_oe property

protected $jointPermission

$page public_oe property

public $page

$role protected_oe property

protected $role

$userRoles protected_oe property

protected $userRoles