]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/PageController.php
French translation update
[bookstack] / app / Http / Controllers / PageController.php
index 45aa8f9347554d2de3cc2f951e3b3b19a2e533a0..736fcf4f6d2b9c41b471340762b87fb62eec0dc9 100644 (file)
@@ -56,7 +56,7 @@ class PageController extends Controller
         $this->checkOwnablePermission('page-create', $parent);
 
         // Redirect to draft edit screen if signed in
-        if ($this->signedIn) {
+        if ($this->isSignedIn()) {
             $draft = $this->pageRepo->getDraftPage($book, $chapter);
             return redirect($draft->getUrl());
         }
@@ -111,7 +111,7 @@ class PageController extends Controller
         $this->checkOwnablePermission('page-create', $draft->parent);
         $this->setPageTitle(trans('entities.pages_edit_draft'));
 
-        $draftsEnabled = $this->signedIn;
+        $draftsEnabled = $this->isSignedIn();
         $templates = $this->pageRepo->getPageTemplates(10);
 
         return view('pages.edit', [
@@ -230,7 +230,7 @@ class PageController extends Controller
         }
 
         // Check for a current draft version for this user
-        $userPageDraft = $this->pageRepo->getUserPageDraft($page, $this->currentUser->id);
+        $userPageDraft = $this->pageRepo->getUserPageDraft($page, user()->id);
         if ($userPageDraft !== null) {
             $page->name = $userPageDraft->name;
             $page->html = $userPageDraft->html;
@@ -240,10 +240,10 @@ class PageController extends Controller
         }
 
         if (count($warnings) > 0) {
-            session()->flash('warning', implode("\n", $warnings));
+            $this->showWarningNotification( implode("\n", $warnings));
         }
 
-        $draftsEnabled = $this->signedIn;
+        $draftsEnabled = $this->isSignedIn();
         $templates = $this->pageRepo->getPageTemplates(10);
 
         return view('pages.edit', [
@@ -285,7 +285,7 @@ class PageController extends Controller
         $page = $this->pageRepo->getById('page', $pageId, true);
         $this->checkOwnablePermission('page-update', $page);
 
-        if (!$this->signedIn) {
+        if (!$this->isSignedIn()) {
             return response()->json([
                 'status' => 'error',
                 'message' => trans('errors.guests_cannot_save_drafts'),
@@ -358,8 +358,8 @@ class PageController extends Controller
         $this->checkOwnablePermission('page-delete', $page);
         $this->pageRepo->destroyPage($page);
 
-        Activity::addMessage('page_delete', $book->id, $page->name);
-        session()->flash('success', trans('entities.pages_delete_success'));
+        Activity::addMessage('page_delete', $page->name, $book->id);
+        $this->showSuccessNotification( trans('entities.pages_delete_success'));
         return redirect($book->getUrl());
     }
 
@@ -375,7 +375,7 @@ class PageController extends Controller
         $page = $this->pageRepo->getById('page', $pageId, true);
         $book = $page->book;
         $this->checkOwnablePermission('page-update', $page);
-        session()->flash('success', trans('entities.pages_delete_draft_success'));
+        $this->showSuccessNotification( trans('entities.pages_delete_draft_success'));
         $this->pageRepo->destroyPage($page);
         return redirect($book->getUrl());
     }
@@ -491,12 +491,12 @@ class PageController extends Controller
 
         // Check if its the latest revision, cannot delete latest revision.
         if (intval($currentRevision->id) === intval($revId)) {
-            session()->flash('error', trans('entities.revision_cannot_delete_latest'));
+            $this->showErrorNotification( trans('entities.revision_cannot_delete_latest'));
             return response()->view('pages.revisions', ['page' => $page, 'book' => $page->book, 'current' => $page], 400);
         }
 
         $revision->delete();
-        session()->flash('success', trans('entities.revision_delete_success'));
+        $this->showSuccessNotification( trans('entities.revision_delete_success'));
         return redirect($page->getUrl('/revisions'));
     }
 
@@ -568,7 +568,7 @@ class PageController extends Controller
 
         $this->pageRepo->changePageParent($page, $parent);
         Activity::add($page, 'page_move', $page->book->id);
-        session()->flash('success', trans('entities.pages_move_success', ['parentName' => $parent->name]));
+        $this->showSuccessNotification( trans('entities.pages_move_success', ['parentName' => $parent->name]));
 
         return redirect($page->getUrl());
     }
@@ -616,7 +616,7 @@ class PageController extends Controller
             try {
                 $parent = $this->pageRepo->getById($entityType, $entityId);
             } catch (Exception $e) {
-                session()->flash(trans('entities.selected_book_chapter_not_found'));
+                $this->showErrorNotification(trans('entities.selected_book_chapter_not_found'));
                 return redirect()->back();
             }
         }
@@ -626,7 +626,7 @@ class PageController extends Controller
         $pageCopy = $this->pageRepo->copyPage($page, $parent, $request->get('name', ''));
 
         Activity::add($pageCopy, 'page_create', $pageCopy->book->id);
-        session()->flash('success', trans('entities.pages_copy_success'));
+        $this->showSuccessNotification( trans('entities.pages_copy_success'));
 
         return redirect($pageCopy->getUrl());
     }
@@ -663,7 +663,7 @@ class PageController extends Controller
         $page = $this->pageRepo->getBySlug($pageSlug, $bookSlug);
         $this->checkOwnablePermission('restrictions-manage', $page);
         $this->pageRepo->updateEntityPermissionsFromRequest($request, $page);
-        session()->flash('success', trans('entities.pages_permissions_success'));
+        $this->showSuccessNotification( trans('entities.pages_permissions_success'));
         return redirect($page->getUrl());
     }
 }