X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/e537d0c4e8dbf0c8bf4ac8119e6a8d7a4adf4bfb..refs/pull/3918/head:/app/Http/Controllers/PageController.php diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index 748468b21..8b131c4f3 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -3,6 +3,7 @@ namespace BookStack\Http\Controllers; use BookStack\Actions\View; +use BookStack\Entities\Models\Book; use BookStack\Entities\Models\Page; use BookStack\Entities\Repos\PageRepo; use BookStack\Entities\Tools\BookContents; @@ -11,7 +12,6 @@ use BookStack\Entities\Tools\NextPreviousContentLocator; use BookStack\Entities\Tools\PageContent; use BookStack\Entities\Tools\PageEditActivity; use BookStack\Entities\Tools\PageEditorData; -use BookStack\Entities\Tools\PermissionsUpdater; use BookStack\Exceptions\NotFoundException; use BookStack\Exceptions\PermissionsException; use BookStack\References\ReferenceFetcher; @@ -75,7 +75,6 @@ class PageController extends Controller $page = $this->pageRepo->getNewDraftPage($parent); $this->pageRepo->publishDraft($page, [ 'name' => $request->get('name'), - 'html' => '', ]); return redirect($page->getUrl('/edit')); @@ -267,11 +266,13 @@ class PageController extends Controller $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug); $this->checkOwnablePermission('page-delete', $page); $this->setPageTitle(trans('entities.pages_delete_named', ['pageName' => $page->getShortName()])); + $times_used_as_template = Book::where('default_template', '=', $page->id)->count(); return view('pages.delete', [ 'book' => $page->book, 'page' => $page, 'current' => $page, + 'times_used_as_template' => $times_used_as_template, ]); } @@ -452,37 +453,4 @@ class PageController extends Controller return redirect($pageCopy->getUrl()); } - - /** - * Show the Permissions view. - * - * @throws NotFoundException - */ - public function showPermissions(string $bookSlug, string $pageSlug) - { - $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug); - $this->checkOwnablePermission('restrictions-manage', $page); - - return view('pages.permissions', [ - 'page' => $page, - ]); - } - - /** - * Set the permissions for this page. - * - * @throws NotFoundException - * @throws Throwable - */ - public function permissions(Request $request, PermissionsUpdater $permissionsUpdater, string $bookSlug, string $pageSlug) - { - $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug); - $this->checkOwnablePermission('restrictions-manage', $page); - - $permissionsUpdater->updateFromPermissionsForm($page, $request); - - $this->showSuccessNotification(trans('entities.pages_permissions_success')); - - return redirect($page->getUrl()); - } }