Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
473ead9616
3 changed files with 41 additions and 24 deletions
|
@ -76,28 +76,32 @@ class Group extends SnipeModel
|
|||
*
|
||||
* @author A. Gianotto <snipe@snipe.net>
|
||||
* @since [v1.0]
|
||||
* @return array
|
||||
* @return array | \stdClass
|
||||
*/
|
||||
public function decodePermissions()
|
||||
{
|
||||
// Set default to empty JSON if the value is null
|
||||
// If the permissions are an array, convert it to JSON
|
||||
if (is_array($this->permissions)) {
|
||||
$this->permissions = json_encode($this->permissions);
|
||||
}
|
||||
|
||||
$permissions = json_decode($this->permissions ?? '{}', JSON_OBJECT_AS_ARRAY);
|
||||
|
||||
// If there are no permissions, return an empty array
|
||||
if (!$permissions) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Otherwise, loop through the permissions and cast the values as integers
|
||||
foreach ($permissions as $permission => $value) {
|
||||
$permissions[$permission] = (int) $value;
|
||||
if ((is_array($permissions)) && ($permissions)) {
|
||||
foreach ($permissions as $permission => $value) {
|
||||
|
||||
if (!is_integer($permission)) {
|
||||
$permissions[$permission] = (int) $value;
|
||||
} else {
|
||||
\Log::info('Weird data here - skipping it');
|
||||
unset($permissions[$permission]);
|
||||
}
|
||||
}
|
||||
return $permissions ?: new \stdClass;
|
||||
}
|
||||
return new \stdClass;
|
||||
|
||||
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -746,24 +746,36 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Decode JSON permissions into array
|
||||
*
|
||||
* @author A. Gianotto <snipe@snipe.net>
|
||||
* @since [v1.0]
|
||||
* @return array | \stdClass
|
||||
*/
|
||||
public function decodePermissions()
|
||||
{
|
||||
// Set default to empty JSON if the value is null
|
||||
// If the permissions are an array, convert it to JSON
|
||||
if (is_array($this->permissions)) {
|
||||
$this->permissions = json_encode($this->permissions);
|
||||
}
|
||||
|
||||
$permissions = json_decode($this->permissions ?? '{}', JSON_OBJECT_AS_ARRAY);
|
||||
|
||||
// If there are no permissions, return an empty array
|
||||
if (!$permissions) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Otherwise, loop through the permissions and cast the values as integers
|
||||
foreach ($permissions as $permission => $value) {
|
||||
$permissions[$permission] = (int) $value;
|
||||
if ((is_array($permissions)) && ($permissions)) {
|
||||
foreach ($permissions as $permission => $value) {
|
||||
|
||||
if (!is_integer($permission)) {
|
||||
$permissions[$permission] = (int) $value;
|
||||
} else {
|
||||
\Log::info('Weird data here - skipping it');
|
||||
unset($permissions[$permission]);
|
||||
}
|
||||
}
|
||||
return $permissions ?: new \stdClass;
|
||||
}
|
||||
|
||||
|
||||
return $permissions;
|
||||
return new \stdClass;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
<th data-switchable="true" data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
||||
<th data-switchable="true" data-sortable="true" data-field="name" data-formatter="groupsAdminLinkFormatter" data-visible="true">{{ trans('admin/groups/table.name') }}</th>
|
||||
<th data-switchable="true" data-sortable="true" data-field="users_count" data-visible="true"><x-icon type="user" /><span class="sr-only">{{ trans('admin/groups/table.users') }}</span></th>
|
||||
<th data-switchable="true" data-sortable="true" data-field="created_at" data-visible="true" data-formatter="dateDisplayFormatter">{{ trans('general.created_at') }}</th>
|
||||
<th data-switchable="true" data-sortable="true" data-field="notes" data-visible="true">{{ trans('general.notes') }}</th>
|
||||
<th data-switchable="true" data-sortable="true" data-field="created_at" data-visible="true" data-formatter="dateDisplayFormatter">{{ trans('general.created_at') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="true" data-field="created_by" data-formatter="usersLinkObjFormatter">{{ trans('general.created_by') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions" data-formatter="groupsActionsFormatter">{{ trans('table.actions') }}</th>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue