X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/9e033709a78824decbf959ea25ce8672b026da09..refs/pull/2768/head:/app/Http/Controllers/PageController.php diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index ee998996f..134c22081 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -1,13 +1,13 @@ pageRepo = $pageRepo; - parent::__construct(); } /** @@ -107,7 +106,6 @@ class PageController extends Controller $this->checkOwnablePermission('page-create', $draftPage->getParent()); $page = $this->pageRepo->publishDraft($draftPage, $request->all()); - Activity::add($page, 'page_create', $draftPage->book->id); return redirect($page->getUrl()); } @@ -144,7 +142,7 @@ class PageController extends Controller $page->load(['comments.createdBy']); } - Views::add($page); + View::incrementFor($page); $this->setPageTitle($page->getShortName()); return view('pages.show', [ 'page' => $page, @@ -224,7 +222,6 @@ class PageController extends Controller $this->checkOwnablePermission('page-update', $page); $this->pageRepo->update($page, $request->all()); - Activity::add($page, 'page_update', $page->book->id); return redirect($page->getUrl()); } @@ -298,26 +295,21 @@ class PageController extends Controller * Remove the specified page from storage. * @throws NotFoundException * @throws Throwable - * @throws NotifyException */ public function destroy(string $bookSlug, string $pageSlug) { $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug); $this->checkOwnablePermission('page-delete', $page); + $parent = $page->getParent(); - $book = $page->book; - $parent = $page->chapter ?? $book; $this->pageRepo->destroy($page); - Activity::addMessage('page_delete', $page->name, $book->id); - $this->showSuccessNotification(trans('entities.pages_delete_success')); return redirect($parent->getUrl()); } /** * Remove the specified draft page from storage. * @throws NotFoundException - * @throws NotifyException * @throws Throwable */ public function destroyDraft(string $bookSlug, int $pageId) @@ -346,9 +338,9 @@ class PageController extends Controller ->paginate(20) ->setPath(url('/pages/recently-updated')); - return view('pages.detailed-listing', [ + return view('common.detailed-listing-paginated', [ 'title' => trans('entities.recently_updated_pages'), - 'pages' => $pages + 'entities' => $pages ]); } @@ -394,7 +386,6 @@ class PageController extends Controller return redirect()->back(); } - Activity::add($page, 'page_move', $page->book->id); $this->showSuccessNotification(trans('entities.pages_move_success', ['parentName' => $parent->name])); return redirect($page->getUrl()); } @@ -439,8 +430,6 @@ class PageController extends Controller return redirect()->back(); } - Activity::add($pageCopy, 'page_create', $pageCopy->book->id); - $this->showSuccessNotification(trans('entities.pages_copy_success')); return redirect($pageCopy->getUrl()); } @@ -463,14 +452,12 @@ class PageController extends Controller * @throws NotFoundException * @throws Throwable */ - public function permissions(Request $request, string $bookSlug, string $pageSlug) + public function permissions(Request $request, PermissionsUpdater $permissionsUpdater, string $bookSlug, string $pageSlug) { $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug); $this->checkOwnablePermission('restrictions-manage', $page); - $restricted = $request->get('restricted') === 'true'; - $permissions = $request->filled('restrictions') ? collect($request->get('restrictions')) : null; - $this->pageRepo->updatePermissions($page, $restricted, $permissions); + $permissionsUpdater->updateFromPermissionsForm($page, $request); $this->showSuccessNotification(trans('entities.pages_permissions_success')); return redirect($page->getUrl());