Skip to content

Commit

Permalink
Merge branch 'develop' into feature/fbs-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuaitk authored May 3, 2024
2 parents 937b86d + e6c37fe commit 63f1954
Show file tree
Hide file tree
Showing 38 changed files with 567 additions and 47 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ before starting to add changes. Use example [placed in the end of the page](#exa

## [Unreleased]

- Added webform encryption modules
- Adding Lat and Long fetching to DataAddress
- CprFetchData adding ajax error fix
- [#84](https://github.com/OS2Forms/os2forms/pull/84)
Added digital post test command.
- Added FBS handler for supporting user creation in library systems
- [#95](https://github.com/OS2Forms/os2forms/pull/95)
- Added `base_url` variable to twig templates.
- Handled tokens in Maestro notification html.
- [#92](https://github.com/OS2Forms/os2forms/pull/92)
Allow denying address protected citizen from webform.
- [#96](https://github.com/OS2Forms/os2forms/pull/96)
NemLogin autologout pop-up styling.
- [#99](https://github.com/OS2Forms/os2forms/pull/99)
Fix coding standards.
- [#102](https://github.com/OS2Forms/os2forms/pull/102)
Fix array access with `purge_days` configuration.

## [3.14.1] 2024-01-16

Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@
"drupal/simple_ldap": "^1.0@alpha",
"drupal/simplesamlphp_auth": "^3.2",
"drupal/smtp": "^1.0@beta",
"drupal/sodium": "^2.4",
"drupal/switch_page_theme": "^4.0",
"drupal/telephone_validation": "^2.2",
"drupal/token": "^1.5",
"drupal/ultimate_cron": "^2.0.0",
"drupal/user_default_page": "^2.1",
"drupal/webform": "^6.1",
"drupal/webform_composite": "^1.0@RC",
"drupal/webform_encrypt": "^2.0@alpha",
"drupal/webform_migrate": "^1.1",
"drupal/webform_node_element": "^1.2",
"drupal/webform_remote_handlers": "^1.6.0",
Expand Down Expand Up @@ -112,6 +114,9 @@
},
"drupal/dynamic_entity_reference": {
"entityQuery reference JOINs should specify target_type (https://www.drupal.org/project/dynamic_entity_reference/issues/3120952#comment-14141038)": "https://www.drupal.org/files/issues/2021-06-22/entityquery-reference-joins-should-specify-target_type-3120952-24.patch"
},
"drupal/webform_encrypt": {
"Ensure data is base64 encoded (https://www.drupal.org/project/webform_encrypt/issues/3399414)": "https://git.drupalcode.org/project/webform_encrypt/-/merge_requests/4.patch"
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions modules/os2forms_attachment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ To add custom headers/footer ```admin/structure/webform/config/os2forms_attachme
To specify headers/footers that will override the default ones on a global level (**Third party settings** -> **Entity print** section): ```admin/structure/webform/config```

To specify headers/footers that will override the default ones on a form level (**Third party settings** -> **Entity print** section): ```/admin/structure/webform/manage/[webform]/settings```

# Overwriting templates

With some setups it might be necessary to overwrite templates
in order to access stylesheets or images.

See [templates](modules/os2forms_forloeb/README.md#templates)
for more details on how to do this.
10 changes: 10 additions & 0 deletions modules/os2forms_attachment/os2forms_attachment.module
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Site\Settings;
use Drupal\os2forms_attachment\Entity\AttachmentComponent;

/**
Expand Down Expand Up @@ -317,3 +318,12 @@ function os2forms_attachment_module_implements_alter(&$implementations, $hook) {
}

}

/**
* Implements hook_preprocess().
*
* Add 'base_url' variable to be used by templates.
*/
function os2forms_attachment_preprocess(&$vars) {
$vars['base_url'] = Settings::get('base_url');
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
private readonly DigitalPostHelper $digitalPostHelper,
private readonly Token $token,
private readonly EntityPrintPluginManagerInterface $entityPrintPluginManager,
private readonly Settings $digitalPostSettings
private readonly Settings $digitalPostSettings,
) {
}

Expand All @@ -53,12 +53,15 @@ public function __construct(
* @command os2forms-digital-post:test:send
* @usage os2forms-digital-post:test:send --help
*/
public function send(array $recipients, array $options = [
'subject' => 'os2forms_digital_post',
'message' => 'This is a test message from os2forms_digital_post sent on [current-date:html_datetime].',
'digital-post-type' => SF1601::TYPE_AUTOMATISK_VALG,
'dump-digital-post-settings' => FALSE,
]): void {
public function send(
array $recipients,
array $options = [
'subject' => 'os2forms_digital_post',
'message' => 'This is a test message from os2forms_digital_post sent on [current-date:html_datetime].',
'digital-post-type' => SF1601::TYPE_AUTOMATISK_VALG,
'dump-digital-post-settings' => FALSE,
],
): void {
$io = new SymfonyStyle($this->input(), $this->output());

if ($options['dump-digital-post-settings']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public function __construct(
private readonly BeskedfordelerHelper $beskedfordelerHelper,
private readonly MessageHelper $messageHelper,
private readonly WebformHelperSF1601 $webformHelper,
LoggerInterface $logger) {
LoggerInterface $logger,
) {
parent::__construct($logger);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/os2forms_digital_post/src/Form/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class SettingsForm extends FormBase {
public function __construct(
private readonly Settings $settings,
private readonly CertificateLocatorHelper $certificateLocatorHelper,
EntityTypeManagerInterface $entityTypeManager
EntityTypeManagerInterface $entityTypeManager,
) {
$this->queueStorage = $entityTypeManager->getStorage('advancedqueue_queue');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class AbstractMessageHelper {
public function __construct(
readonly protected Settings $settings,
readonly protected ElementInfoManager $elementInfoManager,
readonly protected WebformTokenManagerInterface $webformTokenManager
readonly protected WebformTokenManagerInterface $webformTokenManager,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class BeskedfordelerHelper {
public function __construct(
private readonly Connection $database,
private readonly MeMoHelper $meMoHelper,
LoggerInterface $logger) {
LoggerInterface $logger,
) {
$this->setLogger($logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CertificateLocatorHelper {
* {@inheritdoc}
*/
public function __construct(
private readonly Settings $settings
private readonly Settings $settings,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
private readonly ForsendelseHelper $forsendelseHelper,
private readonly BeskedfordelerHelper $beskedfordelerHelper,
private readonly LoggerChannelInterface $logger,
private readonly LoggerChannelInterface $submissionLogger
private readonly LoggerChannelInterface $submissionLogger,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(
private readonly BeskedfordelerHelper $beskedfordelerHelper,
private readonly LoggerChannelInterface $logger,
private readonly LoggerChannelInterface $submissionLogger,
private readonly DigitalPostHelper $digitalPostHelper
private readonly DigitalPostHelper $digitalPostHelper,
) {
$this->webformSubmissionStorage = $entityTypeManager->getStorage('webform_submission');
$this->queueStorage = $entityTypeManager->getStorage('advancedqueue_queue');
Expand Down
2 changes: 1 addition & 1 deletion modules/os2forms_digital_post/src/Model/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(
readonly public string $content,
readonly public string $mimeType,
readonly public string $filename,
readonly public string $language = self::LANGUAGE_DEFAULT
readonly public string $language = self::LANGUAGE_DEFAULT,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
WebformHelperSF1601 $helper
WebformHelperSF1601 $helper,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->helper = $helper;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
uuid: 98e9a380-a5d6-4d2a-9176-7c50a9ec7c47
langcode: en
status: true
dependencies:
config:
- key.key.webform
module:
- sodium
id: webform
label: Webform
encryption_method: sodium
encryption_method_configuration: { }
encryption_key: webform
17 changes: 17 additions & 0 deletions modules/os2forms_encrypt/config/install/key.key.webform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
uuid: be3383e8-1b0e-4b50-989f-e132900d02a0
langcode: en
status: true
dependencies: { }
id: webform
label: Webform
description: 'Encrypt webform submissions'
key_type: encryption
key_type_settings:
key_size: 256
key_provider: config
key_provider_settings:
key_value: LWD5+0klWZn48ZVs13UVHaHJYawX62PAMd3sklkKj/w=
base64_encoded: true
key_input: text_field
key_input_settings:
base64_encoded: true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enabled: 0
6 changes: 6 additions & 0 deletions modules/os2forms_encrypt/drush.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
os2forms_encrypt.commands:
class: Drupal\os2forms_encrypt\Commands\Os2FormsEncryptCommands
arguments: ['@entity_type.manager', '@config.factory']
tags:
- { name: drush.command }
11 changes: 11 additions & 0 deletions modules/os2forms_encrypt/os2forms_encrypt.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: OS2Forms Encrypt
description: Encryption functionality for OS2Forms web-forms
package: OS2Forms
type: module
version: 1.0.0
core_version_requirement: ^8 || ^9 || ^10
dependencies:
- 'drupal:webform_encrypt'
- 'drupal:sodium'

configure: os2forms_encrypt.admin_settings
5 changes: 5 additions & 0 deletions modules/os2forms_encrypt/os2forms_encrypt.links.menu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
os2forms_encrypt.admin_settings:
title: 'OS2Forms Encrypt settings'
parent: system.admin_config_system
description: 'Settings for the OS2Forms Encrypt module'
route_name: os2forms_encrypt.admin_settings
23 changes: 23 additions & 0 deletions modules/os2forms_encrypt/os2forms_encrypt.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* @file
* This module enabled webform submission encryption as a default option.
*/

/**
* Implements hook_webform_element_info_alter().
*
* Add extra processing function to "force" enabled encryption on webform
* elements when they are being saved in the UI.
*/
function os2forms_encrypt_element_info_alter(array &$definitions): void {
foreach ($definitions as $element_id => &$definition) {
if ($element_id === 'webform_element_encrypt') {
$definition['#process'][] = [
'Drupal\os2forms_encrypt\Element\WebformElementEncrypt',
'processWebformElementEncrypt',
];
}
}
}
7 changes: 7 additions & 0 deletions modules/os2forms_encrypt/os2forms_encrypt.routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
os2forms_encrypt.admin_settings:
path: '/admin/config/os2forms_encrypt/settings'
defaults:
_form: '\Drupal\os2forms_encrypt\Form\SettingsForm'
_title: 'OS2Forms Encrypt settings'
requirements:
_permission: 'administer encrypt'
90 changes: 90 additions & 0 deletions modules/os2forms_encrypt/src/Commands/Os2FormsEncryptCommands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

namespace Drupal\os2forms_encrypt\Commands;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\os2forms_encrypt\Form\SettingsForm;
use Drush\Commands\DrushCommands;

/**
* A Drush command file.
*
* @package Drupal\os2forms_encrypt\Commands
*/
class Os2FormsEncryptCommands extends DrushCommands {

/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected EntityTypeManagerInterface $entityTypeManager;

/**
* Factory to get module configuration.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected ConfigFactoryInterface $configFactory;

/**
* Class constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* An instance of the entity type manager.
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* An instance of the config factory.
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager, ConfigFactoryInterface $configFactory) {
$this->entityTypeManager = $entityTypeManager;
$this->configFactory = $configFactory;
parent::__construct();
}

/**
* Enable encrypt for all existing webform elements.
*
* @command os2forms-encrypt:enable
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function enabledEncrypt(): void {
$config = $this->configFactory->get(SettingsForm::$configName);
if (!$config->get('enabled')) {
$this->output()->writeln('Encrypt has not been enabled.');
return;
}

// Get the storage for Webform entity type.
$webformStorage = $this->entityTypeManager->getStorage('webform');

// Load all webform entities.
$webforms = $webformStorage->loadMultiple();

/** @var \Drupal\webform\Entity\Webform $webform */
foreach ($webforms as $webform) {
$elements = $webform->getElementsDecoded();
$config = $webform->getThirdPartySettings('webform_encrypt');

$changed = FALSE;
foreach ($elements as $key => $element) {
if (!isset($config['element'][$key])) {
$config['element'][$key] = [
'encrypt' => TRUE,
'encrypt_profile' => 'webform',
];
$changed = TRUE;
}
}

// Save the webform entity so the changes persist, if any changes where
// made.
if ($changed) {
$webform->setThirdPartySetting('webform_encrypt', 'element', $config['element']);
$webform->save();
}
}
}

}
Loading

0 comments on commit 63f1954

Please sign in to comment.