Skip to content
Open
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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ before starting to add changes. Use example [placed in the end of the page](#exa

## [Unreleased]

## Patch release selvbetjening 4.7.0

- [PR-222](https://github.com/OS2Forms/os2forms/pull/222)
- Correctly sets sender label on Maestro digital post notifications.
- [PR-215](https://github.com/OS2Forms/os2forms/pull/215)
- Added condition to maestro notification submission handler
- [PR-192](https://github.com/OS2Forms/os2forms/pull/192)
- Fix bug in MitidChildrenSelectAjaxBehaviour.php
- [PR-187](https://github.com/OS2Forms/os2forms/pull/187)
- Avoid double-saving submissions when handling name and address protection.
- [PR-184](https://github.com/OS2Forms/os2forms/pull/184)
- Patches `coc_forms_auto_export` to ensure settings can be saved upon initial
attempt, cf. [Unable to save initial settings due to unfocusable form control](https://www.drupal.org/project/coc_forms_auto_export/issues/3531004)

## Patch release selvbetjening 4.6.0

- [PR-189](https://github.com/OS2Forms/os2forms/pull/189)
- Added support for MeMo 1.2 and added additional validation of MeMo actions.
- [PR-202](https://github.com/OS2Forms/os2forms/pull/202)
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
"enable-patching": true,
"patches": {
"drupal/coc_forms_auto_export": {
"3256951: - Unable to receive attachments in emails sent": "https://git.drupalcode.org/project/coc_forms_auto_export/-/merge_requests/11.diff"
"3256951: - Unable to receive attachments in emails sent": "https://git.drupalcode.org/project/coc_forms_auto_export/-/merge_requests/11.diff",
"3531004: Unable to save initial settings due to unfocusable form control": "https://www.drupal.org/files/issues/2025-06-19/text_area_with_text_edit_always_fails_reqired_set_via_states.patch"
},
"drupal/entity_print": {
"2733781 - Add Export to Word Support": "https://www.drupal.org/files/issues/2019-11-22/2733781-47.patch"
Expand Down
24 changes: 18 additions & 6 deletions modules/os2forms_forloeb/src/MaestroHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ private function sendNotification(
|| $handler->isDisabled()
|| $handler->isExcluded()
|| !$handler->isNotificationEnabled($notificationType)
|| !$handler->checkConditions($submission)
) {
continue;
}
Expand All @@ -257,13 +258,14 @@ private function sendNotification(
'subject' => $subject,
'taskUrl' => $taskUrl,
'actionLabel' => $actionLabel,
'senderLabel' => $senderLabel,
] = $this->renderNotification($submission, $handler->getHandlerId(), $notificationType, $templateTask, $maestroQueueID);

if ('email' === $contentType) {
$this->sendNotificationEmail($recipient, $subject, $content, $submission, $notificationType);
}
else {
$this->sendNotificationDigitalPost($recipient, $subject, $content, $taskUrl, $actionLabel, $submission, $notificationType);
$this->sendNotificationDigitalPost($recipient, $subject, $content, $taskUrl, $actionLabel, $submission, $notificationType, $senderLabel);
}
}
}
Expand Down Expand Up @@ -313,7 +315,7 @@ private function loadQueue(): QueueInterface {
* @param \Drupal\webform\WebformSubmissionInterface $submission
* The webform submission.
* @param string $notificationType
* The notification type (one of the NOTIFICATION_* constannts).
* The notification type (one of the NOTIFICATION_* constants).
*/
private function sendNotificationEmail(
string $recipient,
Expand Down Expand Up @@ -378,7 +380,9 @@ private function sendNotificationEmail(
* @param \Drupal\webform\WebformSubmissionInterface $submission
* The webform submission.
* @param string $notificationType
* The notification type (one of the NOTIFICATION_* constannts).
* The notification type (one of the NOTIFICATION_* constants).
* @param string $senderLabel
* The sender label.
*/
private function sendNotificationDigitalPost(
string $recipient,
Expand All @@ -388,6 +392,7 @@ private function sendNotificationDigitalPost(
string $actionLabel,
WebformSubmissionInterface $submission,
string $notificationType,
string $senderLabel,
): void {
try {
$document = new Document(
Expand All @@ -396,7 +401,6 @@ private function sendNotificationDigitalPost(
$subject . '.pdf'
);

$senderLabel = $subject;
$messageLabel = $subject;

// Remove all non-digits from recipient identifier.
Expand Down Expand Up @@ -449,13 +453,13 @@ private function sendNotificationDigitalPost(
* @param string $handlerId
* The handler ID.
* @param string $notificationType
* The notification type (one of the NOTIFICATION_* constannts).
* The notification type (one of the NOTIFICATION_* constants).
* @param array $templateTask
* The Maestro template task.
* @param int $maestroQueueID
* The Maestro queue ID.
* @param string|null $contentType
* Optional content type. If not set the content type will be compoted based
* Optional content type. If not set the content type will be computed based
* on the recipient.
*
* @return array
Expand All @@ -466,13 +470,20 @@ private function sendNotificationDigitalPost(
* - subject
* - taskUrl (for digital post)
* - actionLabel (for digital post)
* - senderLabel (for digital post)
*
* @see self::renderHtml()
*/
public function renderNotification(WebformSubmissionInterface $submission, string $handlerId, string $notificationType, array $templateTask, int $maestroQueueID, ?string $contentType = NULL): array {
$handler = $submission->getWebform()->getHandler($handlerId);
$settings = $handler->getSettings();

$senderLabel = $settings[MaestroNotificationHandler::NOTIFICATION][MaestroNotificationHandler::SENDER_LABEL] ?? NULL;

if (NULL === $senderLabel) {
throw new RuntimeException(sprintf('Cannot get setting for Maestro notification: %s', MaestroNotificationHandler::SENDER_LABEL));
}

$data = $submission->getData();
$recipientElement = $settings[MaestroNotificationHandler::NOTIFICATION][MaestroNotificationHandler::RECIPIENT_ELEMENT] ?? NULL;
// Handle os2forms_person_lookup element.
Expand Down Expand Up @@ -571,6 +582,7 @@ public function renderNotification(WebformSubmissionInterface $submission, strin
'subject' => $subject,
'taskUrl' => $taskUrl,
'actionLabel' => $actionLabel,
'senderLabel' => $senderLabel,
];
}

Expand Down
1 change: 0 additions & 1 deletion modules/os2forms_nemid/os2forms_nemid.module
Original file line number Diff line number Diff line change
Expand Up @@ -469,5 +469,4 @@ function os2forms_nemid_submission_set_address_protected(array $form, FormStateI
$data = $webformSubmission->getData();
$data['os2forms_nemid_elements_nemid_address_protected'] = TRUE;
$webformSubmission->setData($data);
$webformSubmission->save();
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public static function mitidChildrenSelectAjax(array &$form, FormStateInterface
if ($cprPlugin->isReady()) {
$cprLookupResult = $cprPlugin->lookup($childCpr);

if (!$cprLookupResult->isSuccessful()) {
return $response;
}

/** @var \Drupal\webform\WebformSubmissionForm $webformSubmissionForm */
$webformSubmissionForm = $form_state->getFormObject();
/** @var \Drupal\webform\WebformSubmissionInterface $webformSubmission */
Expand Down
13 changes: 11 additions & 2 deletions modules/os2forms_nemid/src/Plugin/WebformElement/NemidAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,18 @@ public function alterForm(array &$element, array &$form, FormStateInterface $for
// Only manipulate element on submission create form.
if (!$webformSubmission->isCompleted()) {
if ($cprLookupResult && $cprLookupResult->isNameAddressProtected()) {
$element['#info_message'] = 'adresse beskyttelse';
NestedArray::setValue($form['elements'], $element['#webform_parents'], $element);
$form['actions']['submit']['#submit'][] = 'os2forms_nemid_submission_set_address_protected';

// It is important the 'os2forms_nemid_submission_set_address_protected'
// submit action is executed before the 'save' action. Otherwise,
// submissions are both created and completed, resulting in unexpected
// behavior, e.g. handlers being run twice.
if (isset($form['actions']['submit']['#submit']) && is_array($form['actions']['submit']['#submit'])) {
array_unshift($form['actions']['submit']['#submit'], 'os2forms_nemid_submission_set_address_protected');
}
else {
$form['actions']['submit']['#submit'][] = 'os2forms_nemid_submission_set_address_protected';
}
}
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface NemidPrepopulateFieldInterface {
/**
* String representation of the prepopulate field key.
*
* Is used to prepopulate the field from the corresponding plugin..
* Is used to prepopulate the field from the corresponding plugin.
*
* @param array $element
* The element to prepopulate value for.
Expand Down
2 changes: 1 addition & 1 deletion modules/os2forms_nemid/src/Service/FormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function retrieveCompanyLookupResult(FormStateInterface $form_state) {
}

/**
* Performs lookup of the company data..
* Performs lookup of the company data.
*
* Uses CVR or P-number based services depending on the available values.
*
Expand Down