X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/bf591765c1e642f144675afaa031ecd283a8673b..refs/heads/ldap_host_failover:/app/Http/Controllers/PermissionsController.php diff --git a/app/Http/Controllers/PermissionsController.php b/app/Http/Controllers/PermissionsController.php index 92f994b00..7d908733b 100644 --- a/app/Http/Controllers/PermissionsController.php +++ b/app/Http/Controllers/PermissionsController.php @@ -2,6 +2,9 @@ namespace BookStack\Http\Controllers; +use BookStack\Auth\Permissions\EntityPermission; +use BookStack\Auth\Permissions\PermissionFormData; +use BookStack\Auth\Role; use BookStack\Entities\Models\Book; use BookStack\Entities\Models\Bookshelf; use BookStack\Entities\Models\Chapter; @@ -26,8 +29,10 @@ class PermissionsController extends Controller $page = Page::getBySlugs($bookSlug, $pageSlug); $this->checkOwnablePermission('restrictions-manage', $page); + $this->setPageTitle(trans('entities.pages_permissions')); return view('pages.permissions', [ 'page' => $page, + 'data' => new PermissionFormData($page), ]); } @@ -54,8 +59,10 @@ class PermissionsController extends Controller $chapter = Chapter::getBySlugs($bookSlug, $chapterSlug); $this->checkOwnablePermission('restrictions-manage', $chapter); + $this->setPageTitle(trans('entities.chapters_permissions')); return view('chapters.permissions', [ 'chapter' => $chapter, + 'data' => new PermissionFormData($chapter), ]); } @@ -82,8 +89,10 @@ class PermissionsController extends Controller $book = Book::getBySlug($slug); $this->checkOwnablePermission('restrictions-manage', $book); + $this->setPageTitle(trans('entities.books_permissions')); return view('books.permissions', [ 'book' => $book, + 'data' => new PermissionFormData($book), ]); } @@ -110,8 +119,10 @@ class PermissionsController extends Controller $shelf = Bookshelf::getBySlug($slug); $this->checkOwnablePermission('restrictions-manage', $shelf); + $this->setPageTitle(trans('entities.shelves_permissions')); return view('shelves.permissions', [ 'shelf' => $shelf, + 'data' => new PermissionFormData($shelf), ]); } @@ -143,4 +154,21 @@ class PermissionsController extends Controller return redirect($shelf->getUrl()); } + + /** + * Get an empty entity permissions form row for the given role. + */ + public function formRowForRole(string $entityType, string $roleId) + { + $this->checkPermissionOr('restrictions-manage-all', fn() => userCan('restrictions-manage-own')); + + $role = Role::query()->findOrFail($roleId); + + return view('form.entity-permissions-row', [ + 'role' => $role, + 'permission' => new EntityPermission(), + 'entityType' => $entityType, + 'inheriting' => false, + ]); + } }