PHP Класс BookStack\Services\PermissionService

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$book
$chapter
$page

Защищенные свойства (Protected)

Свойство Тип Описание
$currentAction
$currentUserModel
$entityCache
$isAdminUser
$jointPermission
$role
$userRoles

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
clean ( ) Clean the cached user elements.
currentUser ( ) : User Get the current user
isAdmin ( ) : boolean Check if the current user is an admin.

Описание методов

__construct() публичный Метод

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() публичный Метод

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

buildJointPermissions() публичный Метод

Re-generate all entity permission from scratch.

buildJointPermissionsForEntities() публичный Метод

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

buildJointPermissionsForEntity() публичный Метод

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

checkIfRestrictionsSet() публичный Метод

Check if an entity has restrictions set on itself or its parent tree.
public checkIfRestrictionsSet ( Entity $entity, $action ) : boolean | mixed
$entity BookStack\Entity
$action
Результат boolean | mixed

checkOwnableUserAccess() публичный Метод

Checks if an entity has a restriction set upon it.
public checkOwnableUserAccess ( Ownable $ownable, $permission ) : boolean
$ownable BookStack\Ownable
$permission
Результат boolean

createJointPermissionData() защищенный Метод

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
Результат array

createJointPermissionDataArray() защищенный Метод

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
Результат array

createManyJointPermissions() защищенный Метод

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

deleteJointPermissionsForEntity() публичный Метод

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

deleteJointPermissionsForRole() публичный Метод

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

deleteManyJointPermissionsForEntities() защищенный Метод

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

deleteManyJointPermissionsForRoles() защищенный Метод

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

enforceBookRestrictions() публичный Метод

Add restrictions to a book query.
public enforceBookRestrictions ( $query, string $action = 'view' ) : mixed
$query
$action string
Результат mixed

enforceChapterRestrictions() публичный Метод

Add on permission restrictions to a chapter query.
public enforceChapterRestrictions ( $query, string $action = 'view' ) : mixed
$query
$action string
Результат mixed

enforceEntityRestrictions() публичный Метод

Add restrictions for a generic entity
public enforceEntityRestrictions ( $query, string $action = 'view' ) : mixed
$query
$action string
Результат mixed

enforcePageRestrictions() публичный Метод

Add restrictions for a page query
public enforcePageRestrictions ( $query, string $action = 'view' ) : mixed
$query
$action string
Результат mixed

entityRestrictionQuery() защищенный Метод

The general query filter to remove all entities that the current user does not have access to.
protected entityRestrictionQuery ( $query ) : mixed
$query
Результат mixed

filterRelatedPages() публичный Метод

Filters pages that are a direct relation to another item.
public filterRelatedPages ( $query, $tableName, $entityIdColumn ) : mixed
$query
$tableName
$entityIdColumn
Результат mixed

filterRestrictedEntityRelations() публичный Метод

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
Результат mixed

getActions() защищенный Метод

Get the actions related to an entity.
protected getActions ( $entity ) : array
$entity
Результат array

getBook() защищенный Метод

Get a book via ID, Checks local cache
protected getBook ( $bookId ) : Book
$bookId
Результат BookStack\Book

getChapter() защищенный Метод

Get a chapter via ID, Checks local cache
protected getChapter ( $chapterId ) : Book
$chapterId
Результат BookStack\Book

getRoles() защищенный Метод

Get the roles for the current user;
protected getRoles ( ) : array | boolean
Результат array | boolean

readyEntityCache() защищенный Метод

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

Описание свойств

$book публичное свойство

public $book

$chapter публичное свойство

public $chapter

$currentAction защищенное свойство

protected $currentAction

$currentUserModel защищенное свойство

protected $currentUserModel

$entityCache защищенное свойство

protected $entityCache

$isAdminUser защищенное свойство

protected $isAdminUser

$jointPermission защищенное свойство

protected $jointPermission

$page публичное свойство

public $page

$role защищенное свойство

protected $role

$userRoles защищенное свойство

protected $userRoles