<?php namespace BookStack;
-
class Bookshelf extends Entity
{
protected $table = 'bookshelves';
protected function showDeletedImages($paths)
{
- if ($this->getOutput()->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL) return;
+ if ($this->getOutput()->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL) {
+ return;
+ }
if (count($paths) > 0) {
$this->line('Images to delete:');
}
session()->flash('success', trans('entities.shelves_copy_permission_success', ['count' => $updateCount]));
return redirect($bookshelf->getUrl());
}
-
}
{
return Images::getThumbnail($this, $width, $height, $keepRatio);
}
-
}
$updatedBookCount = 0;
foreach ($shelfBooks as $book) {
- if (!userCan('restrictions-manage', $book)) continue;
+ if (!userCan('restrictions-manage', $book)) {
+ continue;
+ }
$book->permissions()->delete();
$book->restricted = $bookshelf->restricted;
$book->permissions()->createMany($shelfPermissions);
$deletedPaths = [];
$this->image->newQuery()->whereIn('type', $types)
- ->chunk(1000, function($images) use ($types, $checkRevisions, &$deletedPaths, $dryRun) {
- foreach ($images as $image) {
- $searchQuery = '%' . basename($image->path) . '%';
- $inPage = DB::table('pages')
+ ->chunk(1000, function ($images) use ($types, $checkRevisions, &$deletedPaths, $dryRun) {
+ foreach ($images as $image) {
+ $searchQuery = '%' . basename($image->path) . '%';
+ $inPage = DB::table('pages')
->where('html', 'like', $searchQuery)->count() > 0;
- $inRevision = false;
- if ($checkRevisions) {
- $inRevision = DB::table('page_revisions')
+ $inRevision = false;
+ if ($checkRevisions) {
+ $inRevision = DB::table('page_revisions')
->where('html', 'like', $searchQuery)->count() > 0;
- }
-
- if (!$inPage && !$inRevision) {
- $deletedPaths[] = $image->path;
- if (!$dryRun) {
- $this->destroy($image);
- }
- }
- }
- });
+ }
+
+ if (!$inPage && !$inRevision) {
+ $deletedPaths[] = $image->path;
+ if (!$dryRun) {
+ $this->destroy($image);
+ }
+ }
+ }
+ });
return $deletedPaths;
}
$groupNames[$i] = str_replace(' ', '-', trim(strtolower($groupName)));
}
- $roles = Role::query()->where(function(Builder $query) use ($groupNames) {
+ $roles = Role::query()->where(function (Builder $query) use ($groupNames) {
$query->whereIn('name', $groupNames);
foreach ($groupNames as $groupName) {
$query->orWhere('external_auth_id', 'LIKE', '%' . $groupName . '%');
}
})->get();
- $matchedRoles = $roles->filter(function(Role $role) use ($groupNames) {
+ $matchedRoles = $roles->filter(function (Role $role) use ($groupNames) {
return $this->roleMatchesGroupNames($role, $groupNames);
});
$roleName = str_replace(' ', '-', trim(strtolower($role->display_name)));
return in_array($roleName, $groupNames);
}
-
}
* @param Page $page
*/
public function __construct(
- JointPermission $jointPermission, EntityPermission $entityPermission, Role $role, Connection $db,
- Bookshelf $bookshelf, Book $book, Chapter $chapter, Page $page
- )
- {
+ JointPermission $jointPermission,
+ EntityPermission $entityPermission,
+ Role $role,
+ Connection $db,
+ Bookshelf $bookshelf,
+ Book $book,
+ Chapter $chapter,
+ Page $page
+ ) {
$this->db = $db;
$this->jointPermission = $jointPermission;
$this->entityPermission = $entityPermission;
// Chunk through all bookshelves
$this->bookshelf->newQuery()->select(['id', 'restricted', 'created_by'])
->chunk(50, function ($shelves) use ($roles) {
- $this->buildJointPermissionsForShelves($shelves, $roles);
- });
+ $this->buildJointPermissionsForShelves($shelves, $roles);
+ });
}
/**