From b02dccfad414ffd080b609601fec4b82efd08993 Mon Sep 17 00:00:00 2001 From: Amir Meshkin Date: Mon, 8 Jan 2024 15:30:14 -0500 Subject: [PATCH 1/3] FOIA-453: New field field_webform_submission_website in foia_request stores true false depending on hard coded production API key. --- ...play.foia_request.foia_request.default.yml | 8 +++++++ ...play.foia_request.foia_request.default.yml | 11 ++++++++++ ...quest.field_webform_submission_website.yml | 22 +++++++++++++++++++ ...quest.field_webform_submission_website.yml | 22 +++++++++++++++++++ .../FoiaSubmissionQueueHandler.php | 1 + 5 files changed, 64 insertions(+) create mode 100644 config/default/field.field.foia_request.foia_request.field_webform_submission_website.yml create mode 100644 config/default/field.storage.foia_request.field_webform_submission_website.yml diff --git a/config/default/core.entity_form_display.foia_request.foia_request.default.yml b/config/default/core.entity_form_display.foia_request.foia_request.default.yml index 708bad24a..78cad98b9 100644 --- a/config/default/core.entity_form_display.foia_request.foia_request.default.yml +++ b/config/default/core.entity_form_display.foia_request.foia_request.default.yml @@ -14,6 +14,7 @@ dependencies: - field.field.foia_request.foia_request.field_submission_time - field.field.foia_request.foia_request.field_tracking_number - field.field.foia_request.foia_request.field_webform_submission_id + - field.field.foia_request.foia_request.field_webform_submission_website module: - foia_request _core: @@ -106,6 +107,13 @@ content: settings: placeholder: '' third_party_settings: { } + field_webform_submission_website: + type: boolean_checkbox + weight: 16 + region: content + settings: + display_label: true + third_party_settings: { } request_status: type: options_select weight: -1 diff --git a/config/default/core.entity_view_display.foia_request.foia_request.default.yml b/config/default/core.entity_view_display.foia_request.foia_request.default.yml index 690f4d368..4bb6adde3 100644 --- a/config/default/core.entity_view_display.foia_request.foia_request.default.yml +++ b/config/default/core.entity_view_display.foia_request.foia_request.default.yml @@ -14,6 +14,7 @@ dependencies: - field.field.foia_request.foia_request.field_submission_time - field.field.foia_request.foia_request.field_tracking_number - field.field.foia_request.foia_request.field_webform_submission_id + - field.field.foia_request.foia_request.field_webform_submission_website module: - foia_request - options @@ -123,6 +124,16 @@ content: third_party_settings: { } weight: 10 region: content + field_webform_submission_website: + type: boolean + label: above + settings: + format: default + format_custom_false: '' + format_custom_true: '' + third_party_settings: { } + weight: 13 + region: content request_status: type: list_default label: inline diff --git a/config/default/field.field.foia_request.foia_request.field_webform_submission_website.yml b/config/default/field.field.foia_request.foia_request.field_webform_submission_website.yml new file mode 100644 index 000000000..09ec010e2 --- /dev/null +++ b/config/default/field.field.foia_request.foia_request.field_webform_submission_website.yml @@ -0,0 +1,22 @@ +uuid: 87e9b2c7-77fc-4f35-9590-92b844584b72 +langcode: en +status: true +dependencies: + config: + - field.storage.foia_request.field_webform_submission_website + module: + - foia_request +id: foia_request.foia_request.field_webform_submission_website +field_name: field_webform_submission_website +entity_type: foia_request +bundle: foia_request +label: 'Submitted from Website' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + on_label: 'Yes' + off_label: 'No' +field_type: boolean diff --git a/config/default/field.storage.foia_request.field_webform_submission_website.yml b/config/default/field.storage.foia_request.field_webform_submission_website.yml new file mode 100644 index 000000000..dcfb16d16 --- /dev/null +++ b/config/default/field.storage.foia_request.field_webform_submission_website.yml @@ -0,0 +1,22 @@ +uuid: 5e6f7949-4d28-4284-a78b-69ed9a60abda +langcode: en +status: true +dependencies: + module: + - field_permissions + - foia_request +third_party_settings: + field_permissions: + permission_type: public +id: foia_request.field_webform_submission_website +field_name: field_webform_submission_website +entity_type: foia_request +type: boolean +settings: { } +module: core +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php b/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php index 486157790..316a8ac0e 100644 --- a/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php +++ b/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php @@ -69,6 +69,7 @@ protected function getComponentAssociatedToWebform(WebformSubmissionInterface $w protected function createFoiaRequest(WebformSubmissionInterface $webformSubmission, NodeInterface $agencyComponent) { $foiaRequest = FoiaRequest::create([ 'field_webform_submission_id' => $webformSubmission->id(), + 'field_webform_submission_website' => isset($_SERVER["HTTP_X_API_KEY"]) && $_SERVER["HTTP_X_API_KEY"] === 'mUPoczW5VDRQOvroK6srQIjEGc5xBP0KDHgE34fv' ? TRUE : FALSE, 'field_agency_component' => [ 'target_id' => $agencyComponent->id(), ], From 366f1cbb5925ab21ecc92fe7bcea720229774883 Mon Sep 17 00:00:00 2001 From: Amir Meshkin Date: Tue, 23 Jan 2024 14:11:11 -0500 Subject: [PATCH 2/3] FOIA-453: Updating code to check against HTTP_X_API_USER_ID which will be stored in secrets file. --- .../src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php b/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php index 316a8ac0e..5a9836449 100644 --- a/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php +++ b/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php @@ -69,7 +69,7 @@ protected function getComponentAssociatedToWebform(WebformSubmissionInterface $w protected function createFoiaRequest(WebformSubmissionInterface $webformSubmission, NodeInterface $agencyComponent) { $foiaRequest = FoiaRequest::create([ 'field_webform_submission_id' => $webformSubmission->id(), - 'field_webform_submission_website' => isset($_SERVER["HTTP_X_API_KEY"]) && $_SERVER["HTTP_X_API_KEY"] === 'mUPoczW5VDRQOvroK6srQIjEGc5xBP0KDHgE34fv' ? TRUE : FALSE, + 'field_webform_submission_website' => isset($_SERVER["HTTP_X_API_USER_ID"]) && $_SERVER["HTTP_X_API_USER_ID"] === \Drupal::config('api.prod')->get('user_id') ? TRUE : FALSE, 'field_agency_component' => [ 'target_id' => $agencyComponent->id(), ], From 670d193afa0eebd3beb2846c392b4860abfcabcf Mon Sep 17 00:00:00 2001 From: Amir Meshkin Date: Tue, 23 Jan 2024 14:29:17 -0500 Subject: [PATCH 3/3] FOIA-453: Changing name of config var to foia.secrets api_user_id. --- .../src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php b/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php index 5a9836449..7cc4d4529 100644 --- a/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php +++ b/docroot/modules/custom/foia_webform/src/Plugin/WebformHandler/FoiaSubmissionQueueHandler.php @@ -69,7 +69,7 @@ protected function getComponentAssociatedToWebform(WebformSubmissionInterface $w protected function createFoiaRequest(WebformSubmissionInterface $webformSubmission, NodeInterface $agencyComponent) { $foiaRequest = FoiaRequest::create([ 'field_webform_submission_id' => $webformSubmission->id(), - 'field_webform_submission_website' => isset($_SERVER["HTTP_X_API_USER_ID"]) && $_SERVER["HTTP_X_API_USER_ID"] === \Drupal::config('api.prod')->get('user_id') ? TRUE : FALSE, + 'field_webform_submission_website' => isset($_SERVER["HTTP_X_API_USER_ID"]) && $_SERVER["HTTP_X_API_USER_ID"] === \Drupal::config('foia.secrets')->get('api_user_id') ? TRUE : FALSE, 'field_agency_component' => [ 'target_id' => $agencyComponent->id(), ],