1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Simplified activity facade interface

Also cleaned up any other bits along the way.
This commit is contained in:
Dan Brown
2019-09-19 18:03:17 +01:00
parent 2a2cc858f0
commit 615b2de433
11 changed files with 68 additions and 46 deletions

View File

@@ -58,11 +58,6 @@ class BookController extends Controller
$view = setting()->getUser($this->currentUser, 'books_view_type', config('app.views.books'));
$sort = setting()->getUser($this->currentUser, 'books_sort', 'name');
$order = setting()->getUser($this->currentUser, 'books_sort_order', 'asc');
$sortOptions = [
'name' => trans('common.sort_name'),
'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
];
$books = $this->bookRepo->getAllPaginated('book', 18, $sort, $order);
$recents = $this->signedIn ? $this->bookRepo->getRecentlyViewed('book', 4, 0) : false;
@@ -80,7 +75,6 @@ class BookController extends Controller
'view' => $view,
'sort' => $sort,
'order' => $order,
'sortOptions' => $sortOptions,
]);
}
@@ -114,6 +108,7 @@ class BookController extends Controller
* @throws NotFoundException
* @throws ImageUploadException
* @throws ValidationException
* @throws Throwable
*/
public function store(Request $request, string $shelfSlug = null)
{
@@ -192,6 +187,7 @@ class BookController extends Controller
* @throws ImageUploadException
* @throws NotFoundException
* @throws ValidationException
* @throws Throwable
*/
public function update(Request $request, string $slug)
{
@@ -340,7 +336,7 @@ class BookController extends Controller
{
$book = $this->bookRepo->getBySlug($bookSlug);
$this->checkOwnablePermission('book-delete', $book);
Activity::addMessage('book_delete', 0, $book->name);
Activity::addMessage('book_delete', $book->name);
if ($book->cover) {
$this->imageRepo->destroyImage($book->cover);

View File

@@ -212,7 +212,7 @@ class BookshelfController extends Controller
{
$shelf = $this->entityRepo->getEntityBySlug('bookshelf', $slug); /** @var $shelf Bookshelf */
$this->checkOwnablePermission('bookshelf-delete', $shelf);
Activity::addMessage('bookshelf_delete', 0, $shelf->name);
Activity::addMessage('bookshelf_delete', $shelf->name);
if ($shelf->cover) {
$this->imageRepo->destroyImage($shelf->cover);

View File

@@ -143,7 +143,7 @@ class ChapterController extends Controller
$chapter = $this->entityRepo->getEntityBySlug('chapter', $chapterSlug, $bookSlug);
$book = $chapter->book;
$this->checkOwnablePermission('chapter-delete', $chapter);
Activity::addMessage('chapter_delete', $book->id, $chapter->name);
Activity::addMessage('chapter_delete', $chapter->name, $book->id);
$this->entityRepo->destroyChapter($chapter);
return redirect($book->getUrl());
}

View File

@@ -3,6 +3,8 @@
namespace BookStack\Http\Controllers;
use BookStack\Auth\User;
use BookStack\Entities\Entity;
use BookStack\Facades\Activity;
use BookStack\Ownable;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;

View File

@@ -358,7 +358,7 @@ class PageController extends Controller
$this->checkOwnablePermission('page-delete', $page);
$this->pageRepo->destroyPage($page);
Activity::addMessage('page_delete', $book->id, $page->name);
Activity::addMessage('page_delete', $page->name, $book->id);
$this->showSuccessNotification( trans('entities.pages_delete_success'));
return redirect($book->getUrl());
}