forked from mirror/pixelfed
Update UserRoleService, add useDefaultFallback parameter
This commit is contained in:
parent
cbe75ce871
commit
0ef6812709
1 changed files with 12 additions and 4 deletions
|
@ -6,11 +6,18 @@ use App\Models\UserRoles;
|
||||||
|
|
||||||
class UserRoleService
|
class UserRoleService
|
||||||
{
|
{
|
||||||
public static function can($action, $id)
|
public static function can($action, $id, $useDefaultFallback = true)
|
||||||
{
|
{
|
||||||
|
$default = self::defaultRoles();
|
||||||
$roles = self::get($id);
|
$roles = self::get($id);
|
||||||
|
return
|
||||||
return in_array($action, $roles) ? $roles[$action] : null;
|
in_array($action, array_keys($roles)) ?
|
||||||
|
$roles[$action] :
|
||||||
|
(
|
||||||
|
$useDefaultFallback ?
|
||||||
|
$default[$action] :
|
||||||
|
false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get($id)
|
public static function get($id)
|
||||||
|
@ -36,6 +43,7 @@ class UserRoleService
|
||||||
'can-view-public-feed' => true,
|
'can-view-public-feed' => true,
|
||||||
'can-view-network-feed' => true,
|
'can-view-network-feed' => true,
|
||||||
'can-view-discover' => true,
|
'can-view-discover' => true,
|
||||||
|
'can-view-hashtag-feed' => false,
|
||||||
|
|
||||||
'can-post' => true,
|
'can-post' => true,
|
||||||
'can-comment' => true,
|
'can-comment' => true,
|
||||||
|
|
Loading…
Reference in a new issue