From 6e6e99b42de3c043566b851b9f6b288cb4c5496a Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Thu, 6 Mar 2025 10:08:51 +0100 Subject: [PATCH 1/4] Handle elements not present in submission data --- modules/os2web_audit_entity/os2web_audit_entity.module | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/os2web_audit_entity/os2web_audit_entity.module b/modules/os2web_audit_entity/os2web_audit_entity.module index 927bcde..98d533a 100644 --- a/modules/os2web_audit_entity/os2web_audit_entity.module +++ b/modules/os2web_audit_entity/os2web_audit_entity.module @@ -72,6 +72,10 @@ function os2web_audit_entity_webform_post_load_data(mixed $submissions): void { $submissionData = $submission->getData(); if (!empty($filterFields)) { foreach ($filterFields as $field) { + // Not all fields/elements are present within submission data, i.e. markup. + if (!isset($submissionData[$field])) { + continue; + } $cpr = $submissionData[$field]; $personal .= sprintf(' CPR "%s" in field "%s".', $cpr ?: 'null', $field); } From 9f43d3ecbed2492d336b5aa1aa277124748f6682 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Thu, 6 Mar 2025 10:16:14 +0100 Subject: [PATCH 2/4] Updated actions and changelog --- .github/workflows/pr.yml | 6 +++--- CHANGELOG.md | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4762588..899403b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -39,7 +39,7 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -70,7 +70,7 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -102,7 +102,7 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9faa66d..f4535b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.1] - 2025-03-06 + +- Handled webform elements not present in submission data + i.e. markup elements. + ## [1.0.0] - 2025-02-28 - Version 1.0.0. @@ -72,7 +77,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - First version of the module - Added submodule to log user CUD events. -[Unreleased]: https://github.com/OS2web/os2web_audit/compare/1.0.0...HEAD +[Unreleased]: https://github.com/OS2web/os2web_audit/compare/1.0.1...HEAD +[1.0.1]: https://github.com/OS2web/os2web_audit/compare/1.0.0...1.0.1 [1.0.0]: https://github.com/OS2web/os2web_audit/compare/0.2.2...1.0.0 [0.2.2]: https://github.com/OS2web/os2web_audit/compare/0.2.1...0.2.2 [0.2.1]: https://github.com/OS2web/os2web_audit/compare/0.2.0...0.2.1 From bd97c58ca16f3bb9506471719a1c849fecd2c4f4 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Thu, 6 Mar 2025 10:17:52 +0100 Subject: [PATCH 3/4] Fixed coding standards --- modules/os2web_audit_entity/os2web_audit_entity.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/os2web_audit_entity/os2web_audit_entity.module b/modules/os2web_audit_entity/os2web_audit_entity.module index 98d533a..4abe4ba 100644 --- a/modules/os2web_audit_entity/os2web_audit_entity.module +++ b/modules/os2web_audit_entity/os2web_audit_entity.module @@ -72,7 +72,7 @@ function os2web_audit_entity_webform_post_load_data(mixed $submissions): void { $submissionData = $submission->getData(); if (!empty($filterFields)) { foreach ($filterFields as $field) { - // Not all fields/elements are present within submission data, i.e. markup. + // Not all fields are present within submission data, i.e. markup. if (!isset($submissionData[$field])) { continue; } From db875edf49c43afa07cd42064e09a16be68283d2 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Thu, 6 Mar 2025 10:49:14 +0100 Subject: [PATCH 4/4] Handled os2forms_person_lookup element --- CHANGELOG.md | 1 + .../os2web_audit_entity.module | 22 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4535b9..b3a4a9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Handled webform elements not present in submission data i.e. markup elements. +- Handled `os2forms_person_lookup` element. ## [1.0.0] - 2025-02-28 diff --git a/modules/os2web_audit_entity/os2web_audit_entity.module b/modules/os2web_audit_entity/os2web_audit_entity.module index 4abe4ba..1a78540 100644 --- a/modules/os2web_audit_entity/os2web_audit_entity.module +++ b/modules/os2web_audit_entity/os2web_audit_entity.module @@ -64,7 +64,10 @@ function os2web_audit_entity_webform_post_load_data(mixed $submissions): void { $webform = $submission->getWebform(); $elements = $webform->getElementsDecodedAndFlattened(); foreach ($elements as $fieldName => $element) { - if (str_contains(strtolower($element['#type']), 'cpr') || str_contains(strtolower($fieldName), 'cpr')) { + if ( + str_contains(strtolower($element['#type']), 'cpr') + || str_contains(strtolower($element['#type']), 'os2forms_person_lookup') + || str_contains(strtolower($fieldName), 'cpr')) { $filterFields[] = $fieldName; } } @@ -76,7 +79,22 @@ function os2web_audit_entity_webform_post_load_data(mixed $submissions): void { if (!isset($submissionData[$field])) { continue; } - $cpr = $submissionData[$field]; + + $fieldValue = $submissionData[$field]; + + // Handles os2forms_person_lookup (cpr & name validation) element. + if (is_array($fieldValue)) { + // Example: + // [ + // 'cpr_number' => 1234567890, + // 'name' => Eksempel Eksempelsen, + // ]. + $cpr = $fieldValue['cpr_number'] ?? NULL; + } + else { + $cpr = $fieldValue; + } + $personal .= sprintf(' CPR "%s" in field "%s".', $cpr ?: 'null', $field); } }