From d03a59f734e53283f824b7f080abee1c8419f595 Mon Sep 17 00:00:00 2001 From: Esteban Gallego Date: Wed, 5 Jul 2023 20:00:10 -0700 Subject: [PATCH 1/7] Update editing_process to asset_id --- resources/js/components/pm-blocks/CreatePmBlockModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/components/pm-blocks/CreatePmBlockModal.vue b/resources/js/components/pm-blocks/CreatePmBlockModal.vue index 1b214f160f..6f7006d6a8 100644 --- a/resources/js/components/pm-blocks/CreatePmBlockModal.vue +++ b/resources/js/components/pm-blocks/CreatePmBlockModal.vue @@ -123,7 +123,7 @@ export default { }, savePmBlock() { let formData = new FormData(); - formData.append("editing_process_id", this.assetId); + formData.append("asset_id", this.assetId); formData.append("name", this.name); formData.append("description", this.description); formData.append("user_id", this.currentUserId); From 67cbc4c9d1a9d347136dfd1ded7f651a737494d6 Mon Sep 17 00:00:00 2001 From: Esteban Gallego Date: Thu, 6 Jul 2023 16:00:11 -0700 Subject: [PATCH 2/7] New version of Publish PmBlocks --- ProcessMaker/Traits/HideSystemResources.php | 6 +++++- resources/js/components/pm-blocks/CreatePmBlockModal.vue | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ProcessMaker/Traits/HideSystemResources.php b/ProcessMaker/Traits/HideSystemResources.php index e23777cea5..8e86a44711 100644 --- a/ProcessMaker/Traits/HideSystemResources.php +++ b/ProcessMaker/Traits/HideSystemResources.php @@ -65,7 +65,11 @@ public function scopeNonSystem($query) } elseif (static::class === Screen::class) { $systemCategory = ScreenCategory::where('is_system', true)->pluck('id'); - return $query->whereNotIn('screen_category_id', $systemCategory)->where('is_template', false); + return $query->whereNotIn('screen_category_id', $systemCategory) + ->where('is_template', false) + ->when(Schema::hasColumn('screens', 'asset_type'), function ($query) { + return $query->whereNull('asset_type'); + }); } elseif (static::class == ProcessRequest::class) { // ProcessRequests must be filtered this way since // they could be in a separate database diff --git a/resources/js/components/pm-blocks/CreatePmBlockModal.vue b/resources/js/components/pm-blocks/CreatePmBlockModal.vue index 6f7006d6a8..6357ff2874 100644 --- a/resources/js/components/pm-blocks/CreatePmBlockModal.vue +++ b/resources/js/components/pm-blocks/CreatePmBlockModal.vue @@ -133,7 +133,7 @@ export default { ProcessMaker.alert(this.$t("PM Block successfully created"), "success"); window.setTimeout(() => { window.location.href = `/designer/pm-blocks/${response.data.id}/edit/`; - }, 3000) + }, 1000) this.close(); }).catch(error => { this.errors = error.response.data; From 5f182545f771e78aa1746995313b342501581c14 Mon Sep 17 00:00:00 2001 From: Sanja Date: Mon, 10 Jul 2023 13:32:59 -0700 Subject: [PATCH 3/7] Add DraggableFileUpload to shared components --- resources/js/components/shared/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/js/components/shared/index.js b/resources/js/components/shared/index.js index 090e2f4483..6afb682028 100644 --- a/resources/js/components/shared/index.js +++ b/resources/js/components/shared/index.js @@ -7,6 +7,7 @@ import ColumnConfig from "./ColumnConfig"; import DataFormatSelector from "./DataFormatSelector"; import DataLoadingBasic from "./DataLoadingBasic"; import DataMaskSelector from "./DataMaskSelector"; +import DraggableFileUpload from "./DraggableFileUpload"; import EllipsisMenu from "./EllipsisMenu"; import FileUploadButton from "./FileUploadButton"; import FormErrorsMixin from "./FormErrorsMixin"; @@ -30,6 +31,7 @@ export { DataFormatSelector, DataLoadingBasic, DataMaskSelector, + DraggableFileUpload, EllipsisMenu, FileUploadButton, FormErrorsMixin, From a31dd1b94954190289f61dc61a728710d7acb5e6 Mon Sep 17 00:00:00 2001 From: Sanja Date: Thu, 13 Jul 2023 16:41:11 -0700 Subject: [PATCH 4/7] Add support for array incrementStrings; php cs fix formatting --- .../ImportExport/Exporters/ExporterBase.php | 19 ++++++++++++------- .../Nayra/Managers/WorkflowManagerDefault.php | 2 +- .../Managers/WorkflowManagerRabbitMq.php | 8 +++++++- .../Nayra/MessageBrokers/ServiceKafka.php | 2 +- .../Repositories/PersistenceRequestTrait.php | 1 + ProcessMaker/Traits/ExtendedPMQL.php | 4 +++- 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/ProcessMaker/ImportExport/Exporters/ExporterBase.php b/ProcessMaker/ImportExport/Exporters/ExporterBase.php index 58e308c55c..084e34154f 100644 --- a/ProcessMaker/ImportExport/Exporters/ExporterBase.php +++ b/ProcessMaker/ImportExport/Exporters/ExporterBase.php @@ -421,8 +421,13 @@ protected function duplicateExists($attribute, $value) : bool public function handleDuplicateAttributes() : array { $handlers = []; - foreach ($this->handleDuplicatesByIncrementing as $attr) { - $handlers[$attr] = fn ($name) => $this->incrementString($name); + foreach ($this->handleDuplicatesByIncrementing as $index => $attr) { + if (is_array($this->incrementStringSeparator)) { + $seperator = $this->incrementStringSeparator[$index]; + $handlers[$attr] = fn ($name) => $this->incrementString($name, $seperator); + } else { + $handlers[$attr] = fn ($name) => $this->incrementString($name, $this->incrementStringSeparator); + } } return $handlers; @@ -433,20 +438,20 @@ public function log($key, $value) $this->log[$key] = $value; } - protected function incrementString(string $string) + protected function incrementString(string $string, $seperator = ' ') { - if (preg_match('/' . $this->incrementStringSeparator . '(\d+)$/', $string, $matches)) { + if (preg_match('/' . $seperator . '(\d+)$/', $string, $matches)) { $num = (int) $matches[1]; $new = $num + 1; return preg_replace( - '/' . $this->incrementStringSeparator . '\d+$/', - $this->incrementStringSeparator . (string) $new, + '/' . $seperator . '\d+$/', + $seperator . (string) $new, $string ); } - return $string . $this->incrementStringSeparator . '2'; + return $string . $seperator . '2'; } protected function exportCategories() diff --git a/ProcessMaker/Nayra/Managers/WorkflowManagerDefault.php b/ProcessMaker/Nayra/Managers/WorkflowManagerDefault.php index 46f9674878..a44fa8ed3f 100644 --- a/ProcessMaker/Nayra/Managers/WorkflowManagerDefault.php +++ b/ProcessMaker/Nayra/Managers/WorkflowManagerDefault.php @@ -290,7 +290,7 @@ public function throwSignalEventRequest(ProcessRequest $request, $signalRef, arr $signalRef ); } - + /** * Catch a signal event. * diff --git a/ProcessMaker/Nayra/Managers/WorkflowManagerRabbitMq.php b/ProcessMaker/Nayra/Managers/WorkflowManagerRabbitMq.php index 53247c6ef6..2b733a1115 100644 --- a/ProcessMaker/Nayra/Managers/WorkflowManagerRabbitMq.php +++ b/ProcessMaker/Nayra/Managers/WorkflowManagerRabbitMq.php @@ -13,8 +13,8 @@ use ProcessMaker\Managers\DataManager; use ProcessMaker\Managers\SignalManager; use ProcessMaker\Models\EnvironmentVariable; -use ProcessMaker\Models\Process as Definitions; use ProcessMaker\Models\Process; +use ProcessMaker\Models\Process as Definitions; use ProcessMaker\Models\ProcessCollaboration; use ProcessMaker\Models\ProcessRequest; use ProcessMaker\Models\Script; @@ -30,11 +30,17 @@ class WorkflowManagerRabbitMq extends WorkflowManagerDefault implements WorkflowManagerInterface { const ACTION_START_PROCESS = 'START_PROCESS'; + const ACTION_COMPLETE_TASK = 'COMPLETE_TASK'; + const ACTION_TRIGGER_INTERMEDIATE_EVENT = 'TRIGGER_INTERMEDIATE_EVENT'; + const ACTION_RUN_SCRIPT = 'RUN_SCRIPT'; + const ACTION_TRIGGER_BOUNDARY_EVENT = 'TRIGGER_BOUNDARY_EVENT'; + const ACTION_TRIGGER_MESSAGE_EVENT = 'TRIGGER_MESSAGE_EVENT'; + const ACTION_TRIGGER_SIGNAL_EVENT = 'TRIGGER_SIGNAL_EVENT'; /** diff --git a/ProcessMaker/Nayra/MessageBrokers/ServiceKafka.php b/ProcessMaker/Nayra/MessageBrokers/ServiceKafka.php index cb8dd4a3eb..c4c8772733 100644 --- a/ProcessMaker/Nayra/MessageBrokers/ServiceKafka.php +++ b/ProcessMaker/Nayra/MessageBrokers/ServiceKafka.php @@ -3,8 +3,8 @@ namespace ProcessMaker\Nayra\MessageBrokers; use Junges\Kafka\Contracts\KafkaConsumerMessage; -use ProcessMaker\Nayra\Repositories\PersistenceHandler; use Junges\Kafka\Facades\Kafka; +use ProcessMaker\Nayra\Repositories\PersistenceHandler; class ServiceKafka { diff --git a/ProcessMaker/Nayra/Repositories/PersistenceRequestTrait.php b/ProcessMaker/Nayra/Repositories/PersistenceRequestTrait.php index bb0f3d64c8..6e1d334999 100644 --- a/ProcessMaker/Nayra/Repositories/PersistenceRequestTrait.php +++ b/ProcessMaker/Nayra/Repositories/PersistenceRequestTrait.php @@ -7,6 +7,7 @@ trait PersistenceRequestTrait { protected ExecutionInstanceRepository $instanceRepository; + protected Deserializer $deserializer; /** diff --git a/ProcessMaker/Traits/ExtendedPMQL.php b/ProcessMaker/Traits/ExtendedPMQL.php index 37b839afd9..69161bf708 100644 --- a/ProcessMaker/Traits/ExtendedPMQL.php +++ b/ProcessMaker/Traits/ExtendedPMQL.php @@ -20,6 +20,7 @@ trait ExtendedPMQL } protected $dataStoreTable = ''; + protected $dataStoreColumns = []; /** @@ -111,7 +112,8 @@ private function handle(Expression $expression, Builder $builder, User $user = n if ($value instanceof IntervalExpression) { $value = $value->toEloquent(); } - return function($query) use($expression, $value, $realFieldName) { + + return function ($query) use ($expression, $value, $realFieldName) { switch ($expression->operator) { case Expression::OPERATOR_IN: $query->whereIn($realFieldName, $value); From 209d6514a8718c0f4a6f82c092f2c83666a9c16a Mon Sep 17 00:00:00 2001 From: Sanja Date: Thu, 13 Jul 2023 16:41:31 -0700 Subject: [PATCH 5/7] php cs fixer --- ProcessMaker/Events/ActivityReassignment.php | 4 ++-- ProcessMaker/Events/AuthClientDeleted.php | 2 +- ProcessMaker/Events/AuthClientUpdated.php | 4 +--- ProcessMaker/Events/CategoryCreated.php | 2 +- ProcessMaker/Events/CategoryUpdated.php | 2 +- .../Events/EnvironmentVariablesCreated.php | 2 +- .../Events/EnvironmentVariablesDeleted.php | 2 +- .../Events/EnvironmentVariablesUpdated.php | 2 +- ProcessMaker/Events/FilesAccessed.php | 5 +++-- ProcessMaker/Events/FilesCreated.php | 6 +++-- ProcessMaker/Events/FilesDeleted.php | 3 ++- ProcessMaker/Events/FilesDownloaded.php | 5 +++-- ProcessMaker/Events/FilesUpdated.php | 3 ++- ProcessMaker/Events/GroupCreated.php | 2 +- ProcessMaker/Events/GroupUpdated.php | 3 ++- ProcessMaker/Events/ProcessCreated.php | 2 +- ProcessMaker/Events/ProcessPublished.php | 2 +- ProcessMaker/Events/RequestAction.php | 22 +++++++++++-------- ProcessMaker/Events/RequestError.php | 15 +++++++------ ProcessMaker/Events/ScreenCreated.php | 2 +- ProcessMaker/Events/ScreenDeleted.php | 2 +- ProcessMaker/Events/ScriptCreated.php | 7 ++++-- ProcessMaker/Events/ScriptDeleted.php | 2 +- ProcessMaker/Events/ScriptExecutorCreated.php | 2 +- ProcessMaker/Events/ScriptExecutorDeleted.php | 5 ++--- ProcessMaker/Events/ScriptExecutorUpdated.php | 6 ++--- ProcessMaker/Events/ScriptUpdated.php | 2 +- ProcessMaker/Events/SettingsUpdated.php | 2 +- ProcessMaker/Events/TemplateCreated.php | 4 ++-- ProcessMaker/Events/TemplateUpdated.php | 6 ++--- ProcessMaker/Events/TokenCreated.php | 4 +--- ProcessMaker/Events/TokenDeleted.php | 4 +--- ProcessMaker/Events/UserUpdated.php | 6 ++++- ProcessMaker/Helpers/ArrayHelper.php | 5 +++-- ProcessMaker/Helpers/SensitiveDataHelper.php | 2 +- .../Controllers/Api/CssOverrideController.php | 6 ++--- .../Api/ProcessRequestController.php | 6 ++--- .../Api/ScriptExecutorController.php | 2 +- .../Controllers/Api/SecurityLogController.php | 4 ++-- ProcessMaker/Jobs/DownloadSecurityLog.php | 14 +++++++----- ProcessMaker/Models/EnvironmentVariable.php | 3 ++- ProcessMaker/Models/ProcessCategory.php | 3 ++- ProcessMaker/Models/ScreenCategory.php | 3 ++- ProcessMaker/Models/ScriptCategory.php | 3 ++- .../Providers/EventServiceProvider.php | 2 +- .../ExecutionInstanceRepository.php | 1 + ProcessMaker/Repositories/TokenRepository.php | 1 + ProcessMaker/SanitizeHelper.php | 2 +- ProcessMaker/Traits/ProcessMapTrait.php | 5 +++-- config/rabbitmq.php | 2 +- tests/Feature/Api/ProcessRequestsTest.php | 8 +++---- tests/TestCase.php | 1 + .../ProcessMaker/Helpers/ArrayHelperTest.php | 20 ++++++++--------- .../Models/ProcessCategoryTest.php | 4 ++-- .../Models/ScreenCategoryTest.php | 4 ++-- .../Models/ScriptCategoryTest.php | 4 ++-- 56 files changed, 134 insertions(+), 113 deletions(-) diff --git a/ProcessMaker/Events/ActivityReassignment.php b/ProcessMaker/Events/ActivityReassignment.php index f63e5d6087..fb9d9457fd 100644 --- a/ProcessMaker/Events/ActivityReassignment.php +++ b/ProcessMaker/Events/ActivityReassignment.php @@ -33,11 +33,11 @@ public function getData(): array 'name_action' => $this::ACTION_REASSIGNMENT, 'request' => [ 'label' => $this->processRequest->getAttribute('process_request_id'), - 'link' => route('requests.show', ['request' => $this->processRequest->getAttribute('process_request_id')]) + 'link' => route('requests.show', ['request' => $this->processRequest->getAttribute('process_request_id')]), ], 'task' => $this->processRequest->getAttribute('element_name'), 'process' => $this->processRequest->process->name ?? '', - 'actionated_at' => $this->processRequest->getAttribute('updated_at') + 'actionated_at' => $this->processRequest->getAttribute('updated_at'), ]; } diff --git a/ProcessMaker/Events/AuthClientDeleted.php b/ProcessMaker/Events/AuthClientDeleted.php index 5d1875d6bc..8bf3957b34 100644 --- a/ProcessMaker/Events/AuthClientDeleted.php +++ b/ProcessMaker/Events/AuthClientDeleted.php @@ -32,7 +32,7 @@ public function getData(): array return [ 'auth_client_id' => $this->changes['id'] ?? 0, 'name' => $this->changes['name'] ?? 0, - 'deleted_at' => Carbon::now() + 'deleted_at' => Carbon::now(), ]; } diff --git a/ProcessMaker/Events/AuthClientUpdated.php b/ProcessMaker/Events/AuthClientUpdated.php index 275795e054..0089a6d4f2 100644 --- a/ProcessMaker/Events/AuthClientUpdated.php +++ b/ProcessMaker/Events/AuthClientUpdated.php @@ -32,7 +32,6 @@ public function __construct(string $clientId, array $originalValues, array $chan $this->clientId = $clientId; } - /** * Return event data * Return event data @@ -41,11 +40,10 @@ public function getData(): array { return array_merge([ 'auth_client_id' => $this->clientId, - 'last_modified' => $this->changes['updated_at'] ?? Carbon::now() + 'last_modified' => $this->changes['updated_at'] ?? Carbon::now(), ], $this->formatChanges($this->changes, $this->original)); } - /** * Return event changes * Return event changes diff --git a/ProcessMaker/Events/CategoryCreated.php b/ProcessMaker/Events/CategoryCreated.php index 68a85e9350..02a8127db2 100644 --- a/ProcessMaker/Events/CategoryCreated.php +++ b/ProcessMaker/Events/CategoryCreated.php @@ -54,7 +54,7 @@ public function getChanges(): array return [ 'id' => $this->category->getAttribute('id'), 'name' => $this->category->getAttribute('name'), - 'status' => $this->category->getAttribute('status') + 'status' => $this->category->getAttribute('status'), ]; } diff --git a/ProcessMaker/Events/CategoryUpdated.php b/ProcessMaker/Events/CategoryUpdated.php index a8f2ee37a1..64a828341c 100644 --- a/ProcessMaker/Events/CategoryUpdated.php +++ b/ProcessMaker/Events/CategoryUpdated.php @@ -54,7 +54,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->category->getAttribute('id') + 'id' => $this->category->getAttribute('id'), ]; } diff --git a/ProcessMaker/Events/EnvironmentVariablesCreated.php b/ProcessMaker/Events/EnvironmentVariablesCreated.php index a676148bcd..fa610f56f7 100644 --- a/ProcessMaker/Events/EnvironmentVariablesCreated.php +++ b/ProcessMaker/Events/EnvironmentVariablesCreated.php @@ -49,7 +49,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->enVariable->getAttribute('name') + 'id' => $this->enVariable->getAttribute('name'), ]; } diff --git a/ProcessMaker/Events/EnvironmentVariablesDeleted.php b/ProcessMaker/Events/EnvironmentVariablesDeleted.php index 154a2776fe..58c1947a5f 100644 --- a/ProcessMaker/Events/EnvironmentVariablesDeleted.php +++ b/ProcessMaker/Events/EnvironmentVariablesDeleted.php @@ -47,7 +47,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->enVariable->getAttribute('id') + 'id' => $this->enVariable->getAttribute('id'), ]; } diff --git a/ProcessMaker/Events/EnvironmentVariablesUpdated.php b/ProcessMaker/Events/EnvironmentVariablesUpdated.php index e11cf42bbb..70c782cd8e 100644 --- a/ProcessMaker/Events/EnvironmentVariablesUpdated.php +++ b/ProcessMaker/Events/EnvironmentVariablesUpdated.php @@ -54,7 +54,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->enVariable->getAttribute('id') + 'id' => $this->enVariable->getAttribute('id'), ]; } diff --git a/ProcessMaker/Events/FilesAccessed.php b/ProcessMaker/Events/FilesAccessed.php index bffe4b7e47..e1e565111e 100644 --- a/ProcessMaker/Events/FilesAccessed.php +++ b/ProcessMaker/Events/FilesAccessed.php @@ -14,6 +14,7 @@ class FilesAccessed implements SecurityLogEventInterface use FormatSecurityLogChanges; private array $linkFile = []; + private string $processName = ''; /** @@ -29,7 +30,7 @@ public function __construct(string $name, ProcessRequest $data = null) // Link to the request $this->linkFile = [ 'label' => $data->getAttribute('id'), - 'link' => route('requests.show', $data) + 'link' => route('requests.show', $data), ]; } else { // Link to file in the package @@ -50,7 +51,7 @@ public function getData(): array return [ 'name' => $this->linkFile, 'process' => $this->processName, - 'accessed_at' => Carbon::now() + 'accessed_at' => Carbon::now(), ]; } diff --git a/ProcessMaker/Events/FilesCreated.php b/ProcessMaker/Events/FilesCreated.php index 51ba82ce62..6257786715 100644 --- a/ProcessMaker/Events/FilesCreated.php +++ b/ProcessMaker/Events/FilesCreated.php @@ -16,7 +16,9 @@ class FilesCreated implements SecurityLogEventInterface public const NAME_PUBLIC_FILES = 'Public Files'; private array $media; + private array $name = []; + private string $processName = ''; /** @@ -42,7 +44,7 @@ public function __construct(int $fileId, ProcessRequest $data) // Link to the request $this->name = [ 'label' => $data->getAttribute('id'), - 'link' => route('requests.show', $data) + 'link' => route('requests.show', $data), ]; } } @@ -69,7 +71,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->media['id'] + 'id' => $this->media['id'], ]; } diff --git a/ProcessMaker/Events/FilesDeleted.php b/ProcessMaker/Events/FilesDeleted.php index a950a1455c..f6f1c9e5cc 100644 --- a/ProcessMaker/Events/FilesDeleted.php +++ b/ProcessMaker/Events/FilesDeleted.php @@ -13,6 +13,7 @@ class FilesDeleted implements SecurityLogEventInterface use FormatSecurityLogChanges; private int $fileId; + private string $fileName; /** @@ -47,7 +48,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->fileId + 'id' => $this->fileId, ]; } diff --git a/ProcessMaker/Events/FilesDownloaded.php b/ProcessMaker/Events/FilesDownloaded.php index e6787cc43b..7b5bfff1f6 100644 --- a/ProcessMaker/Events/FilesDownloaded.php +++ b/ProcessMaker/Events/FilesDownloaded.php @@ -14,6 +14,7 @@ class FilesDownloaded implements SecurityLogEventInterface use FormatSecurityLogChanges; private array $name = []; + private string $processName = ''; /** @@ -29,7 +30,7 @@ public function __construct(string $file, ProcessRequest $data = null) // Link to the request $this->name = [ 'label' => $data->getAttribute('id'), - 'link' => route('requests.show', $data) + 'link' => route('requests.show', $data), ]; } else { // Link to file in the package @@ -50,7 +51,7 @@ public function getData(): array return [ 'name' => $this->name, 'process' => $this->processName, - 'accessed_at' => Carbon::now() + 'accessed_at' => Carbon::now(), ]; } diff --git a/ProcessMaker/Events/FilesUpdated.php b/ProcessMaker/Events/FilesUpdated.php index 5a89acfcff..ec282e5a7b 100644 --- a/ProcessMaker/Events/FilesUpdated.php +++ b/ProcessMaker/Events/FilesUpdated.php @@ -15,6 +15,7 @@ class FilesUpdated implements SecurityLogEventInterface private Media $media; private array $changes; + private array $original; /** @@ -52,7 +53,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->media->getAttribute('id') + 'id' => $this->media->getAttribute('id'), ]; } diff --git a/ProcessMaker/Events/GroupCreated.php b/ProcessMaker/Events/GroupCreated.php index 7818c2006b..bdae25c8c4 100644 --- a/ProcessMaker/Events/GroupCreated.php +++ b/ProcessMaker/Events/GroupCreated.php @@ -49,7 +49,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->group->getAttribute('id') + 'id' => $this->group->getAttribute('id'), ]; } diff --git a/ProcessMaker/Events/GroupUpdated.php b/ProcessMaker/Events/GroupUpdated.php index 3ba0779328..5f602e7be9 100644 --- a/ProcessMaker/Events/GroupUpdated.php +++ b/ProcessMaker/Events/GroupUpdated.php @@ -15,6 +15,7 @@ class GroupUpdated implements SecurityLogEventInterface private Group $group; private array $changes; + private array $original; /** @@ -53,7 +54,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->group->getAttribute('id') + 'id' => $this->group->getAttribute('id'), ]; } diff --git a/ProcessMaker/Events/ProcessCreated.php b/ProcessMaker/Events/ProcessCreated.php index 3559d49144..8ed59a742a 100644 --- a/ProcessMaker/Events/ProcessCreated.php +++ b/ProcessMaker/Events/ProcessCreated.php @@ -60,7 +60,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->process->getAttribute('id') + 'id' => $this->process->getAttribute('id'), ]; } diff --git a/ProcessMaker/Events/ProcessPublished.php b/ProcessMaker/Events/ProcessPublished.php index 1853324758..24384e8b21 100644 --- a/ProcessMaker/Events/ProcessPublished.php +++ b/ProcessMaker/Events/ProcessPublished.php @@ -74,7 +74,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->process->getAttribute('id') + 'id' => $this->process->getAttribute('id'), ]; } diff --git a/ProcessMaker/Events/RequestAction.php b/ProcessMaker/Events/RequestAction.php index a5b0dc5efa..ae2861015c 100644 --- a/ProcessMaker/Events/RequestAction.php +++ b/ProcessMaker/Events/RequestAction.php @@ -13,7 +13,9 @@ class RequestAction implements SecurityLogEventInterface use Dispatchable; const ACTION_CANCELED = 'CANCELED'; + const ACTION_COMPLETED = 'COMPLETED'; + const ACTION_CREATED = 'CREATED'; const ACTIONS = [ @@ -21,8 +23,9 @@ class RequestAction implements SecurityLogEventInterface 'CANCELED' => 'canceled_at', 'CREATED' => 'created_at', ]; - + private ProcessRequest $data; + private string $action; /** @@ -35,34 +38,35 @@ public function __construct(ProcessRequest $data, string $action) $this->data = $data; $this->action = $action; } - + /** - * Return event data + * Return event data */ public function getData(): array { $parentProcess = Process::find($this->data->getAttribute('process_id')); + return [ 'process' => [ 'label' => $parentProcess->getAttribute('name'), - 'link' => route('modeler.show', $parentProcess) + 'link' => route('modeler.show', $parentProcess), ], 'request' => [ 'label' => $this->data->getAttribute('id'), - 'link' => route('requests.show', $this->data) + 'link' => route('requests.show', $this->data), ], 'action' => $this->action, - $this::ACTIONS[$this->action] => Carbon::now() + $this::ACTIONS[$this->action] => Carbon::now(), ]; } - + /** - * Return event changes + * Return event changes */ public function getChanges(): array { return [ - 'request_id' => $this->data->getAttribute('id') + 'request_id' => $this->data->getAttribute('id'), ]; } diff --git a/ProcessMaker/Events/RequestError.php b/ProcessMaker/Events/RequestError.php index a5795ef761..d28da908ef 100644 --- a/ProcessMaker/Events/RequestError.php +++ b/ProcessMaker/Events/RequestError.php @@ -11,8 +11,9 @@ class RequestError implements SecurityLogEventInterface { use Dispatchable; - + private ProcessRequest $data; + private string $error; /** @@ -25,24 +26,24 @@ public function __construct(ProcessRequest $data, string $error) $this->data = $data; $this->error = $error; } - + /** - * Return event data + * Return event data */ public function getData(): array { return [ 'request' => [ 'label' => $this->data->getAttribute('id'), - 'link' => route('requests.show', $this->data) + 'link' => route('requests.show', $this->data), ], 'error' => $this->error, - 'occurred_at' => Carbon::now() + 'occurred_at' => Carbon::now(), ]; } - + /** - * Return event changes + * Return event changes */ public function getChanges(): array { diff --git a/ProcessMaker/Events/ScreenCreated.php b/ProcessMaker/Events/ScreenCreated.php index 90cf0a241a..314bca13bd 100644 --- a/ProcessMaker/Events/ScreenCreated.php +++ b/ProcessMaker/Events/ScreenCreated.php @@ -38,7 +38,7 @@ public function getData(): array 'name' => $this->newScreen['title'] ?? '', 'description' => $this->newScreen['description'] ?? '', 'type' => $this->newScreen['type'] ?? '', - 'screen_category_id' => $this->newScreen['screen_category_id'] ?? '' + 'screen_category_id' => $this->newScreen['screen_category_id'] ?? '', ]; } diff --git a/ProcessMaker/Events/ScreenDeleted.php b/ProcessMaker/Events/ScreenDeleted.php index f4e1f43b79..a34ed8f578 100644 --- a/ProcessMaker/Events/ScreenDeleted.php +++ b/ProcessMaker/Events/ScreenDeleted.php @@ -45,7 +45,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->screen->getAttribute('id') + 'id' => $this->screen->getAttribute('id'), ]; } diff --git a/ProcessMaker/Events/ScriptCreated.php b/ProcessMaker/Events/ScriptCreated.php index 31d7fb2a3b..4cc96df059 100644 --- a/ProcessMaker/Events/ScriptCreated.php +++ b/ProcessMaker/Events/ScriptCreated.php @@ -14,8 +14,11 @@ class ScriptCreated implements SecurityLogEventInterface use FormatSecurityLogChanges; private array $changes; + private array $original; + public string $categoryName = ''; + private Script $script; /** @@ -38,7 +41,7 @@ public function __construct(Script $script, array $changes) public function getChanges(): array { return [ - 'script_id' => $this->script->id + 'script_id' => $this->script->id, ]; } @@ -61,7 +64,7 @@ public function getData(): array 'name' => $this->script->getAttribute('title'), 'description' => $this->script->getAttribute('description'), 'category' => $categoryName, - 'language' => $this->script->getAttribute('language') + 'language' => $this->script->getAttribute('language'), ]; unset($this->changes['code']); unset($this->original['code']); diff --git a/ProcessMaker/Events/ScriptDeleted.php b/ProcessMaker/Events/ScriptDeleted.php index a4a526486c..96942b9147 100644 --- a/ProcessMaker/Events/ScriptDeleted.php +++ b/ProcessMaker/Events/ScriptDeleted.php @@ -46,7 +46,7 @@ public function getData(): array { return [ 'name' => $this->script->getAttribute('title'), - 'deleted_at' => Carbon::now() + 'deleted_at' => Carbon::now(), ]; } diff --git a/ProcessMaker/Events/ScriptExecutorCreated.php b/ProcessMaker/Events/ScriptExecutorCreated.php index 701914b804..282d1ec95e 100644 --- a/ProcessMaker/Events/ScriptExecutorCreated.php +++ b/ProcessMaker/Events/ScriptExecutorCreated.php @@ -24,7 +24,7 @@ public function __construct(array $created_values) $this->data = [ 'script_executor_id' => $created_values['id'], 'title' => $created_values['title'], - 'description' => isset($created_values['description']) ? $created_values['description'] : "", + 'description' => isset($created_values['description']) ? $created_values['description'] : '', 'language' => $created_values['language'], 'config' => $created_values['config'], ]; diff --git a/ProcessMaker/Events/ScriptExecutorDeleted.php b/ProcessMaker/Events/ScriptExecutorDeleted.php index 43bdfef0cc..a4c40887e6 100644 --- a/ProcessMaker/Events/ScriptExecutorDeleted.php +++ b/ProcessMaker/Events/ScriptExecutorDeleted.php @@ -31,11 +31,10 @@ public function getData(): array return [ 'script_executor_id' => $this->changes['id'] ?? '', 'title' => $this->changes['title'] ?? '', - 'description' => $this->changes['description'] ?? '' + 'description' => $this->changes['description'] ?? '', ]; } - /** * Return event changes * Return event changes @@ -43,7 +42,7 @@ public function getData(): array public function getChanges(): array { return [ - 'id' => $this->changes['id'] ?? '' + 'id' => $this->changes['id'] ?? '', ]; } diff --git a/ProcessMaker/Events/ScriptExecutorUpdated.php b/ProcessMaker/Events/ScriptExecutorUpdated.php index b8431482ee..1537b70b5f 100644 --- a/ProcessMaker/Events/ScriptExecutorUpdated.php +++ b/ProcessMaker/Events/ScriptExecutorUpdated.php @@ -32,7 +32,6 @@ public function __construct(int $scriptId, array $originalValues, array $changed $this->scriptId = $scriptId; } - /** * Return event data * Return event data @@ -41,11 +40,10 @@ public function getData(): array { return array_merge([ 'script_executor_id' => $this->scriptId, - 'last_modified' => $this->changes['updated_at'] ?? Carbon::now() + 'last_modified' => $this->changes['updated_at'] ?? Carbon::now(), ], $this->formatChanges($this->changes, $this->original)); } - /** * Return event changes * Return event changes @@ -53,7 +51,7 @@ public function getData(): array public function getChanges(): array { return [ - 'script_executor_id' => $this->scriptId + 'script_executor_id' => $this->scriptId, ]; } diff --git a/ProcessMaker/Events/ScriptUpdated.php b/ProcessMaker/Events/ScriptUpdated.php index 17752df939..35c40bc34d 100644 --- a/ProcessMaker/Events/ScriptUpdated.php +++ b/ProcessMaker/Events/ScriptUpdated.php @@ -47,7 +47,7 @@ public function __construct(Script $script, array $changes, array $original) public function getChanges(): array { return [ - 'script_id' => $this->script->id + 'script_id' => $this->script->id, ]; } diff --git a/ProcessMaker/Events/SettingsUpdated.php b/ProcessMaker/Events/SettingsUpdated.php index e38bde6c30..9a90cb5eed 100644 --- a/ProcessMaker/Events/SettingsUpdated.php +++ b/ProcessMaker/Events/SettingsUpdated.php @@ -46,7 +46,7 @@ public function __construct(Setting $setting, array $changes, array $original) public function getChanges(): array { return [ - 'setting_id' => $this->setting->id + 'setting_id' => $this->setting->id, ]; } diff --git a/ProcessMaker/Events/TemplateCreated.php b/ProcessMaker/Events/TemplateCreated.php index 6d537e3c94..ed7c209493 100644 --- a/ProcessMaker/Events/TemplateCreated.php +++ b/ProcessMaker/Events/TemplateCreated.php @@ -31,7 +31,7 @@ public function getData(): array return [ 'type' => $this->payload['type'] ?? '', 'version' => $this->payload['version'] ?? '', - 'name' => $this->payload['name'] ?? '' + 'name' => $this->payload['name'] ?? '', ]; } @@ -43,7 +43,7 @@ public function getData(): array public function getChanges(): array { return [ - 'root' => $this->payload['root'] ?? '' + 'root' => $this->payload['root'] ?? '', ]; } diff --git a/ProcessMaker/Events/TemplateUpdated.php b/ProcessMaker/Events/TemplateUpdated.php index a1e9b2188f..87c372baf0 100644 --- a/ProcessMaker/Events/TemplateUpdated.php +++ b/ProcessMaker/Events/TemplateUpdated.php @@ -4,8 +4,8 @@ use Carbon\Carbon; use Illuminate\Foundation\Events\Dispatchable; -use ProcessMaker\Helpers\ArrayHelper; use ProcessMaker\Contracts\SecurityLogEventInterface; +use ProcessMaker\Helpers\ArrayHelper; use ProcessMaker\Models\ProcessCategory; use ProcessMaker\Traits\FormatSecurityLogChanges; @@ -50,7 +50,7 @@ public function getData(): array 'name' => [ 'label' => $this->processType, ], - 'last_modified' => $this->changes['updated_at'] ?? Carbon::now() + 'last_modified' => $this->changes['updated_at'] ?? Carbon::now(), ]; } else { $oldData = array_diff_assoc($this->original, $this->changes); @@ -60,7 +60,7 @@ public function getData(): array 'name' => [ 'label' => $this->processType, ], - 'last_modified' => $this->changes['updated_at'] ?? Carbon::now() + 'last_modified' => $this->changes['updated_at'] ?? Carbon::now(), ], ArrayHelper::getArrayDifferencesWithFormat($this->changes, $this->original)); } } diff --git a/ProcessMaker/Events/TokenCreated.php b/ProcessMaker/Events/TokenCreated.php index 4871068437..8f4716b608 100644 --- a/ProcessMaker/Events/TokenCreated.php +++ b/ProcessMaker/Events/TokenCreated.php @@ -24,11 +24,10 @@ public function __construct(Token $token) { $this->data = [ 'token_id' => $token->getKey(), - 'created_at' => Carbon::now() + 'created_at' => Carbon::now(), ]; } - /** * Return event data * Return event data @@ -38,7 +37,6 @@ public function getData(): array return $this->data; } - /** * Return event changes * Return event changes diff --git a/ProcessMaker/Events/TokenDeleted.php b/ProcessMaker/Events/TokenDeleted.php index 03901db1bf..3156587b49 100644 --- a/ProcessMaker/Events/TokenDeleted.php +++ b/ProcessMaker/Events/TokenDeleted.php @@ -22,11 +22,10 @@ class TokenDeleted implements SecurityLogEventInterface public function __construct(Token $token) { $this->data = [ - "token_id" => $token->getKey() + 'token_id' => $token->getKey(), ]; } - /** * Return event data * Return event data @@ -36,7 +35,6 @@ public function getData(): array return $this->data; } - /** * Return event changes * Return event changes diff --git a/ProcessMaker/Events/UserUpdated.php b/ProcessMaker/Events/UserUpdated.php index 26487c757e..ca07f9e67e 100644 --- a/ProcessMaker/Events/UserUpdated.php +++ b/ProcessMaker/Events/UserUpdated.php @@ -14,12 +14,16 @@ class UserUpdated implements SecurityLogEventInterface use FormatSecurityLogChanges; private User $user; + private array $changes; + private array $original; + public const REMOVE_KEYS = [ 'meta', - 'schedule' + 'schedule', ]; + /** * Create a new event instance. * diff --git a/ProcessMaker/Helpers/ArrayHelper.php b/ProcessMaker/Helpers/ArrayHelper.php index 0eb2417eaf..eb82892974 100644 --- a/ProcessMaker/Helpers/ArrayHelper.php +++ b/ProcessMaker/Helpers/ArrayHelper.php @@ -23,7 +23,7 @@ public static function stdClassToArray(stdClass $parameter): array /** * This method compares the keys of two arrays(new Values, old values) and adds (+) and (-) prefix - * to the keys which are different between the arrays with "formatChanges" Trait function. + * to the keys which are different between the arrays with "formatChanges" Trait function. * The method returns an array with different keys values, and new values only with (+) prefix. * @param array $changedArray * @param array $originalArray @@ -35,8 +35,9 @@ public static function getArrayDifferencesWithFormat(array $changedArray, array $displayChanges = array_diff_assoc($changedArray, $originalArray); $displayOriginal = array_diff_assoc($originalArray, $changedArray); - $arrayHelper = new ArrayHelper(); + $arrayHelper = new self(); $arrayDiff = $arrayHelper->formatChanges($displayChanges, $displayOriginal); + return $arrayDiff; } } diff --git a/ProcessMaker/Helpers/SensitiveDataHelper.php b/ProcessMaker/Helpers/SensitiveDataHelper.php index 388993dc4e..6ca8224c99 100644 --- a/ProcessMaker/Helpers/SensitiveDataHelper.php +++ b/ProcessMaker/Helpers/SensitiveDataHelper.php @@ -9,7 +9,7 @@ class SensitiveDataHelper 'idp.client_secret', 'abe_imap_password', 'EMAIL_CONNECTOR_MAIL_PASSWORD', - 'services.ldap.authentication.password' + 'services.ldap.authentication.password', ]; public const MASK = '*'; diff --git a/ProcessMaker/Http/Controllers/Api/CssOverrideController.php b/ProcessMaker/Http/Controllers/Api/CssOverrideController.php index 8bd9e9486d..4a1a984ea4 100644 --- a/ProcessMaker/Http/Controllers/Api/CssOverrideController.php +++ b/ProcessMaker/Http/Controllers/Api/CssOverrideController.php @@ -111,7 +111,7 @@ public function store(Request $request) $altText['changes'] ?? [], $changes ); - + if (!empty($changes)) { $original['config'] = array_merge( $footer['original'] ?? [], @@ -144,7 +144,7 @@ private function setLoginFooter(Request $request) if ((!$setting->wasRecentlyCreated && $setting->wasChanged()) || $setting->wasRecentlyCreated) { $response = [ 'changes' => ['loginFooter' => $setting->getAttribute('config')['html'] ?? ''], - 'original' => ['loginFooter' => $original->getAttribute('config')['html'] ?? ''] + 'original' => ['loginFooter' => $original->getAttribute('config')['html'] ?? ''], ]; } @@ -172,7 +172,7 @@ private function setAltText(Request $request) if ((!$setting->wasRecentlyCreated && $setting->wasChanged()) || $setting->wasRecentlyCreated) { $response = [ 'changes' => ['altText' => $setting->getAttribute('config') ?? ''], - 'original' => ['altText' => $original->getAttribute('config') ?? ''] + 'original' => ['altText' => $original->getAttribute('config') ?? ''], ]; } diff --git a/ProcessMaker/Http/Controllers/Api/ProcessRequestController.php b/ProcessMaker/Http/Controllers/Api/ProcessRequestController.php index 441cb4bb2b..e73150ec2a 100644 --- a/ProcessMaker/Http/Controllers/Api/ProcessRequestController.php +++ b/ProcessMaker/Http/Controllers/Api/ProcessRequestController.php @@ -4,8 +4,8 @@ use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Contracts\Routing\ResponseFactory; -use Illuminate\Database\QueryException; use Illuminate\Database\Eloquent\ModelNotFoundException; +use Illuminate\Database\QueryException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -137,9 +137,9 @@ public function index(Request $request, $getTotal = false, User $user = null) if (!empty($filter)) { $query->filter($filter); } - + $query->nonSystem(); - + $pmql = $request->input('pmql', ''); if (!empty($pmql)) { try { diff --git a/ProcessMaker/Http/Controllers/Api/ScriptExecutorController.php b/ProcessMaker/Http/Controllers/Api/ScriptExecutorController.php index 6a579eca65..4b4a239907 100644 --- a/ProcessMaker/Http/Controllers/Api/ScriptExecutorController.php +++ b/ProcessMaker/Http/Controllers/Api/ScriptExecutorController.php @@ -174,7 +174,7 @@ public function update(Request $request, ScriptExecutor $scriptExecutor) $scriptExecutor->update( $request->only($scriptExecutor->getFillable()) ); - + if (!empty($scriptExecutor->getChanges())) { ScriptExecutorUpdated::dispatch($scriptExecutor->id, $original_values, $scriptExecutor->getChanges()); } diff --git a/ProcessMaker/Http/Controllers/Api/SecurityLogController.php b/ProcessMaker/Http/Controllers/Api/SecurityLogController.php index 918e476763..1a11144400 100644 --- a/ProcessMaker/Http/Controllers/Api/SecurityLogController.php +++ b/ProcessMaker/Http/Controllers/Api/SecurityLogController.php @@ -143,7 +143,7 @@ private function download(Request $request, User $user = null) if (!Media::s3IsReady()) { return response()->json([ 'success' => false, - 'message' => __('Sorry, this feature requires the configured AWS S3 service. Please contact the administrator.') + 'message' => __('Sorry, this feature requires the configured AWS S3 service. Please contact the administrator.'), ]); } $request->validate([ @@ -157,7 +157,7 @@ private function download(Request $request, User $user = null) return response()->json([ 'success' => true, - 'message' => __('The file is processing... Please wait for an alert with the download link.') + 'message' => __('The file is processing... Please wait for an alert with the download link.'), ]); } diff --git a/ProcessMaker/Jobs/DownloadSecurityLog.php b/ProcessMaker/Jobs/DownloadSecurityLog.php index 9d9a56ea9c..0a7a742b46 100644 --- a/ProcessMaker/Jobs/DownloadSecurityLog.php +++ b/ProcessMaker/Jobs/DownloadSecurityLog.php @@ -33,8 +33,11 @@ class DownloadSecurityLog implements ShouldQueue private ?int $userId; public const CSV_SEPARATOR = ','; + public const EXPIRATION_HOURS = 24; + public const FORMAT_CSV = 'csv'; + public const FORMAT_XML = 'xml'; /** @@ -60,6 +63,7 @@ public function handle() // Check if the S3 is ready to use if (!Media::s3IsReady()) { event(new SecurityLogDownloadFailed($this->user, false, __('Sorry, this feature requires the configured AWS S3 service. Please contact the administrator.'))); + return; } try { @@ -69,7 +73,7 @@ public function handle() $expires = $this->getExpires(); // Export the file and get the URL $url = $this->export($filename, $expires); - $message = __('Click on the link and download the file. This link will be available until '. $expires->toString()); + $message = __('Click on the link and download the file. This link will be available until ' . $expires->toString()); // Call the event event(new SecurityLogDownloadJobCompleted($this->user, true, $message, $url)); } catch (Exception $e) { @@ -97,7 +101,7 @@ protected function createTemporaryFilename() { $uuid = Uuid::uuid4()->toString() . Str::random(8); - return 'security-logs/' . $uuid . '.' . $this->format; + return 'security-logs/' . $uuid . '.' . $this->format; } /** @@ -125,7 +129,7 @@ protected function export(string $filename, Carbon $expires) // Save the stream to S3 $disk->put($filename, stream_get_contents($stream), [ 'ACL' => 'private', // private|public-read, - 'Expires' => $expires->toString() + 'Expires' => $expires->toString(), ]); // Close the stream @@ -212,7 +216,7 @@ protected function toXML($stream, array $record) * * @return void */ - protected function initialTagsXML($write = false, $stream) + protected function initialTagsXML($write, $stream) { if ($write) { $contentXml = '' . PHP_EOL; @@ -229,7 +233,7 @@ protected function initialTagsXML($write = false, $stream) * * @return void */ - protected function endTagsXML($write = false, $stream) + protected function endTagsXML($write, $stream) { if ($write) { $contentXml = PHP_EOL . ''; diff --git a/ProcessMaker/Models/EnvironmentVariable.php b/ProcessMaker/Models/EnvironmentVariable.php index 07efd060bf..9a5d78aab3 100644 --- a/ProcessMaker/Models/EnvironmentVariable.php +++ b/ProcessMaker/Models/EnvironmentVariable.php @@ -57,8 +57,9 @@ public function getValueAttribute() try { return decrypt($this->attributes['value']); } catch (\Exception $e) { - Log::error('EnvironmentVariable: ' . $this->attributes['value']. "\n" . $e->getMessage()); + Log::error('EnvironmentVariable: ' . $this->attributes['value'] . "\n" . $e->getMessage()); Log::error($e->getTraceAsString()); + return null; } } diff --git a/ProcessMaker/Models/ProcessCategory.php b/ProcessMaker/Models/ProcessCategory.php index e0d45fbd29..693b407b0b 100644 --- a/ProcessMaker/Models/ProcessCategory.php +++ b/ProcessMaker/Models/ProcessCategory.php @@ -79,8 +79,9 @@ public static function getNamesByIds(string $ids, string $delimiter = ','): stri { $resultString = ''; $arrayIds = explode($delimiter, $ids); - $results = ProcessCategory::whereIn('id', array_map('intval', $arrayIds))->pluck('name'); + $results = self::whereIn('id', array_map('intval', $arrayIds))->pluck('name'); $resultString = implode(', ', $results->toArray()); + return $resultString; } } diff --git a/ProcessMaker/Models/ScreenCategory.php b/ProcessMaker/Models/ScreenCategory.php index 39f7eb5623..9c8221944c 100644 --- a/ProcessMaker/Models/ScreenCategory.php +++ b/ProcessMaker/Models/ScreenCategory.php @@ -78,8 +78,9 @@ public static function getNamesByIds(string $ids, string $delimiter = ','): stri { $resultString = ''; $arrayIds = explode($delimiter, $ids); - $results = ScreenCategory::whereIn('id', array_map('intval', $arrayIds))->pluck('name'); + $results = self::whereIn('id', array_map('intval', $arrayIds))->pluck('name'); $resultString = implode(', ', $results->toArray()); + return $resultString; } } diff --git a/ProcessMaker/Models/ScriptCategory.php b/ProcessMaker/Models/ScriptCategory.php index 1e2954bab2..d043f4c784 100644 --- a/ProcessMaker/Models/ScriptCategory.php +++ b/ProcessMaker/Models/ScriptCategory.php @@ -78,8 +78,9 @@ public static function getNamesByIds(string $ids, string $delimiter = ','): stri { $resultString = ''; $arrayIds = explode($delimiter, $ids); - $results = ScriptCategory::whereIn('id', array_map('intval', $arrayIds))->pluck('name'); + $results = self::whereIn('id', array_map('intval', $arrayIds))->pluck('name'); $resultString = implode(', ', $results->toArray()); + return $resultString; } } diff --git a/ProcessMaker/Providers/EventServiceProvider.php b/ProcessMaker/Providers/EventServiceProvider.php index 24d422041f..2dd06248da 100644 --- a/ProcessMaker/Providers/EventServiceProvider.php +++ b/ProcessMaker/Providers/EventServiceProvider.php @@ -11,9 +11,9 @@ use ProcessMaker\Events\CategoryDeleted; use ProcessMaker\Events\CategoryUpdated; use ProcessMaker\Events\CustomizeUiUpdated; -use ProcessMaker\Events\EnvironmentVariablesUpdated; use ProcessMaker\Events\EnvironmentVariablesCreated; use ProcessMaker\Events\EnvironmentVariablesDeleted; +use ProcessMaker\Events\EnvironmentVariablesUpdated; use ProcessMaker\Events\FilesAccessed; use ProcessMaker\Events\FilesCreated; use ProcessMaker\Events\FilesDeleted; diff --git a/ProcessMaker/Repositories/ExecutionInstanceRepository.php b/ProcessMaker/Repositories/ExecutionInstanceRepository.php index 281d8d21f3..a22a9b6825 100644 --- a/ProcessMaker/Repositories/ExecutionInstanceRepository.php +++ b/ProcessMaker/Repositories/ExecutionInstanceRepository.php @@ -20,6 +20,7 @@ class ExecutionInstanceRepository implements ExecutionInstanceRepositoryInterfac use RepositoryTrait; private bool $abortIfInstanceNotFound = true; + private bool $loadTokens = true; /** diff --git a/ProcessMaker/Repositories/TokenRepository.php b/ProcessMaker/Repositories/TokenRepository.php index a839075a91..6854107740 100644 --- a/ProcessMaker/Repositories/TokenRepository.php +++ b/ProcessMaker/Repositories/TokenRepository.php @@ -63,6 +63,7 @@ public function loadTokenByUid($uid): ? TokenInterface if (is_numeric($uid)) { return Token::find($uid); } + return Token::where('uuid', $uid)->first(); } diff --git a/ProcessMaker/SanitizeHelper.php b/ProcessMaker/SanitizeHelper.php index 52ad22c02d..625d5f019d 100644 --- a/ProcessMaker/SanitizeHelper.php +++ b/ProcessMaker/SanitizeHelper.php @@ -197,7 +197,7 @@ private static function getRichTextElements($items, $parent = null) $elements = array_merge($elements, self::getRichTextElements($item['items'], ($parent ? $parent . '.' . $item['config']['name'] : $item['config']['name']))); } elseif (isset($item['component']) && $item['component'] === 'FormTextArea' && isset($item['config']['richtext']) && $item['config']['richtext'] === true) { $elements[] = ($parent ? $parent . '.' . $item['config']['name'] : $item['config']['name']); - // Inside a table .. + // Inside a table .. } elseif ($item['component'] == 'FormMultiColumn') { foreach ($item['items'] as $cell) { if ( diff --git a/ProcessMaker/Traits/ProcessMapTrait.php b/ProcessMaker/Traits/ProcessMapTrait.php index 52d9eec4f5..baac236a67 100644 --- a/ProcessMaker/Traits/ProcessMapTrait.php +++ b/ProcessMaker/Traits/ProcessMapTrait.php @@ -77,7 +77,7 @@ private function getCompletedSequenceFlow(SimpleXMLElement $xml, string $complet { $inProgressAndCompletedNodes = $completedNodesStr . ' ' . $inProgressNodesStr; $query = '//bpmn:sequenceFlow[contains("' . $completedNodesStr . '", @sourceRef) and contains("' . $inProgressAndCompletedNodes . '", @targetRef)]/@id'; - $query = $query. ' | //bpmn:sequenceFlow[contains("' . $completedInProgressNode . '", @sourceRef) and contains("' . $inProgressAndCompletedNodes . '", @targetRef)]/@id'; + $query = $query . ' | //bpmn:sequenceFlow[contains("' . $completedInProgressNode . '", @sourceRef) and contains("' . $inProgressAndCompletedNodes . '", @targetRef)]/@id'; return $this->filterXML($xml, $query); } @@ -98,10 +98,11 @@ private function getRefNodes(SimpleXMLElement $xml, string $sequenceFlowId): Col 'sourceRef' => (string) $sequenceFlowNode[0]['sourceRef'], ]); } + /** * Validates if the sourceRef token is in progress when the repeat count is the same as the targetRef */ - private function getCountFlag(int $sourceCount, int $targetCount,string $sourceRef, ProcessRequest $request) :bool + private function getCountFlag(int $sourceCount, int $targetCount, string $sourceRef, ProcessRequest $request) :bool { $maxToken = $request->tokens()->find($this->getMaxTokenId($request, $sourceRef)); diff --git a/config/rabbitmq.php b/config/rabbitmq.php index 5ead5f127a..be2fc6cc6f 100644 --- a/config/rabbitmq.php +++ b/config/rabbitmq.php @@ -2,7 +2,7 @@ $_port = env('RABBITMQ_PORT', 5672); if (preg_match('/\d+$/', $_port, $_match)) { - $_port = intval($_match[0]) ?: 5672; + $_port = intval($_match[0]) ?: 5672; } return [ diff --git a/tests/Feature/Api/ProcessRequestsTest.php b/tests/Feature/Api/ProcessRequestsTest.php index 9b90c66732..e7da6b023e 100644 --- a/tests/Feature/Api/ProcessRequestsTest.php +++ b/tests/Feature/Api/ProcessRequestsTest.php @@ -833,7 +833,6 @@ public function testGetProcessRequestListAndPermissions() $this->assertEquals(20, $response->json()['meta']['total']); } - public function testGetRequestToken() { $expectedResponse = [ @@ -865,7 +864,7 @@ public function testGetRequestToken() $token = ProcessRequestToken::factory()->create([ 'process_request_id' => $request->id, 'user_id' => $this->user, - ]); + ]); // Validate the status is correct $response = $this->apiCall('GET', self::API_TEST_URL . '/' . $request->id . '/tokens?element_id=' . $token->element_id); @@ -878,20 +877,19 @@ public function testGetRequestToken() $nonExistentElementId = 999; $response = $this->apiCall('GET', self::API_TEST_URL . '/' . $request->id . '/tokens?element_id=' . $nonExistentElementId); - $response->assertStatus(404); + $response->assertStatus(404); // Verify with other user without permissions $this->user = $otherUser; $response = $this->apiCall('GET', self::API_TEST_URL . '/' . $request->id . '/tokens?element_id=' . $token->element_id); $response->assertStatus(403); - + $this->user->giveDirectPermission('view-all_requests'); $this->user->refresh(); // Verify with other user with permissions $response = $this->apiCall('GET', self::API_TEST_URL . '/' . $request->id . '/tokens?element_id=' . $token->element_id); $response->assertStatus(200); - } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 7709701d2a..b1e1cdef86 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -22,6 +22,7 @@ abstract class TestCase extends BaseTestCase use ArraySubsetAsserts; public $withPermissions = false; + protected $skipTeardownPDOException = false; /** diff --git a/tests/unit/ProcessMaker/Helpers/ArrayHelperTest.php b/tests/unit/ProcessMaker/Helpers/ArrayHelperTest.php index 5db0b2fcb1..e0a9ce0880 100644 --- a/tests/unit/ProcessMaker/Helpers/ArrayHelperTest.php +++ b/tests/unit/ProcessMaker/Helpers/ArrayHelperTest.php @@ -16,7 +16,7 @@ public function testStdClassToArray() $this->assertEquals( [ 'name' => 'John', - 'id' => 5 + 'id' => 5, ], ArrayHelper::stdClassToArray($myObject) ); @@ -29,45 +29,45 @@ public function testGetArrayDifferencesWithFormat() '+ name' => 'Maria', '- name' => 'Laura', '+ email' => 'maria@mail.com', - '- email' => 'laura@mail.com' + '- email' => 'laura@mail.com', ], ArrayHelper::getArrayDifferencesWithFormat( [ 'name' => 'Maria', - 'email' => 'maria@mail.com' + 'email' => 'maria@mail.com', ], [ 'name' => 'Laura', - 'email' => 'laura@mail.com' + 'email' => 'laura@mail.com', ] )); //Case 2: Two arrays with same keys and only one value different $this->assertEquals([ '+ email' => 'maria@mail.com', - '- email' => 'laura@mail.com' + '- email' => 'laura@mail.com', ], ArrayHelper::getArrayDifferencesWithFormat( [ 'name' => 'Maria', - 'email' => 'maria@mail.com' + 'email' => 'maria@mail.com', ], [ 'name' => 'Maria', - 'email' => 'laura@mail.com' + 'email' => 'laura@mail.com', ] )); //Case 3: One array has more keys than second array $this->assertEquals([ - '+ phone' => '123456' + '+ phone' => '123456', ], ArrayHelper::getArrayDifferencesWithFormat( [ 'name' => 'Maria', 'email' => 'maria@mail.com', - 'phone' => '123456' + 'phone' => '123456', ], [ 'name' => 'Maria', - 'email' => 'maria@mail.com' + 'email' => 'maria@mail.com', ] )); } diff --git a/tests/unit/ProcessMaker/Models/ProcessCategoryTest.php b/tests/unit/ProcessMaker/Models/ProcessCategoryTest.php index 607e18a17c..5acd283463 100644 --- a/tests/unit/ProcessMaker/Models/ProcessCategoryTest.php +++ b/tests/unit/ProcessMaker/Models/ProcessCategoryTest.php @@ -35,14 +35,14 @@ public function testGetNamesByIds() //Case 3: without Id $stringIds = ''; $this->assertEquals( - "", + '', ProcessCategory::getNamesByIds($stringIds) ); //Case 4: non-existentId $stringIds = '9452'; $this->assertEquals( - "", + '', ProcessCategory::getNamesByIds($stringIds) ); } diff --git a/tests/unit/ProcessMaker/Models/ScreenCategoryTest.php b/tests/unit/ProcessMaker/Models/ScreenCategoryTest.php index e07689c7da..12e53da49c 100644 --- a/tests/unit/ProcessMaker/Models/ScreenCategoryTest.php +++ b/tests/unit/ProcessMaker/Models/ScreenCategoryTest.php @@ -35,14 +35,14 @@ public function testGetNamesByIds() //Case 3: without Id $stringIds = ''; $this->assertEquals( - "", + '', ScreenCategory::getNamesByIds($stringIds) ); //Case 4: non-existentId $stringIds = '9452'; $this->assertEquals( - "", + '', ScreenCategory::getNamesByIds($stringIds) ); } diff --git a/tests/unit/ProcessMaker/Models/ScriptCategoryTest.php b/tests/unit/ProcessMaker/Models/ScriptCategoryTest.php index b69b336445..cda9da5170 100644 --- a/tests/unit/ProcessMaker/Models/ScriptCategoryTest.php +++ b/tests/unit/ProcessMaker/Models/ScriptCategoryTest.php @@ -35,14 +35,14 @@ public function testGetNamesByIds() //Case 3: without Id $stringIds = ''; $this->assertEquals( - "", + '', ScriptCategory::getNamesByIds($stringIds) ); //Case 4: non-existentId $stringIds = '9452'; $this->assertEquals( - "", + '', ScriptCategory::getNamesByIds($stringIds) ); } From 78dce5201b1f328cc50e6dfee0c722351fb0f43f Mon Sep 17 00:00:00 2001 From: Sanja Date: Fri, 14 Jul 2023 10:09:43 -0700 Subject: [PATCH 6/7] Fix default icon rendering in CreatePmBlockModal --- resources/js/components/pm-blocks/CreatePmBlockModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/components/pm-blocks/CreatePmBlockModal.vue b/resources/js/components/pm-blocks/CreatePmBlockModal.vue index 0610b85d75..537695422d 100644 --- a/resources/js/components/pm-blocks/CreatePmBlockModal.vue +++ b/resources/js/components/pm-blocks/CreatePmBlockModal.vue @@ -53,7 +53,7 @@ :description="formDescription('Choose an icon for this PM Block.', 'icon', errors)" > Date: Fri, 14 Jul 2023 10:25:27 -0700 Subject: [PATCH 7/7] Update incrementString to support arrays --- ProcessMaker/ImportExport/Exporters/ExporterBase.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ProcessMaker/ImportExport/Exporters/ExporterBase.php b/ProcessMaker/ImportExport/Exporters/ExporterBase.php index 084e34154f..128ee2b5bf 100644 --- a/ProcessMaker/ImportExport/Exporters/ExporterBase.php +++ b/ProcessMaker/ImportExport/Exporters/ExporterBase.php @@ -426,7 +426,8 @@ public function handleDuplicateAttributes() : array $seperator = $this->incrementStringSeparator[$index]; $handlers[$attr] = fn ($name) => $this->incrementString($name, $seperator); } else { - $handlers[$attr] = fn ($name) => $this->incrementString($name, $this->incrementStringSeparator); + $seperator = $this->incrementStringSeparator; + $handlers[$attr] = fn ($name) => $this->incrementString($name, $seperator); } }