Skip to content

Commit 7ace383

Browse files
committed
Merge branch 'release/3.22.1'
2 parents b5cd850 + 5d84f58 commit 7ace383

File tree

5 files changed

+46
-22
lines changed

5 files changed

+46
-22
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ before starting to add changes. Use example [placed in the end of the page](#exa
1111

1212
## [Unreleased]
1313

14+
## [3.22.1] 2025-02-10
15+
16+
- Updated `os2forms_fbs_handler` to include and correct set phone number [#161](https://github.com/OS2Forms/os2forms/pull/161)
17+
1418
## [3.22.0] 2025-02-03
1519

1620
- Removed modules ldap_auth, logging_alerts, maillog [#151](https://github.com/OS2Forms/os2forms/pull/151)
@@ -338,7 +342,9 @@ before starting to add changes. Use example [placed in the end of the page](#exa
338342
- Security in case of vulnerabilities.
339343
```
340344

341-
[Unreleased]: https://github.com/OS2Forms/os2forms/compare/3.21.2...HEAD
345+
[Unreleased]: https://github.com/OS2Forms/os2forms/compare/3.22.1...HEAD
346+
[3.22.1]: https://github.com/OS2Forms/os2forms/compare/3.22.0...3.22.1
347+
[3.22.0]: https://github.com/OS2Forms/os2forms/compare/3.21.2...3.22.0
342348
[3.21.2]: https://github.com/OS2Forms/os2forms/compare/3.21.1...3.21.2
343349
[3.21.1]: https://github.com/OS2Forms/os2forms/compare/3.21.0...3.21.1
344350
[3.21.0]: https://github.com/OS2Forms/os2forms/compare/3.20.1...3.21.0

modules/os2forms_fbs_handler/src/Client/FBS.php renamed to modules/os2forms_fbs_handler/src/Client/Fbs.php

+13-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Minimalistic client to create user with guardians at FBS.
1313
*/
14-
class FBS {
14+
class Fbs {
1515

1616
/**
1717
* FBS session key.
@@ -118,8 +118,14 @@ public function createPatronWithGuardian(Patron $patron, Guardian $guardian) {
118118
'pincode' => $patron->pincode,
119119
'preferredPickupBranch' => $patron->preferredPickupBranch,
120120
'name' => 'Unknown Name',
121-
'emailAddresses' => $patron->emailAddresses,
121+
'emailAddresses' => $patron->emailAddresses ?? [],
122122
'guardian' => $guardian->toArray(),
123+
'phoneNumbers' => $patron->phoneNumber ? [
124+
[
125+
'receiveNotification' => TRUE,
126+
'phoneNumber' => $patron->phoneNumber,
127+
],
128+
] : [],
123129
];
124130

125131
return $this->request($uri, $payload);
@@ -148,12 +154,13 @@ public function getPatron(string $patronId): ?Patron {
148154
(bool) $json->patron->receiveSms,
149155
(bool) $json->patron->receivePostalMail,
150156
$json->patron->notificationProtocols,
151-
$json->patron->phoneNumber,
152157
is_null($json->patron->onHold) ? $json->patron->onHold : (array) $json->patron->onHold,
153158
$json->patron->preferredLanguage,
154159
(bool) $json->patron->guardianVisibility,
155160
$json->patron->defaultInterestPeriod,
156161
(bool) $json->patron->resident,
162+
$json->patron->phoneNumber,
163+
157164
[
158165
[
159166
'emailAddress' => $json->patron->emailAddress,
@@ -185,15 +192,15 @@ public function updatePatron(Patron $patron): bool {
185192
$payload = [
186193
'patron' => [
187194
'preferredPickupBranch' => $patron->preferredPickupBranch,
188-
'emailAddresses' => $patron->emailAddresses,
195+
'emailAddresses' => $patron->emailAddresses ?? [],
189196
'guardianVisibility' => $patron->guardianVisibility,
190197
'receivePostalMail' => $patron->receiveEmail,
191-
'phoneNumbers' => [
198+
'phoneNumbers' => $patron->phoneNumber ? [
192199
[
193200
'receiveNotification' => TRUE,
194201
'phoneNumber' => $patron->phoneNumber,
195202
],
196-
],
203+
] : [],
197204
],
198205
'pincodeChange' => [
199206
'pincode' => $patron->pincode,

modules/os2forms_fbs_handler/src/Client/Model/Patron.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public function __construct(
1919
public readonly ?bool $receiveSms = FALSE,
2020
public readonly ?bool $receivePostalMail = FALSE,
2121
public readonly ?array $notificationProtocols = NULL,
22-
public readonly ?string $phoneNumber = NULL,
2322
public readonly ?array $onHold = NULL,
2423
public readonly ?string $preferredLanguage = NULL,
2524
public readonly ?bool $guardianVisibility = NULL,
2625
public readonly ?int $defaultInterestPeriod = NULL,
2726
public readonly ?bool $resident = NULL,
2827
// Allow these properties below to be updatable.
28+
public ?string $phoneNumber = NULL,
2929
public ?array $emailAddresses = NULL,
3030
public ?bool $receiveEmail = NULL,
3131
public ?string $preferredPickupBranch = NULL,

modules/os2forms_fbs_handler/src/Plugin/AdvancedQueue/JobType/FbsCreateUser.php

+24-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Drupal\advancedqueue\Job;
99
use Drupal\advancedqueue\JobResult;
1010
use Drupal\advancedqueue\Plugin\AdvancedQueue\JobType\JobTypeBase;
11-
use Drupal\os2forms_fbs_handler\Client\FBS;
11+
use Drupal\os2forms_fbs_handler\Client\Fbs;
1212
use Drupal\os2forms_fbs_handler\Client\Model\Guardian;
1313
use Drupal\os2forms_fbs_handler\Client\Model\Patron;
1414
use Drupal\os2web_audit\Service\Logger;
@@ -84,7 +84,7 @@ public function process(Job $job): JobResult {
8484
$config = $payload['configuration'];
8585

8686
try {
87-
$fbs = new FBS($this->client, $config['endpoint_url'], $config['agency_id'], $config['username'], $config['password']);
87+
$fbs = new Fbs($this->client, $config['endpoint_url'], $config['agency_id'], $config['username'], $config['password']);
8888

8989
// Log into FBS and obtain session.
9090
$fbs->login();
@@ -110,12 +110,17 @@ public function process(Job $job): JobResult {
110110
if (!is_null($patron)) {
111111
// Create Patron object with updated values.
112112
$patron->preferredPickupBranch = $data['afhentningssted'];
113-
$patron->emailAddresses = [
114-
[
115-
'emailAddress' => $data['barn_mail'],
116-
'receiveNotification' => TRUE,
117-
],
118-
];
113+
if (!empty($data['barn_mail'])) {
114+
$patron->emailAddresses = [
115+
[
116+
'emailAddress' => $data['barn_mail'],
117+
'receiveNotification' => TRUE,
118+
],
119+
];
120+
}
121+
if (!empty($data['barn_tlf'])) {
122+
$patron->phoneNumber = $data['barn_tlf'];
123+
}
119124
$patron->receiveEmail = TRUE;
120125
$patron->pincode = $data['pinkode'];
121126

@@ -127,15 +132,20 @@ public function process(Job $job): JobResult {
127132
// If "no" create child patron and guardian.
128133
$patron = new Patron();
129134
$patron->preferredPickupBranch = $data['afhentningssted'];
130-
$patron->emailAddresses = [
131-
[
132-
'emailAddress' => $data['barn_mail'],
133-
'receiveNotification' => TRUE,
134-
],
135-
];
135+
if (!empty($data['barn_mail'])) {
136+
$patron->emailAddresses = [
137+
[
138+
'emailAddress' => $data['barn_mail'],
139+
'receiveNotification' => TRUE,
140+
],
141+
];
142+
}
136143
$patron->receiveEmail = TRUE;
137144
$patron->personId = $data['barn_cpr'];
138145
$patron->pincode = $data['pinkode'];
146+
if (!empty($data['barn_tlf'])) {
147+
$patron->phoneNumber = $data['barn_tlf'];
148+
}
139149

140150
$fbs->createPatronWithGuardian($patron, $guardian);
141151
}

modules/os2forms_fbs_handler/src/Plugin/WebformHandler/FbsWebformHandler.php

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ public function postSave(WebformSubmissionInterface $webform_submission, $update
183183
'afhentningssted',
184184
'barn_cpr',
185185
'barn_mail',
186+
'barn_tlf',
186187
'cpr',
187188
'email',
188189
'navn',

0 commit comments

Comments
 (0)