diff --git a/ProcessMaker/Events/PermissionUpdated.php b/ProcessMaker/Events/PermissionUpdated.php index e7c7252c68..b12b98be64 100644 --- a/ProcessMaker/Events/PermissionUpdated.php +++ b/ProcessMaker/Events/PermissionUpdated.php @@ -4,6 +4,7 @@ use Illuminate\Foundation\Events\Dispatchable; use ProcessMaker\Contracts\SecurityLogEventInterface; +use ProcessMaker\Helpers\ArrayHelper; use ProcessMaker\Models\User; use ProcessMaker\Traits\FormatSecurityLogChanges; @@ -20,6 +21,8 @@ class PermissionUpdated implements SecurityLogEventInterface private string $userId; + private array $arrayPermissions = []; + /** * Create a new event instance. * @@ -35,6 +38,11 @@ public function __construct( $this->originalPermissions = $originalPermissions; $this->permissionType = $permissionType; $this->userId = $userId; + + $this->arrayPermissions = ArrayHelper::getArrayDifferencesWithFormat( + $this->changedPermissions, + $this->originalPermissions + ); } /** @@ -55,12 +63,21 @@ public function getData(): array '+ permission_names' => 'Super Admin - All Permissions', ]; } else { + foreach ($this->arrayPermissions as $key => $value) { + $this->arrayPermissions = ArrayHelper::replaceKeyInArray( + $this->arrayPermissions, + $key, + substr($key, 0, 1) . ' Permission' . substr($key, 2) + ); + } + return array_merge([ 'name' => [ 'label' => $userData->getAttribute('username'), 'link' => route('users.edit', $this->userId) . '#nav-profile', ], - ], $this->formatChanges($this->changedPermissions, $this->originalPermissions)); + 'last_modified' => $userData->getAttribute('updated_at') + ], $this->arrayPermissions); } }