0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-04-30 06:30:03 +00:00

Fixed formatting via phpcbf

This commit is contained in:
Dan Brown 2018-09-21 18:48:47 +01:00
parent e60d11ee04
commit c47b578599
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
8 changed files with 35 additions and 30 deletions

View file

@ -1,6 +1,5 @@
<?php namespace BookStack; <?php namespace BookStack;
class Bookshelf extends Entity class Bookshelf extends Entity
{ {
protected $table = 'bookshelves'; protected $table = 'bookshelves';

View file

@ -72,7 +72,9 @@ class CleanupImages extends Command
protected function showDeletedImages($paths) protected function showDeletedImages($paths)
{ {
if ($this->getOutput()->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL) return; if ($this->getOutput()->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL) {
return;
}
if (count($paths) > 0) { if (count($paths) > 0) {
$this->line('Images to delete:'); $this->line('Images to delete:');
} }

View file

@ -240,5 +240,4 @@ class BookshelfController extends Controller
session()->flash('success', trans('entities.shelves_copy_permission_success', ['count' => $updateCount])); session()->flash('success', trans('entities.shelves_copy_permission_success', ['count' => $updateCount]));
return redirect($bookshelf->getUrl()); return redirect($bookshelf->getUrl());
} }
} }

View file

@ -19,5 +19,4 @@ class Image extends Ownable
{ {
return Images::getThumbnail($this, $width, $height, $keepRatio); return Images::getThumbnail($this, $width, $height, $keepRatio);
} }
} }

View file

@ -1297,7 +1297,9 @@ class EntityRepo
$updatedBookCount = 0; $updatedBookCount = 0;
foreach ($shelfBooks as $book) { foreach ($shelfBooks as $book) {
if (!userCan('restrictions-manage', $book)) continue; if (!userCan('restrictions-manage', $book)) {
continue;
}
$book->permissions()->delete(); $book->permissions()->delete();
$book->restricted = $bookshelf->restricted; $book->restricted = $bookshelf->restricted;
$book->permissions()->createMany($shelfPermissions); $book->permissions()->createMany($shelfPermissions);

View file

@ -316,25 +316,25 @@ class ImageService extends UploadService
$deletedPaths = []; $deletedPaths = [];
$this->image->newQuery()->whereIn('type', $types) $this->image->newQuery()->whereIn('type', $types)
->chunk(1000, function($images) use ($types, $checkRevisions, &$deletedPaths, $dryRun) { ->chunk(1000, function ($images) use ($types, $checkRevisions, &$deletedPaths, $dryRun) {
foreach ($images as $image) { foreach ($images as $image) {
$searchQuery = '%' . basename($image->path) . '%'; $searchQuery = '%' . basename($image->path) . '%';
$inPage = DB::table('pages') $inPage = DB::table('pages')
->where('html', 'like', $searchQuery)->count() > 0; ->where('html', 'like', $searchQuery)->count() > 0;
$inRevision = false; $inRevision = false;
if ($checkRevisions) { if ($checkRevisions) {
$inRevision = DB::table('page_revisions') $inRevision = DB::table('page_revisions')
->where('html', 'like', $searchQuery)->count() > 0; ->where('html', 'like', $searchQuery)->count() > 0;
} }
if (!$inPage && !$inRevision) { if (!$inPage && !$inRevision) {
$deletedPaths[] = $image->path; $deletedPaths[] = $image->path;
if (!$dryRun) { if (!$dryRun) {
$this->destroy($image); $this->destroy($image);
} }
} }
} }
}); });
return $deletedPaths; return $deletedPaths;
} }

View file

@ -330,14 +330,14 @@ class LdapService
$groupNames[$i] = str_replace(' ', '-', trim(strtolower($groupName))); $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); $query->whereIn('name', $groupNames);
foreach ($groupNames as $groupName) { foreach ($groupNames as $groupName) {
$query->orWhere('external_auth_id', 'LIKE', '%' . $groupName . '%'); $query->orWhere('external_auth_id', 'LIKE', '%' . $groupName . '%');
} }
})->get(); })->get();
$matchedRoles = $roles->filter(function(Role $role) use ($groupNames) { $matchedRoles = $roles->filter(function (Role $role) use ($groupNames) {
return $this->roleMatchesGroupNames($role, $groupNames); return $this->roleMatchesGroupNames($role, $groupNames);
}); });
@ -366,5 +366,4 @@ class LdapService
$roleName = str_replace(' ', '-', trim(strtolower($role->display_name))); $roleName = str_replace(' ', '-', trim(strtolower($role->display_name)));
return in_array($roleName, $groupNames); return in_array($roleName, $groupNames);
} }
} }

View file

@ -48,10 +48,15 @@ class PermissionService
* @param Page $page * @param Page $page
*/ */
public function __construct( public function __construct(
JointPermission $jointPermission, EntityPermission $entityPermission, Role $role, Connection $db, JointPermission $jointPermission,
Bookshelf $bookshelf, Book $book, Chapter $chapter, Page $page EntityPermission $entityPermission,
) Role $role,
{ Connection $db,
Bookshelf $bookshelf,
Book $book,
Chapter $chapter,
Page $page
) {
$this->db = $db; $this->db = $db;
$this->jointPermission = $jointPermission; $this->jointPermission = $jointPermission;
$this->entityPermission = $entityPermission; $this->entityPermission = $entityPermission;
@ -169,8 +174,8 @@ class PermissionService
// Chunk through all bookshelves // Chunk through all bookshelves
$this->bookshelf->newQuery()->select(['id', 'restricted', 'created_by']) $this->bookshelf->newQuery()->select(['id', 'restricted', 'created_by'])
->chunk(50, function ($shelves) use ($roles) { ->chunk(50, function ($shelves) use ($roles) {
$this->buildJointPermissionsForShelves($shelves, $roles); $this->buildJointPermissionsForShelves($shelves, $roles);
}); });
} }
/** /**