Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions ProcessMaker/Events/AuthClientCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,46 @@ class AuthClientCreated implements SecurityLogEventInterface

private array $data;

private array $changes;

/**
* Create a new event instance.
*
* @param array $data
*
* @return void
*/
public function __construct(array $created_values)
public function __construct(array $data)
{
$this->data = [
'auth_client_id' => $created_values['id'],
'name' => $created_values['name'],
'user_id' => $created_values['user_id'],
'revoked' => $created_values['revoked'],
'provider' => $created_values['provider'],
'redirect' => $created_values['redirect'],
'password_client' => $created_values['password_client'],
'personal_access_client' => $created_values['personal_access_client'],
];
$this->changes = $created_values;
$this->data = $data;
}

/**
* Return event data
*/
public function getData(): array
{
return $this->data;
return [
'name' => [
'label' => $this->data['name'],
'link' => route('auth-clients.index'),
],
'auth_client_id' => $this->data['id'] ?? '',
'user_id' => $this->data['user_id'] ?? '',
'revoked' => $this->data['revoked'] ?? '',
'provider' => $this->data['provider'] ?? '',
'redirect' => $this->data['redirect'] ?? '',
'personal_access_client' => $this->data['personal_access_client'] ?? '',
'created_at' => $this->data['created_at'] ?? '',
];
}

/**
* Return event changes
*/
public function getChanges(): array
{
return $this->changes;
return [
'id' => $this->data['id']
];
}

/**
Expand Down
17 changes: 8 additions & 9 deletions ProcessMaker/Events/AuthClientUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,44 @@ class AuthClientUpdated implements SecurityLogEventInterface
use FormatSecurityLogChanges;

private array $original;

private array $data;

private array $changes;

private string $clientId;
private string $clientName;

/**
* Create a new event instance.
*
* @return void
*/
public function __construct(string $clientId, array $originalValues, array $changedValues)
public function __construct(string $clientId, array $originalValues, array $changedValues, $name = '')
{
$this->original = $originalValues;
$this->changes = $changedValues;
$this->clientId = $clientId;
$this->clientName = $name;
}

/**
* Return event data
* Return event data
*/
public function getData(): array
{
return array_merge([
'auth_client_id' => $this->clientId,
'name' => [
'label' => $this->changes['name'] ?? $this->clientName,
'link' => route('auth-clients.index'),
],
'last_modified' => $this->changes['updated_at'] ?? Carbon::now(),
], $this->formatChanges($this->changes, $this->original));
}

/**
* Return event changes
* Return event changes
*/
public function getChanges(): array
{
return [
'auth_client_id' => $this->clientId,
'id' => $this->clientId,
];
}

Expand Down
8 changes: 7 additions & 1 deletion ProcessMaker/Events/CustomizeUiUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ public function buildData()
$this->original['variables'] = $varOriginal;
}
$this->data = array_merge(
['last_modified' => Carbon::now()],
[
'name' => [
'label' => 'Customize Ui',
'link' => route('customize-ui.edit'),
],
'last_modified' => Carbon::now()
],
$this->formatChanges($this->changes, $this->original)
);
}
Expand Down
11 changes: 8 additions & 3 deletions ProcessMaker/Events/PermissionUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

class PermissionUpdated implements SecurityLogEventInterface
{
use Dispatchable, FormatSecurityLogChanges;
use Dispatchable;
use FormatSecurityLogChanges;

private array $changedPermissions;

Expand All @@ -24,8 +25,12 @@ class PermissionUpdated implements SecurityLogEventInterface
*
* @return void
*/
public function __construct(array $changedPermissions, array $originalPermissions, bool $permissionType, string $userId)
{
public function __construct(
array $changedPermissions,
array $originalPermissions,
bool $permissionType,
string $userId
) {
$this->changedPermissions = $changedPermissions;
$this->originalPermissions = $originalPermissions;
$this->permissionType = $permissionType;
Expand Down
6 changes: 4 additions & 2 deletions ProcessMaker/Events/ProcessPublished.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ public function __construct(Process $data, array $changes, array $original)
$this->original = array_diff_key($original, array_flip($this::REMOVE_KEYS));

// Get category name
$this->original['process_category'] = isset($original['process_category_id']) ? ProcessCategory::getNamesByIds($this->original['process_category_id']) : '';
$this->original['process_category'] = isset($original['process_category_id'])
? ProcessCategory::getNamesByIds($this->original['process_category_id']) : '';
unset($this->original['process_category_id']);
$this->changes['process_category'] = isset($changes['process_category_id']) ? ProcessCategory::getNamesByIds($this->changes['process_category_id']) : '';
$this->changes['process_category'] = isset($changes['process_category_id'])
? ProcessCategory::getNamesByIds($this->changes['process_category_id']) : '';
unset($this->changes['process_category_id']);
}

Expand Down
10 changes: 7 additions & 3 deletions ProcessMaker/Events/ScreenCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ProcessMaker\Events;

use Carbon\Carbon;
use Illuminate\Foundation\Events\Dispatchable;
use ProcessMaker\Contracts\SecurityLogEventInterface;
use ProcessMaker\Models\ScreenCategory;
Expand Down Expand Up @@ -35,11 +36,14 @@ public function __construct(array $newScreen)
public function getData(): array
{
return [
'name' => $this->newScreen['title'] ?? '',
'created_at' => $this->newScreen['created_at'] ?? '',
'name' => [
'label' => $this->newScreen['title'],
'link' => route('screen-builder.edit', ['screen' => $this->newScreen['id']]),
],
'description' => $this->newScreen['description'] ?? '',
'type' => $this->newScreen['type'] ?? '',
'screen_category' => $this->newScreen['screen_category'] ?? '',
'Screen Categories' => $this->newScreen['screen_category'] ?? '',
'created_at' => $this->newScreen['created_at'] ?? Carbon::now(),
];
}

Expand Down
4 changes: 2 additions & 2 deletions ProcessMaker/Events/ScreenDeleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function __construct(Screen $screen)
public function getData(): array
{
return [
'title' => $this->screen->getAttributes()['title'],
'description' => $this->screen->getAttributes()['description'],
'name' => $this->screen->getAttribute('title'),
'description' => $this->screen->getAttribute('description'),
'deleted_at' => Carbon::now(),
];
}
Expand Down
17 changes: 10 additions & 7 deletions ProcessMaker/Events/ScreenUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ public function __construct(Screen $screen, array $changes, array $original)

// Get category name
$this->original['screen_category'] = isset($original['screen_category_id'])
? ScreenCategory::getNamesByIds($this->original['screen_category_id'])
: '';
? ScreenCategory::getNamesByIds($this->original['screen_category_id']) : '';
unset($this->original['screen_category_id']);
$this->changes['screen_category'] = isset($changes['tmp_screen_category_id'])
? ScreenCategory::getNamesByIds($this->changes['tmp_screen_category_id'])
: '';
? ScreenCategory::getNamesByIds($this->changes['tmp_screen_category_id']) : '';
$this->changes = array_diff_key($this->changes, array_flip($this::REMOVE_KEYS));
}

Expand All @@ -54,10 +52,15 @@ public function __construct(Screen $screen, array $changes, array $original)
*/
public function getData(): array
{
$basic = [
'name' => [
'label' => $this->screen->getAttribute('title'),
'link' => route('screen-builder.edit', ['screen' => $this->screen->getAttribute('id')]),
],
'last_modified' => $this->screen->getAttribute('updated_at'),
];
if (array_key_exists('config', $this->changes)) {
return array_merge([
'last_modified' => $this->screen->getAttribute('updated_at'),
]);
return $basic;
} else {
return array_merge([
'last_modified' => $this->screen->getAttribute('updated_at'),
Expand Down
22 changes: 9 additions & 13 deletions ProcessMaker/Events/ScriptCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ class ScriptCreated implements SecurityLogEventInterface
use FormatSecurityLogChanges;

private array $changes;

private array $original;

public string $categoryName = '';
private string $categoryName = '';

private Script $script;

Expand Down Expand Up @@ -56,20 +53,19 @@ public function getChanges(): array
*/
public function getData(): array
{
$basic = isset($this->changes['code']) ? [
'name' => $this->script->getAttribute('title'),
'created_at' => $this->script->getAttribute('created_at'),
] : [
'name' => $this->script->getAttribute('title'),
'created_at' => $this->script->getAttribute('created_at'),
$configCode = isset($this->changes['code']) ? [] : [
'description' => $this->script->getAttribute('description'),
'category' => $this->categoryName,
'language' => $this->script->getAttribute('language'),
];
unset($this->changes['code']);
unset($this->original['code']);

return array_merge($basic, $this->formatChanges($this->changes, []));
return array_merge([
'name' => [
'label' => $this->script->getAttribute('title'),
'link' => route('scripts.index'),
],
'created_at' => $this->script->getAttribute('created_at'),
], $configCode);
}

public function getEventName(): string
Expand Down
31 changes: 18 additions & 13 deletions ProcessMaker/Events/ScriptExecutorCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,44 @@ class ScriptExecutorCreated implements SecurityLogEventInterface

private array $data;

private array $changes;

/**
* Create a new event instance.
*
* @param array $data
*
* @return void
*/
public function __construct(array $created_values)
public function __construct(array $data)
{
$this->changes = $created_values;
$this->data = [
'script_executor_id' => $created_values['id'],
'title' => $created_values['title'],
'description' => isset($created_values['description']) ? $created_values['description'] : '',
'language' => $created_values['language'],
'config' => $created_values['config'],
];
$this->data = $data;
}

/**
* Return event data
*/
public function getData(): array
{
return $this->data;
return [
'name' => [
'label' => $this->data['title'],
'link' => route('script-executors.index'),
],
'script_executor_id' => $this->data['id'] ?? '',
'description' => isset($this->data['description']) ? $this->data['description'] : '',
'language' => $this->data['language'] ?? '',
'config' => $this->data['config'] ?? '',
'created_at' => $this->data['created_at'] ?? '',
];
}

/**
* Return event changes
*/
public function getChanges(): array
{
return [];
return [
'script_executor_id' => $this->data['id'] ?? '',
];
}

/**
Expand Down
18 changes: 9 additions & 9 deletions ProcessMaker/Events/ScriptExecutorDeleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ProcessMaker\Events;

use Carbon\Carbon;
use Illuminate\Foundation\Events\Dispatchable;
use ProcessMaker\Contracts\SecurityLogEventInterface;

Expand All @@ -11,16 +12,16 @@ class ScriptExecutorDeleted implements SecurityLogEventInterface

private array $data;

private array $changes;

/**
* Create a new event instance.
*
* @param array $data
*
* @return void
*/
public function __construct(array $deleted_values)
public function __construct(array $data)
{
$this->changes = $deleted_values;
$this->data = $data;
}

/**
Expand All @@ -29,20 +30,19 @@ public function __construct(array $deleted_values)
public function getData(): array
{
return [
'script_executor_id' => $this->changes['id'] ?? '',
'title' => $this->changes['title'] ?? '',
'description' => $this->changes['description'] ?? '',
'name' => $this->data['title'] ?? '',
'description' => $this->data['description'] ?? '',
'deleted_at' => Carbon::now(),
];
}

/**
* Return event changes
* Return event changes
*/
public function getChanges(): array
{
return [
'id' => $this->changes['id'] ?? '',
'id' => $this->data['id'] ?? '',
];
}

Expand Down
Loading