mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-03-31 12:15:12 +08:00
Updated restricted usage on search and entity meta details
Also removed now unused view.
This commit is contained in:
parent
803934d020
commit
63056dbef4
@ -182,12 +182,9 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
|
||||
/**
|
||||
* 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()
|
||||
->where('role_id', '=', $role_id)
|
||||
->where($action, '=', true)
|
||||
->count() > 0;
|
||||
return $this->permissions()->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,7 +162,7 @@ class SearchRunner
|
||||
$entityQuery = $entityModelInstance->newQuery()->scopes('visible');
|
||||
|
||||
if ($entityModelInstance instanceof Page) {
|
||||
$entityQuery->select(array_merge($entityModelInstance::$listAttributes, ['restricted', 'owned_by']));
|
||||
$entityQuery->select(array_merge($entityModelInstance::$listAttributes, ['owned_by']));
|
||||
} else {
|
||||
$entityQuery->select(['*']);
|
||||
}
|
||||
@ -447,7 +447,7 @@ class SearchRunner
|
||||
|
||||
protected function filterIsRestricted(EloquentBuilder $query, Entity $model, $input)
|
||||
{
|
||||
$query->where('restricted', '=', true);
|
||||
$query->whereHas('permissions');
|
||||
}
|
||||
|
||||
protected function filterViewedByMe(EloquentBuilder $query, Entity $model, $input)
|
||||
|
@ -71,7 +71,7 @@
|
||||
<h5>{{ trans('common.details') }}</h5>
|
||||
<div class="blended-links">
|
||||
@include('entities.meta', ['entity' => $book])
|
||||
@if($book->restricted)
|
||||
@if($book->hasPermissions())
|
||||
<div class="active-restriction">
|
||||
@if(userCan('restrictions-manage', $book))
|
||||
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
|
||||
|
@ -69,7 +69,7 @@
|
||||
<div class="blended-links">
|
||||
@include('entities.meta', ['entity' => $chapter])
|
||||
|
||||
@if($book->restricted)
|
||||
@if($book->hasPermissions())
|
||||
<div class="active-restriction">
|
||||
@if(userCan('restrictions-manage', $book))
|
||||
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
|
||||
@ -85,7 +85,7 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($chapter->restricted)
|
||||
@if($chapter->hasPermissions())
|
||||
<div class="active-restriction">
|
||||
@if(userCan('restrictions-manage', $chapter))
|
||||
<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">
|
||||
@include('entities.meta', ['entity' => $page])
|
||||
|
||||
@if($book->restricted)
|
||||
@if($book->hasPermissions())
|
||||
<div class="active-restriction">
|
||||
@if(userCan('restrictions-manage', $book))
|
||||
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
|
||||
@ -97,7 +97,7 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($page->chapter && $page->chapter->restricted)
|
||||
@if($page->chapter && $page->chapter->hasPermissions())
|
||||
<div class="active-restriction">
|
||||
@if(userCan('restrictions-manage', $page->chapter))
|
||||
<a href="{{ $page->chapter->getUrl('/permissions') }}" class="entity-meta-item">
|
||||
@ -113,7 +113,7 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($page->restricted)
|
||||
@if($page->hasPermissions())
|
||||
<div class="active-restriction">
|
||||
@if(userCan('restrictions-manage', $page))
|
||||
<a href="{{ $page->getUrl('/permissions') }}" class="entity-meta-item">
|
||||
|
@ -85,7 +85,7 @@
|
||||
<h5>{{ trans('common.details') }}</h5>
|
||||
<div class="blended-links">
|
||||
@include('entities.meta', ['entity' => $shelf])
|
||||
@if($shelf->restricted)
|
||||
@if($shelf->hasPermissions())
|
||||
<div class="active-restriction">
|
||||
@if(userCan('restrictions-manage', $shelf))
|
||||
<a href="{{ $shelf->getUrl('/permissions') }}" class="entity-meta-item">
|
||||
|
Loading…
x
Reference in New Issue
Block a user