X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b94b945fb03e21a1997cfe6e50148967586cb26d..refs/pull/2716/head:/app/Http/Controllers/ChapterController.php diff --git a/app/Http/Controllers/ChapterController.php b/app/Http/Controllers/ChapterController.php index 135597910..1d69df2a2 100644 --- a/app/Http/Controllers/ChapterController.php +++ b/app/Http/Controllers/ChapterController.php @@ -1,9 +1,9 @@ chapterRepo = $chapterRepo; - parent::__construct(); } /** @@ -51,7 +50,6 @@ class ChapterController extends Controller $this->checkOwnablePermission('chapter-create', $book); $chapter = $this->chapterRepo->create($request->all(), $book); - Activity::add($chapter, 'chapter_create', $book->id); return redirect($chapter->getUrl()); } @@ -100,7 +98,6 @@ class ChapterController extends Controller $this->checkOwnablePermission('chapter-update', $chapter); $this->chapterRepo->update($chapter, $request->all()); - Activity::add($chapter, 'chapter_update', $chapter->book->id); return redirect($chapter->getUrl()); } @@ -128,7 +125,6 @@ class ChapterController extends Controller $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug); $this->checkOwnablePermission('chapter-delete', $chapter); - Activity::addMessage('chapter_delete', $chapter->name, $chapter->book->id); $this->chapterRepo->destroy($chapter); return redirect($chapter->book->getUrl()); @@ -173,8 +169,6 @@ class ChapterController extends Controller return redirect()->back(); } - Activity::add($chapter, 'chapter_move', $newBook->id); - $this->showSuccessNotification(trans('entities.chapter_move_success', ['bookName' => $newBook->name])); return redirect($chapter->getUrl()); } @@ -197,14 +191,12 @@ class ChapterController extends Controller * Set the restrictions for this chapter. * @throws NotFoundException */ - public function permissions(Request $request, string $bookSlug, string $chapterSlug) + public function permissions(Request $request, PermissionsUpdater $permissionsUpdater, string $bookSlug, string $chapterSlug) { $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug); $this->checkOwnablePermission('restrictions-manage', $chapter); - $restricted = $request->get('restricted') === 'true'; - $permissions = $request->filled('restrictions') ? collect($request->get('restrictions')) : null; - $this->chapterRepo->updatePermissions($chapter, $restricted, $permissions); + $permissionsUpdater->updateFromPermissionsForm($chapter, $request); $this->showSuccessNotification(trans('entities.chapters_permissions_success')); return redirect($chapter->getUrl());