Skip to content

Commit 390cbfd

Browse files
authored
[FEATURE] Add FrontendUser.privacyDateOfAcceptance (#622)
Fixes #615
1 parent ae28783 commit 390cbfd

8 files changed

Lines changed: 57 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
66
## x.y.z
77

88
### Added
9+
- Add `FrontendUser.privacyDateOfAcceptance` (#622)
910
- Add `FrontendUser.termsDateOfAcceptance` (#620)
1011

1112
### Changed

Classes/Domain/Model/FrontendUser.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ class FrontendUser extends AbstractEntity
200200
*/
201201
protected bool $privacy = false;
202202

203+
protected ?\DateTime $privacyDateOfAcceptance = null;
204+
203205
/**
204206
* the "terms and conditions" have been acknowledged
205207
*/
@@ -473,6 +475,16 @@ public function setPrivacy(bool $privacy): void
473475
$this->privacy = $privacy;
474476
}
475477

478+
public function getPrivacyDateOfAcceptance(): ?\DateTime
479+
{
480+
return $this->privacyDateOfAcceptance;
481+
}
482+
483+
public function setPrivacyDateOfAcceptance(?\DateTime $date): void
484+
{
485+
$this->privacyDateOfAcceptance = $date;
486+
}
487+
476488
public function hasTermsAcknowledged(): bool
477489
{
478490
return $this->termsAcknowledged;

Configuration/TCA/Overrides/fe_users.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@
9595
'type' => 'check',
9696
],
9797
],
98+
'privacy_date_of_acceptance' => [
99+
'exclude' => true,
100+
'label' => $languageFile . 'privacyDateOfAcceptance',
101+
'config' => [
102+
'type' => 'input',
103+
'renderType' => 'datetime',
104+
'format' => 'datetime',
105+
'eval' => 'datetime,int',
106+
'readOnly' => true,
107+
],
108+
],
98109
'terms_acknowledged' => [
99110
'exclude' => true,
100111
'label' => $languageFile . 'terms_acknowledged',
@@ -205,6 +216,12 @@
205216
],
206217
],
207218
],
219+
'privacy_date_of_acceptance' => [
220+
'config' => [
221+
'renderType' => 'inputDateTime',
222+
'eval' => 'datetime,int',
223+
],
224+
],
208225
'terms_date_of_acceptance' => [
209226
'config' => [
210227
'renderType' => 'inputDateTime',
@@ -266,6 +283,6 @@
266283
);
267284
ExtensionManagementUtility::addToAllTCAtypes(
268285
'fe_users',
269-
'privacy, terms_acknowledged, terms_date_of_acceptance, comments'
286+
'privacy, privacy_date_of_acceptance, terms_acknowledged, terms_date_of_acceptance, comments'
270287
);
271288
});

Resources/Private/Language/locallang.xlf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
<trans-unit id="privacy" resname="privacy">
3737
<source>Privacy agreement</source>
3838
</trans-unit>
39+
<trans-unit id="privacyDateOfAcceptance" resname="privacyDateOfAcceptance">
40+
<source>Privacy agreement acknowledged at</source>
41+
</trans-unit>
3942
<trans-unit id="terms_acknowledged" resname="terms_acknowledged">
4043
<source>Terms acknowledged</source>
4144
</trans-unit>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"fe_users"
2-
,"uid","crdate","tstamp","username","password","usergroup","name","first_name","middle_name","last_name","address","telephone","email","title","zip","city","country","www","company","image","lastlogin","zone","privacy","terms_acknowledged","full_salutation","gender","date_of_birth","status","comments","terms_date_of_acceptance"
3-
,1,1546300800,1672531200,"max","luif3ui4t12","","Max M. Minimau","Max","Murri","Minimau","Near the heating 4","+49 1111 1233456-78","max@example.com","Head of fur","01234","Kattingen","United States of CAT","www.example.com","Cat Scans Inc.","",1648922400,"NRW",1,1,"Welcome, Max MM!",2,1648857600,2,"Here we go!",1716000000
2+
,"uid","crdate","tstamp","username","password","usergroup","name","first_name","middle_name","last_name","address","telephone","email","title","zip","city","country","www","company","image","lastlogin","zone","privacy","terms_acknowledged","full_salutation","gender","date_of_birth","status","comments","terms_date_of_acceptance","privacy_date_of_acceptance"
3+
,1,1546300800,1672531200,"max","luif3ui4t12","","Max M. Minimau","Max","Murri","Minimau","Near the heating 4","+49 1111 1233456-78","max@example.com","Head of fur","01234","Kattingen","United States of CAT","www.example.com","Cat Scans Inc.","",1648922400,"NRW",1,1,"Welcome, Max MM!",2,1648857600,2,"Here we go!",1716000000,1713000000

Tests/Functional/Domain/Repository/FrontendUserRepositoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public function findByUidForExistingRecordReturnsModelWithAllScalarData(): void
7272
self::assertSame('Cat Scans Inc.', $model->getCompany());
7373
self::assertEquals(new \DateTime('2022-04-02T18:00'), $model->getLastLogin());
7474
self::assertTrue($model->getPrivacy());
75+
self::assertEquals(new \DateTime('2024-04-13T09:20'), $model->getPrivacyDateOfAcceptance());
7576
self::assertTrue($model->hasTermsAcknowledged());
7677
self::assertEquals(new \DateTime('2024-05-18T02:40'), $model->getTermsDateOfAcceptance());
7778
self::assertSame('NRW', $model->getZone());

Tests/Unit/Domain/Model/FrontendUserTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,25 @@ public function setPrivacySetsPrivacy(): void
671671
self::assertTrue($this->subject->getPrivacy());
672672
}
673673

674+
/**
675+
* @test
676+
*/
677+
public function getPrivacyDateOfAcceptanceInitiallyReturnsNull(): void
678+
{
679+
self::assertNull($this->subject->getPrivacyDateOfAcceptance());
680+
}
681+
682+
/**
683+
* @test
684+
*/
685+
public function setPrivacyDateOfAcceptanceSetsPrivacyDateOfAcceptance(): void
686+
{
687+
$model = new \DateTime();
688+
$this->subject->setPrivacyDateOfAcceptance($model);
689+
690+
self::assertSame($model, $this->subject->getPrivacyDateOfAcceptance());
691+
}
692+
674693
/**
675694
* @test
676695
*/

ext_tables.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CREATE TABLE fe_users (
77
date_of_birth int(11) DEFAULT '0' NOT NULL,
88
zone varchar(45) DEFAULT '' NOT NULL,
99
privacy tinyint(1) unsigned DEFAULT '0' NOT NULL,
10+
privacy_date_of_acceptance int(11) unsigned DEFAULT '0' NOT NULL,
1011
terms_acknowledged tinyint(1) unsigned DEFAULT '0' NOT NULL,
1112
terms_date_of_acceptance int(11) unsigned DEFAULT '0' NOT NULL,
1213
status tinyint(1) unsigned DEFAULT '0' NOT NULL,

0 commit comments

Comments
 (0)