Skip to content

Commit faad126

Browse files
committed
Merge branch 'develop'
* develop: Preparing 3.12.0 OS-60 updating changelog OS-60 disabling webform_embed Anonymized default PDF template Cleaned up Made link text translatable Moved dependency to proper location Cleaned up comments `private readonly` Cleaned up class constants Added Advanced Queue module Fixed inherit from options os2forms_permissions_by_term: removing node access control Made digital post module optional Handled anonymous users in notifications and flow tasks # Conflicts: # CHANGELOG.md
2 parents ee64b99 + 85ad4d2 commit faad126

25 files changed

+1875
-591
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ before starting to add changes. Use example [placed in the end of the page](#exa
1111

1212
## [Unreleased]
1313

14+
## [3.12.0] 2023-10-02
15+
16+
- Removing webform_embed
17+
- os2forms_permissions_by_term: removing node access control
18+
1419
## [3.11.0] 2023-09-25
1520

1621
- [OS-58] New company address fields
1722
- Custom permissions by term field
1823
- Removing dependency to config_entity_revisions, webform_revisions, coc_forms_auto_export
24+
- [PR-56](https://github.com/OS2Forms/os2forms/pull/56)
25+
Handled anonymous users in notifications and flow tasks
1926

2027
## [3.10.0] 2023-08-23
2128

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"cweagans/composer-patches": "^1.6.5",
2020
"dompdf/dompdf": "^2.0",
2121
"drupal/admin_toolbar": "^3.0",
22+
"drupal/advancedqueue": "^1.0",
2223
"drupal/chosen": "^2.10",
2324
"drupal/ckeditor_a11ychecker": "^2.0@alpha",
2425
"drupal/clientside_validation": "^3.0",
@@ -39,7 +40,7 @@
3940
"drupal/libraries": "^3.0@beta",
4041
"drupal/linkit": "^5.0",
4142
"drupal/logging_alerts": "^2.0",
42-
"drupal/maestro": "^3.0",
43+
"drupal/maestro": "^3.1",
4344
"drupal/mailsystem": "^4.1",
4445
"drupal/masquerade": "^2.0@RC",
4546
"drupal/pathauto": "^1.5",
@@ -74,6 +75,9 @@
7475
"webmozart/path-util": "^2.3",
7576
"zaporylie/composer-drupal-optimizations": "^1.2"
7677
},
78+
"suggest": {
79+
"os2forms/os2forms_digital_post": "Send Maestro notifications via digital post (see https://github.com/itk-dev/os2forms_digital_post/blob/main/README.md)"
80+
},
7781
"require-dev": {
7882
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
7983
"drupal/coder": "^8.3",

modules/os2forms_forloeb/CHANGELOG.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ All notable changes to this project should be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
See ["how do I make a good changelog record?"](https://keepachangelog.com/en/1.0.0/#how)
7+
See ["how do I make a good changelog record?"](https://keepachangelog.com/en/1.0.0/#how)
88
before starting to add changes.
99

1010
## [Unreleased]
1111

12+
- Implemented `hook_maestro_zero_user_notification` and added *Maestro
13+
notification* handler for sending notifications via email or digital post.
14+
- Cleaned up prefilling of forms in `MaestroWebformInheritTask`.
15+
1216
## 2.5.2 - 27.03.2023
1317

1418
### Updated
15-
- Bumped drupal/ultimate_cron version fixing [Deprecated function: Implicit conversion from float-string](https://www.drupal.org/project/ultimate_cron/issues/3256142).
19+
- Bumped drupal/ultimate_cron version fixing [Deprecated function: Implicit conversion from float-string](https://www.drupal.org/project/ultimate_cron/issues/3256142).
1620

1721
## 2.5.1 - 10.03.2023
1822
- Added github action for checking changelog changes when creating pull requests
@@ -24,11 +28,11 @@ before starting to add changes.
2428

2529
## 2.5.0 - 11.10.2022
2630

27-
### Added
31+
### Added
2832
- retry task controller action
2933
- Added support for inheriting values without creating a submission
3034

31-
## 2.4.0
35+
## 2.4.0
3236

3337
### Added
3438
- Github CI action for checking Drupal Coding standards with PHP Code Sniffer

modules/os2forms_forloeb/README.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,56 @@
11
# OS2forms 2.1 med Forløb [![Build Status](https://app.travis-ci.com/OS2Forms/os2forms_forloeb.svg?branch=develop)](https://app.travis-ci.com/OS2Forms/os2forms_forloeb)
2+
23
Adds a Maestro workflow engine and advanced workflow functionality to OS2forms.
34

45
## Installing OS2forms 2.1 med Forløb
6+
57
This module requires the codebase from the [OS2forms core project](https://github.com/OS2Forms/os2forms8) installed per the documentation and by selecting the os2forms_forloeb_profile at installation. After succesful installation you should have the OS2forms med Forløb Module available for install via gui.
68

79
You can also install the module by using Drush:
8-
```
9-
./vendor/bin/drush en os2forms_forloeb
10-
```
10+
11+
```
12+
./vendor/bin/drush pm:enable os2forms_forloeb
13+
```
14+
15+
-------------------------------------------------------------------------------
16+
17+
## Maestro notifications
18+
19+
Maestro 3.1 adds a `hook_webform_submission_form_alter` hook which we utilize to
20+
send assignment, reminder and escalation notifications by adding a *Maestro
21+
notification* handler to a form that spawns a Maestro workflow or assigns a
22+
task. If the notification recipient is identified by an an email address, the
23+
notification is sent as an email, and if the identifier is a Danish CPR number,
24+
the notifications is sent as digital post.
25+
26+
See [Opret flow-notifikationer](https://os2forms.os2.eu/node/457) (in Danish)
27+
for details.
28+
29+
### Settings
30+
31+
Settings for OS2Forms forløb are defined on `/admin/config/system/os2forms_forloeb`.
32+
33+
#### Known anonymous roles
34+
35+
In order to make the notifications work, Maestro workflow tasks must be assigned
36+
to a *known anonymous role* and these roles are defined under *Known anonymous
37+
roles*.
38+
39+
#### Processing
40+
41+
A notification is not sent to a user immediately, but added to a queue which
42+
must be processed asynchronously. Specify the queue handling notification jobs.
43+
44+
#### Templates
45+
46+
Define templates for emails and digital post (PDF).
47+
48+
### Note on digital post
49+
50+
Digital post is sent using the API provided by the [OS2Forms Digital Post
51+
module](https://github.com/itk-dev/os2forms_digital_post)
52+
(`os2forms_digital_post`) which in turn uses [SF1600: Print på
53+
serviceplatformen](https://digitaliseringskataloget.dk/integration/sf1600). Not
54+
all OS2Forms projects use `os2forms_digital_post` and in the future we should
55+
generalize the API for sending digital post to allow other implementations (not
56+
based on [SF1600](https://digitaliseringskataloget.dk/integration/sf1600)).

modules/os2forms_forloeb/os2forms_forloeb.info.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ name: 'OS2forms med Forløb Module'
22
description: 'Adds a Maestro workflow engine and advanced workflow functionality to OS2forms.'
33
package: OS2Forms
44
type: module
5-
core: 8.x
6-
core_version_requirement: ^8 || ^9
5+
core_version_requirement: ^9 || ^10
6+
7+
configure: os2forms_forloeb.settings
78

89
dependencies:
910
- 'drupal:admin_toolbar_tools'
11+
- 'drupal:advancedqueue'
1012
- 'drupal:diff'
1113
- 'drupal:entity_print'
1214
- 'drupal:eu_cookie_compliance'
@@ -18,35 +20,37 @@ dependencies:
1820
- 'drupal:mailsystem'
1921
- 'drupal:masquerade'
2022
- 'drupal:os2forms'
21-
- 'drupal:os2forms_nemid'
2223
- 'drupal:os2forms_dawa'
24+
- 'drupal:os2forms_nemid'
2325
- 'drupal:os2forms_sbsys'
2426
- 'drupal:os2web_simplesaml'
2527
- 'drupal:pathauto'
2628
- 'drupal:r4032login'
2729
- 'drupal:redirect'
2830
- 'drupal:smtp'
29-
- 'drupal:system'
3031
- 'drupal:switch_page_theme'
32+
- 'drupal:system'
3133
- 'drupal:token'
3234
- 'drupal:ultimate_cron'
3335
- 'drupal:webform'
34-
- 'drupal:webform_ui'
3536
- 'drupal:webform_access'
3637
- 'drupal:webform_attachment'
3738
- 'drupal:webform_composite'
38-
- 'drupal:webform_embed'
3939
- 'drupal:webform_entity_print'
4040
- 'drupal:webform_entity_print_attachment'
4141
- 'drupal:webform_migrate'
4242
- 'drupal:webform_node_element'
4343
- 'drupal:webform_remote_handlers'
4444
- 'drupal:webform_rest'
45-
- 'drupal:webform_share'
4645
- 'drupal:webform_scheduled_email'
46+
- 'drupal:webform_share'
4747
- 'drupal:webform_submission_export_import'
4848
- 'drupal:webform_submission_log'
4949
- 'drupal:webform_templates'
50+
- 'drupal:webform_ui'
5051
- 'drupal:workflow_participants'
52+
# os2forms_digital_post may be used for sending Meastro notifications via digital post
53+
# - 'os2forms_digital_post:os2forms_digital_post'
54+
5155
'interface translation project': os2forms_forloeb
5256
'interface translation server pattern': modules/contrib/os2forms_forloeb/translations/os2forms_forloeb.da.po
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
os2forms_forloeb.settings:
2+
title: OS2Forms forløb
3+
description: Configure the OS2Forms forløb module
4+
parent: system.admin_config_system
5+
route_name: os2forms_forloeb.settings

modules/os2forms_forloeb/os2forms_forloeb.module

Lines changed: 71 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@
55
* Install, update and uninstall functions for the os2forms_forloeb.
66
*/
77

8-
use Drupal\Core\Access\AccessResult;
9-
use Drupal\Core\Entity\EntityInterface;
108
use Drupal\Core\Form\FormStateInterface;
11-
use Drupal\Core\Render\BubbleableMetadata;
12-
use Drupal\Core\Session\AccountInterface;
13-
use Drupal\Core\Url;
149
use Drupal\maestro\Engine\MaestroEngine;
10+
use Drupal\os2forms_forloeb\MaestroHelper;
1511
use Drupal\os2forms_forloeb\Plugin\EngineTasks\MaestroWebformInheritTask;
1612
use Drupal\user\Entity\User;
1713
use Drupal\webform\Entity\WebformSubmission;
1814
use Drupal\webform\WebformInterface;
19-
use Drupal\webform\WebformSubmissionInterface;
2015

2116
/**
2217
* Implements hook_maestro_interactive_handlers().
@@ -289,66 +284,93 @@ function os2forms_forloeb_preprocess_page(&$variables) {
289284
}
290285

291286
/**
292-
* Implements hook_token_info_alter().
287+
* Implements hook_webform_submission_form_alter().
293288
*/
294-
function os2forms_forloeb_token_info_alter(&$data) {
295-
$data['tokens']['webform_submission']['os2forms_forloeb_execute_task'] = [
296-
'name' => t('Execute task path for webform submission'),
297-
'description' => t("The token that can be user to get path for webform submission redirect URL."),
298-
'type' => 'webform_submission',
299-
];
289+
function os2forms_forloeb_webform_submission_form_alter(array &$form, FormStateInterface $formState, string $formId) {
290+
MaestroWebformInheritTask::webformSubmissionFormAlter($form, $formState, $formId);
291+
}
292+
293+
/**
294+
* Implements hook_maestro_zero_user_notification().
295+
*/
296+
function os2forms_forloeb_maestro_zero_user_notification($templateMachineName, $taskMachineName, $queueID, $notificationType) {
297+
_os2forms_forloeb_helper()->maestroZeroUserNotification($templateMachineName, $taskMachineName, $queueID, $notificationType);
300298
}
301299

302300
/**
303-
* Implements hook_tokens().
301+
* Implements hook_maestro_can_user_execute_task_alter().
304302
*
305-
* Provides token value for webform_submission:os2forms_forloeb_execute_task.
303+
* For OS2Forms, you may have a consistent assignment to an "anonymous" user via
304+
* a role. Use the QueueID and userID to drill into the task and alter the
305+
* returnValue to TRUE if this is a user that should be looking at this task.
306+
*
307+
* You can make this as complex as you'd like it to be, checking things like
308+
* sessions, login tokens, email addresses etc.
306309
*/
307-
function os2forms_forloeb_tokens($type, array $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
308-
$replacements = [];
309-
310-
if ($type === 'webform_submission' && !empty($data['webform_submission']) && isset($tokens['os2forms_forloeb_execute_task'])) {
311-
$replacements[$tokens['os2forms_forloeb_execute_task']] = Url::fromRoute(
312-
'os2forms_forloeb.forloeb_task_console_controller_execute',
313-
['os2forms-forloeb-ws-token' => $data['webform_submission']->getToken()],
314-
['absolute' => TRUE]
315-
)->toString(TRUE)->getGeneratedUrl();
316-
}
310+
function os2forms_forloeb_maestro_can_user_execute_task_alter(&$returnValue, $queueID, $userID) {
311+
_os2forms_forloeb_helper()->maestroCanUserExecuteTaskAlter($returnValue, $queueID, $userID);
312+
}
317313

318-
return $replacements;
314+
/**
315+
* Implements hook_mail().
316+
*/
317+
function os2forms_forloeb_mail($key, &$message, $params) {
318+
_os2forms_forloeb_helper()->mail($key, $message, $params);
319319
}
320320

321321
/**
322-
* Implements hook_entity_access().
323-
*
324-
* Allows requests with tokens to view the entity.
322+
* Implements hook_mail_alter().
325323
*/
326-
function os2forms_forloeb_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
327-
if ($operation == 'update' && $entity instanceof WebformSubmission) {
328-
$token = \Drupal::request()->query->get('os2forms-forloeb-ws-token');
329-
if ($token && $token === $entity->getToken()) {
330-
return AccessResult::allowed();
331-
}
332-
}
333-
return AccessResult::neutral();
324+
function os2forms_forloeb_mail_alter(&$message) {
325+
_os2forms_forloeb_helper()->mailAlter($message);
334326
}
335327

336328
/**
337-
* Implements hook_maestro_post_fetch_assigned_queue_tasks().
329+
* Implements hook_theme().
338330
*/
339-
function os2forms_forloeb_maestro_post_fetch_assigned_queue_tasks($userID, &$queueIDs) {
340-
$token = \Drupal::request()->query->get('os2forms-forloeb-ws-token', '');
341-
if ($token) {
342-
$forloebTaskConsole = Drupal::service('os2forms_forloeb.task_console');
343-
$queueRecord = $forloebTaskConsole->getQueueIdByWebformSubmissionToken($token);
344-
$queueIDs[] = $queueRecord->id();
345-
$queueIDs = array_unique($queueIDs);
346-
}
331+
function os2forms_forloeb_theme(array &$variables) {
332+
$theme['os2forms_forloeb_notification_preview'] = [
333+
'variables' => [
334+
'webform' => NULL,
335+
'handler' => NULL,
336+
'notification_type' => NULL,
337+
'subject' => NULL,
338+
'recipient' => NULL,
339+
'content_type' => NULL,
340+
'submission' => NULL,
341+
'return_url' => NULL,
342+
'render_url' => NULL,
343+
'preview_urls' => [
344+
'prev' => NULL,
345+
'self' => NULL,
346+
'next' => NULL,
347+
],
348+
],
349+
];
350+
351+
$theme['os2forms_forloeb_notification_message_email_html'] = [
352+
'variables' => [
353+
'message' => [
354+
'content' => [
355+
'value' => NULL,
356+
'format' => NULL,
357+
],
358+
],
359+
'task_url' => NULL,
360+
'action_label' => NULL,
361+
'webform_submission' => NULL,
362+
'handler' => NULL,
363+
],
364+
];
365+
366+
$theme['os2forms_forloeb_notification_message_pdf_html'] = $theme['os2forms_forloeb_notification_message_email_html'];
367+
368+
return $theme;
347369
}
348370

349371
/**
350-
* Implements hook_ENTITY_TYPE_prepare_form().
372+
* Get MaestroHelper.
351373
*/
352-
function os2forms_forloeb_webform_submission_prepare_form(WebformSubmissionInterface $webform_submission, string $operation, FormStateInterface $form_state) {
353-
MaestroWebformInheritTask::webformSubmissionPrepareForm($webform_submission, $operation, $form_state);
374+
function _os2forms_forloeb_helper(): MaestroHelper {
375+
return Drupal::service(MaestroHelper::class);
354376
}

0 commit comments

Comments
 (0)