From 6bfd391a0df967782aab761124a3ded8fe303d12 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 16 Apr 2024 00:09:11 +0200 Subject: [PATCH] [FEATURE] Add `FrontendUser.termsAcknowledged` (#538) --- CHANGELOG.md | 1 + Classes/Domain/Model/FrontendUser.php | 15 +++++++++++++++ Configuration/TCA/Overrides/fe_users.php | 9 ++++++++- Resources/Private/Language/locallang.xlf | 3 +++ .../Fixtures/UserWithAllScalarData.csv | 4 ++-- .../Repository/FrontendUserRepositoryTest.php | 1 + Tests/Unit/Domain/Model/FrontendUserTest.php | 18 ++++++++++++++++++ ext_tables.sql | 1 + 8 files changed, 49 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae0cd1b..5cd3c9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## x.y.z ### Added +- Add a checkbox for "terms acknowledged" (#538) ### Changed diff --git a/Classes/Domain/Model/FrontendUser.php b/Classes/Domain/Model/FrontendUser.php index 1b2123e..ea79db1 100644 --- a/Classes/Domain/Model/FrontendUser.php +++ b/Classes/Domain/Model/FrontendUser.php @@ -200,6 +200,11 @@ class FrontendUser extends AbstractEntity */ protected bool $privacy = false; + /** + * the "terms and conditions" have been acknowledged + */ + protected bool $termsAcknowledged = false; + protected ?\DateTime $dateOfBirth = null; /** @@ -466,6 +471,16 @@ public function setPrivacy(bool $privacy): void $this->privacy = $privacy; } + public function hasTermsAcknowledged(): bool + { + return $this->termsAcknowledged; + } + + public function setTermsAcknowledged(bool $termsAcknowledged): void + { + $this->termsAcknowledged = $termsAcknowledged; + } + public function getFullSalutation(): string { return $this->fullSalutation; diff --git a/Configuration/TCA/Overrides/fe_users.php b/Configuration/TCA/Overrides/fe_users.php index c19e8fb..241f4f9 100644 --- a/Configuration/TCA/Overrides/fe_users.php +++ b/Configuration/TCA/Overrides/fe_users.php @@ -89,6 +89,13 @@ 'type' => 'check', ], ], + 'terms_acknowledged' => [ + 'exclude' => true, + 'label' => $languageFile . 'terms_acknowledged', + 'config' => [ + 'type' => 'check', + ], + ], 'status' => [ 'label' => $languageFile . 'status', 'config' => [ @@ -236,6 +243,6 @@ ); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes( 'fe_users', - 'privacy, comments' + 'privacy, terms_acknowledged, comments' ); }); diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 64a6916..bdeb9f1 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -30,6 +30,9 @@ Privacy agreement + + Terms acknowledged + Job status diff --git a/Tests/Functional/Domain/Repository/Fixtures/UserWithAllScalarData.csv b/Tests/Functional/Domain/Repository/Fixtures/UserWithAllScalarData.csv index f38a50b..f70d2f3 100644 --- a/Tests/Functional/Domain/Repository/Fixtures/UserWithAllScalarData.csv +++ b/Tests/Functional/Domain/Repository/Fixtures/UserWithAllScalarData.csv @@ -1,3 +1,3 @@ "fe_users" -,"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","full_salutation","gender","date_of_birth","status","comments" -,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,"Welcome, Max MM!",2,1648857600,2,"Here we go!" +,"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" +,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!" diff --git a/Tests/Functional/Domain/Repository/FrontendUserRepositoryTest.php b/Tests/Functional/Domain/Repository/FrontendUserRepositoryTest.php index 5a2f789..40f300b 100644 --- a/Tests/Functional/Domain/Repository/FrontendUserRepositoryTest.php +++ b/Tests/Functional/Domain/Repository/FrontendUserRepositoryTest.php @@ -72,6 +72,7 @@ public function findByUidForExistingRecordReturnsModelWithAllScalarData(): void self::assertSame('Cat Scans Inc.', $model->getCompany()); self::assertEquals(new \DateTime('2022-04-02T18:00'), $model->getLastLogin()); self::assertTrue($model->getPrivacy()); + self::assertTrue($model->hasTermsAcknowledged()); self::assertSame('NRW', $model->getZone()); self::assertSame('Welcome, Max MM!', $model->getFullSalutation()); self::assertSame(FrontendUser::GENDER_DIVERSE, $model->getGender()); diff --git a/Tests/Unit/Domain/Model/FrontendUserTest.php b/Tests/Unit/Domain/Model/FrontendUserTest.php index 195426a..6d14f3b 100644 --- a/Tests/Unit/Domain/Model/FrontendUserTest.php +++ b/Tests/Unit/Domain/Model/FrontendUserTest.php @@ -669,6 +669,24 @@ public function setPrivacySetsPrivacy(): void self::assertTrue($this->subject->getPrivacy()); } + /** + * @test + */ + public function hasTermsAcknowledgedInitiallyReturnsFalse(): void + { + self::assertFalse($this->subject->hasTermsAcknowledged()); + } + + /** + * @test + */ + public function setTermsAcknowledgedSetsTermsAcknowledged(): void + { + $this->subject->setTermsAcknowledged(true); + + self::assertTrue($this->subject->hasTermsAcknowledged()); + } + /** * @test */ diff --git a/ext_tables.sql b/ext_tables.sql index ebab6c1..3599568 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -7,6 +7,7 @@ CREATE TABLE fe_users ( date_of_birth int(11) DEFAULT '0' NOT NULL, zone varchar(45) DEFAULT '' NOT NULL, privacy tinyint(4) unsigned DEFAULT '0' NOT NULL, + terms_acknowledged tinyint(1) unsigned DEFAULT '0' NOT NULL, status int(11) unsigned DEFAULT '0' NOT NULL, comments text );