]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/BookshelfController.php
Add git to the apt-get install packages.
[bookstack] / app / Http / Controllers / BookshelfController.php
index bcf2e12df88a67628bdded31f2db1162ce120098..bef96dd01a6e41c62ec67e97d04437baf760ced4 100644 (file)
@@ -40,9 +40,9 @@ class BookshelfController extends Controller
      */
     public function index()
     {
-        $view = setting()->getUser($this->currentUser, 'bookshelves_view_type', config('app.views.bookshelves', 'grid'));
-        $sort = setting()->getUser($this->currentUser, 'bookshelves_sort', 'name');
-        $order = setting()->getUser($this->currentUser, 'bookshelves_sort_order', 'asc');
+        $view = setting()->getForCurrentUser('bookshelves_view_type', config('app.views.bookshelves', 'grid'));
+        $sort = setting()->getForCurrentUser('bookshelves_sort', 'name');
+        $order = setting()->getForCurrentUser('bookshelves_sort_order', 'asc');
         $sortOptions = [
             'name' => trans('common.sort_name'),
             'created_at' => trans('common.sort_created_at'),
@@ -54,7 +54,7 @@ class BookshelfController extends Controller
             $shelf->books = $this->entityRepo->getBookshelfChildren($shelf);
         }
 
-        $recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('bookshelf', 4, 0) : false;
+        $recents = $this->isSignedIn() ? $this->entityRepo->getRecentlyViewed('bookshelf', 4, 0) : false;
         $popular = $this->entityRepo->getPopular('bookshelf', 4, 0);
         $new = $this->entityRepo->getRecentlyCreated('bookshelf', 4, 0);
 
@@ -116,7 +116,7 @@ class BookshelfController extends Controller
     public function show(string $slug)
     {
         /** @var Bookshelf $shelf */
-        $shelf = $this->entityRepo->getBySlug('bookshelf', $slug);
+        $shelf = $this->entityRepo->getEntityBySlug('bookshelf', $slug);
         $this->checkOwnablePermission('book-view', $shelf);
 
         $books = $this->entityRepo->getBookshelfChildren($shelf);
@@ -140,7 +140,7 @@ class BookshelfController extends Controller
      */
     public function edit(string $slug)
     {
-        $shelf = $this->entityRepo->getBySlug('bookshelf', $slug); /** @var $shelf Bookshelf */
+        $shelf = $this->entityRepo->getEntityBySlug('bookshelf', $slug); /** @var $shelf Bookshelf */
         $this->checkOwnablePermission('bookshelf-update', $shelf);
 
         $shelfBooks = $this->entityRepo->getBookshelfChildren($shelf);
@@ -169,7 +169,7 @@ class BookshelfController extends Controller
      */
     public function update(Request $request, string $slug)
     {
-        $shelf = $this->entityRepo->getBySlug('bookshelf', $slug); /** @var $bookshelf Bookshelf */
+        $shelf = $this->entityRepo->getEntityBySlug('bookshelf', $slug); /** @var $bookshelf Bookshelf */
         $this->checkOwnablePermission('bookshelf-update', $shelf);
         $this->validate($request, [
             'name' => 'required|string|max:255',
@@ -177,7 +177,7 @@ class BookshelfController extends Controller
             'image' => $this->imageRepo->getImageValidationRules(),
         ]);
 
-         $shelf = $this->entityRepo->updateFromInput('bookshelf', $shelf, $request->all());
+         $shelf = $this->entityRepo->updateFromInput($shelf, $request->all());
          $this->shelfUpdateActions($shelf, $request);
 
          Activity::add($shelf, 'bookshelf_update');
@@ -194,7 +194,7 @@ class BookshelfController extends Controller
      */
     public function showDelete(string $slug)
     {
-        $shelf = $this->entityRepo->getBySlug('bookshelf', $slug); /** @var $shelf Bookshelf */
+        $shelf = $this->entityRepo->getEntityBySlug('bookshelf', $slug); /** @var $shelf Bookshelf */
         $this->checkOwnablePermission('bookshelf-delete', $shelf);
 
         $this->setPageTitle(trans('entities.shelves_delete_named', ['name' => $shelf->getShortName()]));
@@ -210,9 +210,9 @@ class BookshelfController extends Controller
      */
     public function destroy(string $slug)
     {
-        $shelf = $this->entityRepo->getBySlug('bookshelf', $slug); /** @var $shelf Bookshelf */
+        $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);
@@ -230,7 +230,7 @@ class BookshelfController extends Controller
      */
     public function showPermissions(string $slug)
     {
-        $shelf = $this->entityRepo->getBySlug('bookshelf', $slug);
+        $shelf = $this->entityRepo->getEntityBySlug('bookshelf', $slug);
         $this->checkOwnablePermission('restrictions-manage', $shelf);
 
         $roles = $this->userRepo->getRestrictableRoles();
@@ -242,19 +242,19 @@ class BookshelfController extends Controller
 
     /**
      * Set the permissions for this bookshelf.
-     * @param string $slug
      * @param Request $request
+     * @param string $slug
      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
      * @throws \BookStack\Exceptions\NotFoundException
      * @throws \Throwable
      */
-    public function permissions(string $slug, Request $request)
+    public function permissions(Request $request, string $slug)
     {
-        $shelf = $this->entityRepo->getBySlug('bookshelf', $slug);
+        $shelf = $this->entityRepo->getEntityBySlug('bookshelf', $slug);
         $this->checkOwnablePermission('restrictions-manage', $shelf);
 
         $this->entityRepo->updateEntityPermissionsFromRequest($request, $shelf);
-        session()->flash('success', trans('entities.shelves_permissions_updated'));
+        $this->showSuccessNotification( trans('entities.shelves_permissions_updated'));
         return redirect($shelf->getUrl());
     }
 
@@ -266,11 +266,11 @@ class BookshelfController extends Controller
      */
     public function copyPermissions(string $slug)
     {
-        $shelf = $this->entityRepo->getBySlug('bookshelf', $slug);
+        $shelf = $this->entityRepo->getEntityBySlug('bookshelf', $slug);
         $this->checkOwnablePermission('restrictions-manage', $shelf);
 
         $updateCount = $this->entityRepo->copyBookshelfPermissions($shelf);
-        session()->flash('success', trans('entities.shelves_copy_permission_success', ['count' => $updateCount]));
+        $this->showSuccessNotification( trans('entities.shelves_copy_permission_success', ['count' => $updateCount]));
         return redirect($shelf->getUrl());
     }