X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ec3aeb3315db201251e48b9d3713b022e7d88188..refs/pull/3099/head:/app/Entities/Repos/ChapterRepo.php diff --git a/app/Entities/Repos/ChapterRepo.php b/app/Entities/Repos/ChapterRepo.php index 60599eac8..b10fc4530 100644 --- a/app/Entities/Repos/ChapterRepo.php +++ b/app/Entities/Repos/ChapterRepo.php @@ -1,17 +1,19 @@ -book_id = $parentBook->id; $chapter->priority = (new BookContents($parentBook))->getLastPriority() + 1; $this->baseRepo->create($chapter, $input); + Activity::add(ActivityType::CHAPTER_CREATE, $chapter); + return $chapter; } @@ -55,32 +60,29 @@ class ChapterRepo public function update(Chapter $chapter, array $input): Chapter { $this->baseRepo->update($chapter, $input); - return $chapter; - } + Activity::add(ActivityType::CHAPTER_UPDATE, $chapter); - /** - * Update the permissions of a chapter. - */ - public function updatePermissions(Chapter $chapter, bool $restricted, Collection $permissions = null) - { - $this->baseRepo->updatePermissions($chapter, $restricted, $permissions); + return $chapter; } /** * Remove a chapter from the system. + * * @throws Exception */ public function destroy(Chapter $chapter) { $trashCan = new TrashCan(); $trashCan->softDestroyChapter($chapter); + Activity::add(ActivityType::CHAPTER_DELETE, $chapter); $trashCan->autoClearOld(); } /** * Move the given chapter into a new parent book. * The $parentIdentifier must be a string of the following format: - * 'book:' (book:5) + * 'book:' (book:5). + * * @throws MoveOperationException */ public function move(Chapter $chapter, string $parentIdentifier): Book @@ -93,6 +95,7 @@ class ChapterRepo throw new MoveOperationException('Chapters can only be moved into books'); } + /** @var Book $parent */ $parent = Book::visible()->where('id', '=', $entityId)->first(); if ($parent === null) { throw new MoveOperationException('Book to move chapter into not found'); @@ -100,6 +103,8 @@ class ChapterRepo $chapter->changeBook($parent->id); $chapter->rebuildPermissions(); + Activity::add(ActivityType::CHAPTER_MOVE, $chapter); + return $parent; } }