]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Tools/BookContents.php
Guest create page: name field autofocus
[bookstack] / app / Entities / Tools / BookContents.php
index 0ad424de2d0797aca7e5d10db5afe0976d7c58a0..f45bdfcc1b98fabcdb2d4dc774c30752a7582ef1 100644 (file)
@@ -181,7 +181,7 @@ class BookContents
             $model->changeBook($newBook->id);
         }
 
-        if ($chapterChanged) {
+        if ($model instanceof Page && $chapterChanged) {
             $model->chapter_id = $newChapter->id ?? 0;
         }
 
@@ -235,7 +235,7 @@ class BookContents
             }
 
             $hasPageEditPermission = userCan('page-update', $model);
-            $newParentInRightLocation = ($newParent instanceof Book || $newParent->book_id === $newBook->id);
+            $newParentInRightLocation = ($newParent instanceof Book || ($newParent instanceof Chapter && $newParent->book_id === $newBook->id));
             $newParentPermission = ($newParent instanceof Chapter) ? 'chapter-update' : 'book-update';
             $hasNewParentPermission = userCan($newParentPermission, $newParent);