mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-30 22:50:05 +00:00
Updated restricted usage on search and entity meta details
Also removed now unused view.
This commit is contained in:
parent
803934d020
commit
63056dbef4
7 changed files with 11 additions and 27 deletions
app
resources/views
books
chapters
form
pages
shelves
|
@ -182,12 +182,9 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
|
||||||
/**
|
/**
|
||||||
* Check if this entity has a specific restriction set against it.
|
* Check if this entity has a specific restriction set against it.
|
||||||
*/
|
*/
|
||||||
public function hasRestriction(int $role_id, string $action): bool
|
public function hasPermissions(): bool
|
||||||
{
|
{
|
||||||
return $this->permissions()
|
return $this->permissions()->count() > 0;
|
||||||
->where('role_id', '=', $role_id)
|
|
||||||
->where($action, '=', true)
|
|
||||||
->count() > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -162,7 +162,7 @@ class SearchRunner
|
||||||
$entityQuery = $entityModelInstance->newQuery()->scopes('visible');
|
$entityQuery = $entityModelInstance->newQuery()->scopes('visible');
|
||||||
|
|
||||||
if ($entityModelInstance instanceof Page) {
|
if ($entityModelInstance instanceof Page) {
|
||||||
$entityQuery->select(array_merge($entityModelInstance::$listAttributes, ['restricted', 'owned_by']));
|
$entityQuery->select(array_merge($entityModelInstance::$listAttributes, ['owned_by']));
|
||||||
} else {
|
} else {
|
||||||
$entityQuery->select(['*']);
|
$entityQuery->select(['*']);
|
||||||
}
|
}
|
||||||
|
@ -447,7 +447,7 @@ class SearchRunner
|
||||||
|
|
||||||
protected function filterIsRestricted(EloquentBuilder $query, Entity $model, $input)
|
protected function filterIsRestricted(EloquentBuilder $query, Entity $model, $input)
|
||||||
{
|
{
|
||||||
$query->where('restricted', '=', true);
|
$query->whereHas('permissions');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function filterViewedByMe(EloquentBuilder $query, Entity $model, $input)
|
protected function filterViewedByMe(EloquentBuilder $query, Entity $model, $input)
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
<h5>{{ trans('common.details') }}</h5>
|
<h5>{{ trans('common.details') }}</h5>
|
||||||
<div class="blended-links">
|
<div class="blended-links">
|
||||||
@include('entities.meta', ['entity' => $book])
|
@include('entities.meta', ['entity' => $book])
|
||||||
@if($book->restricted)
|
@if($book->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
@if(userCan('restrictions-manage', $book))
|
@if(userCan('restrictions-manage', $book))
|
||||||
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
|
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
<div class="blended-links">
|
<div class="blended-links">
|
||||||
@include('entities.meta', ['entity' => $chapter])
|
@include('entities.meta', ['entity' => $chapter])
|
||||||
|
|
||||||
@if($book->restricted)
|
@if($book->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
@if(userCan('restrictions-manage', $book))
|
@if(userCan('restrictions-manage', $book))
|
||||||
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
|
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if($chapter->restricted)
|
@if($chapter->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
@if(userCan('restrictions-manage', $chapter))
|
@if(userCan('restrictions-manage', $chapter))
|
||||||
<a href="{{ $chapter->getUrl('/permissions') }}" class="entity-meta-item">
|
<a href="{{ $chapter->getUrl('/permissions') }}" class="entity-meta-item">
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{{--
|
|
||||||
$name
|
|
||||||
$label
|
|
||||||
$role
|
|
||||||
$action
|
|
||||||
$model?
|
|
||||||
--}}
|
|
||||||
@include('form.custom-checkbox', [
|
|
||||||
'name' => $name . '[' . $role->id . '][' . $action . ']',
|
|
||||||
'label' => $label,
|
|
||||||
'value' => 'true',
|
|
||||||
'checked' => isset($model) && $model->hasRestriction($role->id, $action)
|
|
||||||
])
|
|
|
@ -81,7 +81,7 @@
|
||||||
<div class="blended-links">
|
<div class="blended-links">
|
||||||
@include('entities.meta', ['entity' => $page])
|
@include('entities.meta', ['entity' => $page])
|
||||||
|
|
||||||
@if($book->restricted)
|
@if($book->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
@if(userCan('restrictions-manage', $book))
|
@if(userCan('restrictions-manage', $book))
|
||||||
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
|
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if($page->chapter && $page->chapter->restricted)
|
@if($page->chapter && $page->chapter->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
@if(userCan('restrictions-manage', $page->chapter))
|
@if(userCan('restrictions-manage', $page->chapter))
|
||||||
<a href="{{ $page->chapter->getUrl('/permissions') }}" class="entity-meta-item">
|
<a href="{{ $page->chapter->getUrl('/permissions') }}" class="entity-meta-item">
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if($page->restricted)
|
@if($page->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
@if(userCan('restrictions-manage', $page))
|
@if(userCan('restrictions-manage', $page))
|
||||||
<a href="{{ $page->getUrl('/permissions') }}" class="entity-meta-item">
|
<a href="{{ $page->getUrl('/permissions') }}" class="entity-meta-item">
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
<h5>{{ trans('common.details') }}</h5>
|
<h5>{{ trans('common.details') }}</h5>
|
||||||
<div class="blended-links">
|
<div class="blended-links">
|
||||||
@include('entities.meta', ['entity' => $shelf])
|
@include('entities.meta', ['entity' => $shelf])
|
||||||
@if($shelf->restricted)
|
@if($shelf->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
@if(userCan('restrictions-manage', $shelf))
|
@if(userCan('restrictions-manage', $shelf))
|
||||||
<a href="{{ $shelf->getUrl('/permissions') }}" class="entity-meta-item">
|
<a href="{{ $shelf->getUrl('/permissions') }}" class="entity-meta-item">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue