use BookStack\Entities\Repos\BookRepo;
use BookStack\Entities\Repos\ChapterRepo;
use BookStack\Entities\Repos\PageRepo;
+use BookStack\Permissions\Permission;
use BookStack\Uploads\Image;
use BookStack\Uploads\ImageService;
use Illuminate\Http\UploadedFile;
$copyChapter = $this->chapterRepo->create($chapterDetails, $parent);
- if (userCan(\BookStack\Permissions\Permission::PageCreate, $copyChapter)) {
+ if (userCan(Permission::PageCreate, $copyChapter)) {
/** @var Page $page */
foreach ($original->getVisiblePages() as $page) {
$this->clonePage($page, $copyChapter, $page->name);
/**
* Clone the given book.
- * Clones all child chapters & pages.
+ * Clones all child chapters and pages.
*/
public function cloneBook(Book $original, string $newName): Book
{
// Clone contents
$directChildren = $original->getDirectVisibleChildren();
foreach ($directChildren as $child) {
- if ($child instanceof Chapter && userCan(\BookStack\Permissions\Permission::ChapterCreate, $copyBook)) {
+ if ($child instanceof Chapter && userCan(Permission::ChapterCreate, $copyBook)) {
$this->cloneChapter($child, $copyBook, $child->name);
}
- if ($child instanceof Page && !$child->draft && userCan(\BookStack\Permissions\Permission::PageCreate, $copyBook)) {
+ if ($child instanceof Page && !$child->draft && userCan(Permission::PageCreate, $copyBook)) {
$this->clonePage($child, $copyBook, $child->name);
}
}
// Clone bookshelf relationships
/** @var Bookshelf $shelf */
foreach ($original->shelves as $shelf) {
- if (userCan(\BookStack\Permissions\Permission::BookshelfUpdate, $shelf)) {
+ if (userCan(Permission::BookshelfUpdate, $shelf)) {
$shelf->appendBook($copyBook);
}
}