Change button classes based on inheritance
This commit is contained in:
@@ -201,6 +201,8 @@ class IconHelper
|
||||
return 'fa-solid fa-lightbulb';
|
||||
case 'highlight':
|
||||
return 'fa-solid fa-highlighter';
|
||||
case 'inherit':
|
||||
return 'fa-solid fa-layer-group';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class UsersTransformer
|
||||
] : null,
|
||||
'notes'=> Helper::parseEscapedMarkedownInline($user->notes),
|
||||
'role' => $role,
|
||||
'user_permissions' => $user->getEffectivePermissions(),
|
||||
'user_permissions' => $user->decodePermissions(),
|
||||
'effective_permissions' => $user->getEffectivePermissions('true'),
|
||||
'activated' => ($user->activated == '1') ? true : false,
|
||||
'autoassign_licenses' => ($user->autoassign_licenses == '1') ? true : false,
|
||||
|
||||
@@ -305,7 +305,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||
|
||||
// The user has no permissions and is not in any groups
|
||||
if (($this->permissions == '') || ($this->permissions == 'null')) {
|
||||
return false;
|
||||
return [];
|
||||
}
|
||||
|
||||
$user_permissions = $this->permissions;
|
||||
@@ -330,22 +330,25 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||
|
||||
// If the user has an explicit permission set, use that
|
||||
if ($return_explicit) {
|
||||
|
||||
\Log::debug('using explicit');
|
||||
if ($user_permissions[$permission_from_config] == '1') {
|
||||
$effective_permissions_array[$permission_from_config] = 'grant';
|
||||
} elseif ($user_permissions[$permission_from_config] == '-1') {
|
||||
$effective_permissions_array[$permission_from_config] = 'inherit';
|
||||
} else {
|
||||
$effective_permissions_array[$permission_from_config] = 'deny';
|
||||
} else {
|
||||
$effective_permissions_array[$permission_from_config] = $this->hasAccess($permission_from_config) ? 'inherit-grant' : 'inherit-deny';
|
||||
// $effective_permissions_array[$permission_from_config] = 'inherit';
|
||||
}
|
||||
|
||||
} else {
|
||||
$effective_permissions_array[$permission_from_config] = $this->hasAccess($permission_from_config) ? 1 : 0;
|
||||
$effective_permissions_array[$permission_from_config] = $this->hasAccess($permission_from_config) ? 'grant' : 'deny';
|
||||
}
|
||||
|
||||
} else {
|
||||
\Log::debug('fallthrough');
|
||||
$effective_permissions_array[$permission_from_config] = $this->hasAccess($permission_from_config) ? 1 : 0;
|
||||
//$effective_permissions_array[$permission_from_config] = 'not in user perms';
|
||||
$effective_permissions_array[$permission_from_config] = $this->hasAccess($permission_from_config) ? 'inherit-grant' : 'inherit-deny';
|
||||
}
|
||||
// $effective_permissions_array[$permission_from_config] = $this->hasAccess($permission_from_config) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -795,10 +795,31 @@
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
@if (($user->groups->count() > 0) || ($user->hasIndividualPermissions()))
|
||||
|
||||
@foreach ($user->getEffectivePermissions(true) as $permission_name => $permissions_value)
|
||||
<span class="label label-default label-{{ ($permissions_value == '1') ? 'success' : 'danger' }}">
|
||||
<x-icon type="{{ ($permissions_value == '1') ? 'checkmark' : 'x' }}" class="text-white" /> {{ trans('permissions.'.str_slug($permission_name).'.name') }}
|
||||
</span>
|
||||
|
||||
@if($permissions_value=='grant')
|
||||
<span class="label label-default label-success">
|
||||
<x-icon type="checkmark" class="text-white" />
|
||||
{{ trans('permissions.'.str_slug($permission_name).'.name') }}
|
||||
</span>
|
||||
@elseif($permissions_value=='inherit-grant')
|
||||
<span class="label label-default label-warning">
|
||||
<x-icon type="inherit" class="text-white" />
|
||||
{{ trans('permissions.'.str_slug($permission_name).'.name') }}
|
||||
</span>
|
||||
@elseif($permissions_value=='inherit-deny')
|
||||
<span class="label label-default label-warning">
|
||||
<x-icon type="inherit" class="text-white" />
|
||||
{{ trans('permissions.'.str_slug($permission_name).'.name') }}
|
||||
</span>
|
||||
@elseif($permissions_value=='deny')
|
||||
<span class="label label-default label-danger">
|
||||
<x-icon type="x" class="text-white" />
|
||||
{{ trans('permissions.'.str_slug($permission_name).'.name') }}
|
||||
</span>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
@else
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user