1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Added user-interface for "Everyone Else" entity permission item

Nothing on back-end logic done to hook this new option up.
Addition of permissions for role_id=0 works out of the box, but active
"everyone else" permissions, with no priviliges, is currently not
working. Needs change of permission gen logic also.
This commit is contained in:
Dan Brown
2022-10-02 18:09:48 +01:00
parent b8b0afa0df
commit a03245e427
10 changed files with 87 additions and 17 deletions

View File

@@ -120,6 +120,19 @@ class Role extends Model implements Loggable
->get();
}
/**
* Get a role to represent the case of 'Everyone else' in the system.
* Used within the interface since the default-fallback for permissions uses role_id=0.
*/
public static function getEveryoneElseRole(): self
{
return (new static())->forceFill([
'id' => 0,
'display_name' => 'Everyone Else',
'description' => 'Set permissions for all roles not specifically overridden.'
]);
}
/**
* {@inheritdoc}
*/

View File

@@ -184,8 +184,10 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
*/
public function hasRestriction(int $role_id, string $action): bool
{
return $this->permissions()->where('role_id', '=', $role_id)
->where('action', '=', $action)->count() > 0;
return $this->permissions()
->where('role_id', '=', $role_id)
->where('action', '=', $action)
->count() > 0;
}
/**