Skip to content

Commit

Permalink
[FEATURE] Add FrontendUser.termsAcknowledged (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverklee authored Apr 15, 2024
1 parent 3958fde commit 6bfd391
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions Classes/Domain/Model/FrontendUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion Configuration/TCA/Overrides/fe_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
'type' => 'check',
],
],
'terms_acknowledged' => [
'exclude' => true,
'label' => $languageFile . 'terms_acknowledged',
'config' => [
'type' => 'check',
],
],
'status' => [
'label' => $languageFile . 'status',
'config' => [
Expand Down Expand Up @@ -236,6 +243,6 @@
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'fe_users',
'privacy, comments'
'privacy, terms_acknowledged, comments'
);
});
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<trans-unit id="privacy" resname="privacy" approved="yes">
<source>Privacy agreement</source>
</trans-unit>
<trans-unit id="terms_acknowledged" resname="comments" approved="yes">
<source>Terms acknowledged</source>
</trans-unit>
<trans-unit id="status" resname="status" approved="yes">
<source>Job status</source>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
@@ -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","[email protected]","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","[email protected]","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!"
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
18 changes: 18 additions & 0 deletions Tests/Unit/Domain/Model/FrontendUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
1 change: 1 addition & 0 deletions ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

0 comments on commit 6bfd391

Please sign in to comment.