From 973048243fbc55da2eb547eea6ee2216cf84a7fd Mon Sep 17 00:00:00 2001 From: Daniel Huf <1814195+dhuf@users.noreply.github.com> Date: Tue, 19 Aug 2025 09:26:44 +0200 Subject: [PATCH 01/11] feat: Update v13 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1b09582..82dfaab 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,6 @@ } }, "require": { - "typo3/cms-core": "^11.5" + "typo3/cms-core": "^13.4" } } From 0d5ae84024bc8f58bd0d72303c29f81a358daff9 Mon Sep 17 00:00:00 2001 From: Daniel Huf Date: Tue, 19 Aug 2025 09:47:24 +0200 Subject: [PATCH 02/11] chore: Run rector --- Classes/Controller/FrontendUserController.php | 138 ++++++++---------- Classes/Domain/Model/FrontendUser.php | 14 +- .../Repository/FrontendUserRepository.php | 2 +- ...olNewsletterregistrationCTypeMigration.php | 41 ++++++ Configuration/TCA/Overrides/fe_users.php | 8 +- Configuration/TCA/Overrides/sys_template.php | 3 + Configuration/TCA/Overrides/tt_content.php | 9 +- ext_localconf.php | 2 +- ext_tables.php | 7 - 9 files changed, 119 insertions(+), 105 deletions(-) create mode 100644 Classes/Updates/VisolNewsletterregistrationCTypeMigration.php create mode 100644 Configuration/TCA/Overrides/sys_template.php diff --git a/Classes/Controller/FrontendUserController.php b/Classes/Controller/FrontendUserController.php index c8adc55..43a7444 100644 --- a/Classes/Controller/FrontendUserController.php +++ b/Classes/Controller/FrontendUserController.php @@ -42,7 +42,6 @@ class FrontendUserController extends ActionController /** * @param FrontendUser|null $newFrontendUser - * @return ResponseInterface */ public function newAction(FrontendUser $newFrontendUser = null): ResponseInterface { @@ -53,7 +52,7 @@ public function newAction(FrontendUser $newFrontendUser = null): ResponseInterfa /** * @param FrontendUser $newFrontendUser */ - public function createAction(FrontendUser $newFrontendUser): void + public function createAction(FrontendUser $newFrontendUser) { /** @var FrontendUser $existingFrontendUser */ $existingFrontendUser = $this->frontendUserRepository->findOneByEmailAndStoragePageId($newFrontendUser->getEmail(), @@ -67,25 +66,23 @@ public function createAction(FrontendUser $newFrontendUser): void $this->request->getControllerExtensionName(), [1 => $this->settings['newsletterTitle'], 2 => $optInUri]); $this->sendEmail($existingFrontendUser->getEmail(), $this->settings['newsletterTitle'], $emailContent); - } else { + } elseif (!empty($this->settings['fieldList'])) { // user exists and is active - if (!empty($this->settings['fieldList'])) { - // user is editable, we send an edit profile link - $optInUri = $this->createOptInUri($existingFrontendUser->getUid(), 'edit'); - $emailContent = LocalizationUtility::translate('createFrontendUser.optInEmail.edit.unsubscribeOnly', - $this->request->getControllerExtensionName(), - [1 => $this->settings['newsletterTitle'], 2 => $optInUri]); - $this->sendEmail($existingFrontendUser->getEmail(), $this->settings['newsletterTitle'], - $emailContent); - } else { - // user is not editable, so we send an unsubscribe link - $optInUri = $this->createOptInUri($existingFrontendUser->getUid(), 'delete'); - $emailContent = LocalizationUtility::translate('createFrontendUser.optInEmail.edit.unsubscribeOnly', - $this->request->getControllerExtensionName(), - [1 => $this->settings['newsletterTitle'], 2 => $optInUri]); - $this->sendEmail($existingFrontendUser->getEmail(), $this->settings['newsletterTitle'], - $emailContent); - } + // user is editable, we send an edit profile link + $optInUri = $this->createOptInUri($existingFrontendUser->getUid(), 'edit'); + $emailContent = LocalizationUtility::translate('createFrontendUser.optInEmail.edit.unsubscribeOnly', + $this->request->getControllerExtensionName(), + [1 => $this->settings['newsletterTitle'], 2 => $optInUri]); + $this->sendEmail($existingFrontendUser->getEmail(), $this->settings['newsletterTitle'], + $emailContent); + } else { + // user is not editable, so we send an unsubscribe link + $optInUri = $this->createOptInUri($existingFrontendUser->getUid(), 'delete'); + $emailContent = LocalizationUtility::translate('createFrontendUser.optInEmail.edit.unsubscribeOnly', + $this->request->getControllerExtensionName(), + [1 => $this->settings['newsletterTitle'], 2 => $optInUri]); + $this->sendEmail($existingFrontendUser->getEmail(), $this->settings['newsletterTitle'], + $emailContent); } } else { $newFrontendUser->setUsername($newFrontendUser->getEmail()); @@ -104,7 +101,7 @@ public function createAction(FrontendUser $newFrontendUser): void $this->sendEmail($newFrontendUser->getEmail(), $this->settings['newsletterTitle'], $emailContent); } - $this->redirect('pendingOptIn'); + return $this->redirect('pendingOptIn'); } /** @@ -122,27 +119,28 @@ public function pendingOptInAction(): ResponseInterface public function activateAction(string $ruid = '', string $verify = '') { $frontendUserUid = (int)base64_decode($ruid); - if (!$frontendUserUid) { + if ($frontendUserUid === 0) { return new ForwardResponse('invalidLink'); - } else { - if ($verify === GeneralUtility::hmac($frontendUserUid)) { - $frontendUser = $this->frontendUserRepository->findByUid($frontendUserUid, false); - if ($frontendUser instanceof FrontendUser) { - $frontendUser->setDisable(false); - $this->frontendUserRepository->update($frontendUser); - $this->persistenceManager->persistAll(); - $successMessage = LocalizationUtility::translate('activateFrontendUser.success', - $this->request->getControllerExtensionName(), - [1 => $this->settings['newsletterTitle']]); - $this->addFlashMessage($successMessage); - $this->redirect('edit', null, null, $this->request->getArguments()); - } else { - return new ForwardResponse('invalidLink'); - } + } + if ($verify === \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\HashService::class)->hmac($frontendUserUid, 'changeMe')) { + $frontendUser = $this->frontendUserRepository->findByUid($frontendUserUid, false); + if ($frontendUser instanceof FrontendUser) { + $frontendUser->setDisable(false); + $this->frontendUserRepository->update($frontendUser); + $this->persistenceManager->persistAll(); + $successMessage = LocalizationUtility::translate('activateFrontendUser.success', + $this->request->getControllerExtensionName(), + [1 => $this->settings['newsletterTitle']]); + $this->addFlashMessage($successMessage); + return $this->redirect('edit', null, null, $this->request->getArguments()); } else { return new ForwardResponse('invalidLink'); } } + else { + return new ForwardResponse('invalidLink'); + } + return null; } /** @@ -153,34 +151,30 @@ public function invalidLinkAction(): ResponseInterface return $this->htmlResponse(); } - /** - * @param string $ruid - * @param string $verify - */ public function editAction(string $ruid = '', string $verify = ''): ResponseInterface { $frontendUserUid = (int)base64_decode($ruid); - if (!$frontendUserUid) { + if ($frontendUserUid === 0) { return new ForwardResponse('invalidLink'); - } else { - if ($verify === GeneralUtility::hmac($frontendUserUid)) { - $frontendUser = $this->frontendUserRepository->findByUid($frontendUserUid); - if ($frontendUser instanceof FrontendUser) { - $this->view->assign('frontendUser', $frontendUser); - $this->view->assign('unsubscribeUri', $this->createOptInUri($frontendUserUid, 'delete')); - $this->view->assign('verify', $verify); - if (!empty($this->settings['fieldList'])) { - // If fields need to be rendered, pass the names of the fields to the view - $this->view->assign('fieldsToRender', - GeneralUtility::trimExplode(',', $this->settings['fieldList'])); - } - } else { - return new ForwardResponse('invalidLink'); + } + if ($verify === \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\HashService::class)->hmac($frontendUserUid, 'changeMe')) { + $frontendUser = $this->frontendUserRepository->findByUid($frontendUserUid); + if ($frontendUser instanceof FrontendUser) { + $this->view->assign('frontendUser', $frontendUser); + $this->view->assign('unsubscribeUri', $this->createOptInUri($frontendUserUid, 'delete')); + $this->view->assign('verify', $verify); + if (!empty($this->settings['fieldList'])) { + // If fields need to be rendered, pass the names of the fields to the view + $this->view->assign('fieldsToRender', + GeneralUtility::trimExplode(',', $this->settings['fieldList'])); } } else { return new ForwardResponse('invalidLink'); } } + else { + return new ForwardResponse('invalidLink'); + } return $this->htmlResponse(); } @@ -188,19 +182,18 @@ public function editAction(string $ruid = '', string $verify = ''): ResponseInte * @param FrontendUser $frontendUser * @param string $verify */ - public function updateAction(FrontendUser $frontendUser, string $verify = ''): ResponseInterface + public function updateAction(FrontendUser $frontendUser, string $verify = ''): \Psr\Http\Message\ResponseInterface { - if ($verify === GeneralUtility::hmac($frontendUser->getUid())) { + if ($verify === \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\HashService::class)->hmac($frontendUser->getUid(), 'changeMe')) { $this->frontendUserRepository->update($frontendUser); $this->persistenceManager->persistAll(); $successMessage = LocalizationUtility::translate('updateFrontendUser.success', $this->request->getControllerExtensionName()); $this->addFlashMessage($successMessage); - $this->redirect('edit', null, null, + return $this->redirect('edit', null, null, ['verify' => $verify, 'ruid' => base64_encode($frontendUser->getUid())]); - } else { - return new ForwardResponse('updateError'); } + return new ForwardResponse('updateError'); } /** @@ -211,18 +204,14 @@ public function updateErrorAction(): ResponseInterface return $this->htmlResponse(); } - /** - * @param string $ruid - * @param string $verify - */ public function deleteAction(string $ruid = '', string $verify = ''): ResponseInterface { $frontendUserUid = (int)base64_decode($ruid); - if (!$frontendUserUid) { + if ($frontendUserUid === 0) { return new ForwardResponse('deleteError'); } - if ($verify === GeneralUtility::hmac($frontendUserUid)) { + if ($verify === \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\HashService::class)->hmac($frontendUserUid, 'changeMe')) { $frontendUser = $this->frontendUserRepository->findByUid($frontendUserUid); if ($frontendUser instanceof FrontendUser) { $this->frontendUserRepository->remove($frontendUser); @@ -244,11 +233,6 @@ public function deleteErrorAction(): ResponseInterface return $this->htmlResponse(); } - /** - * @param integer $uid - * @param string $action - * @return string - */ protected function createOptInUri(int $uid, string $action = 'activate'): string { $arguments = [ @@ -256,21 +240,13 @@ protected function createOptInUri(int $uid, string $action = 'activate'): string 'controller' => 'FrontendUser', 'action' => $action, 'ruid' => base64_encode($uid), - 'verify' => GeneralUtility::hmac($uid), + 'verify' => \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\HashService::class)->hmac($uid, 'changeMe'), ], ]; return $this->uriBuilder->reset()->setCreateAbsoluteUri(true)->setArguments($arguments)->build(); } - /** - * @param string $email - * @param string $subject - * @param string $content - * @param string $replyTo - * @param string $returnPath - * @return bool - */ protected function sendEmail(string $email, string $subject, string $content, string $replyTo = '', string $returnPath = ''): bool { /** @var $message \TYPO3\CMS\Core\Mail\MailMessage */ diff --git a/Classes/Domain/Model/FrontendUser.php b/Classes/Domain/Model/FrontendUser.php index c78097c..ce96315 100644 --- a/Classes/Domain/Model/FrontendUser.php +++ b/Classes/Domain/Model/FrontendUser.php @@ -28,7 +28,7 @@ class FrontendUser extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser /** * @var ObjectStorage */ - protected $usergroup = null; + protected $usergroup; /** * @var string @@ -52,9 +52,9 @@ class FrontendUser extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser /** * @var string - * @Extbase\Validate("EmailAddress") - * @Extbase\Validate("NotEmpty") */ + #[Extbase\Validate(['validator' => 'EmailAddress'])] + #[Extbase\Validate(['validator' => 'NotEmpty'])] protected $email; /** @@ -80,7 +80,7 @@ public function getGender() /** * @param string $gender */ - public function setGender($gender) + public function setGender($gender): void { $this->gender = $gender; } @@ -96,7 +96,7 @@ public function isActivateNewsletter() /** * @param boolean $activateNewsletter */ - public function setActivateNewsletter($activateNewsletter) + public function setActivateNewsletter($activateNewsletter): void { $this->activateNewsletter = $activateNewsletter; } @@ -112,7 +112,7 @@ public function isReceiveHtmlMail() /** * @param boolean $receiveHtmlMail */ - public function setReceiveHtmlMail($receiveHtmlMail) + public function setReceiveHtmlMail($receiveHtmlMail): void { $this->receiveHtmlMail = $receiveHtmlMail; } @@ -128,7 +128,7 @@ public function isDisable() /** * @param boolean $disable */ - public function setDisable($disable) + public function setDisable($disable): void { $this->disable = $disable; } diff --git a/Classes/Domain/Repository/FrontendUserRepository.php b/Classes/Domain/Repository/FrontendUserRepository.php index e26f161..abeb474 100644 --- a/Classes/Domain/Repository/FrontendUserRepository.php +++ b/Classes/Domain/Repository/FrontendUserRepository.php @@ -21,7 +21,7 @@ class FrontendUserRepository extends Repository { - public function initializeObject() + public function initializeObject(): void { $querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class); $querySettings->setRespectStoragePage(false); diff --git a/Classes/Updates/VisolNewsletterregistrationCTypeMigration.php b/Classes/Updates/VisolNewsletterregistrationCTypeMigration.php new file mode 100644 index 0000000..731486f --- /dev/null +++ b/Classes/Updates/VisolNewsletterregistrationCTypeMigration.php @@ -0,0 +1,41 @@ + 'pi_plugin1', + * 'pi_plugin2' => 'new_content_element', + * ] + * + * @return array + */ + protected function getListTypeToCTypeMapping(): array + { + return [ + // TODO: Add this mapping yourself! + ]; + } +} diff --git a/Configuration/TCA/Overrides/fe_users.php b/Configuration/TCA/Overrides/fe_users.php index 3dccc34..cc1d44f 100644 --- a/Configuration/TCA/Overrides/fe_users.php +++ b/Configuration/TCA/Overrides/fe_users.php @@ -1,6 +1,6 @@ [ @@ -9,14 +9,14 @@ 'type' => 'radio', 'default' => 'm', 'items' => [ - ['LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.m', 'm'], - ['LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.f', 'f'] + ['label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.m', 'value' => 'm'], + ['label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.f', 'value' => 'f'] ] ] ], ]; -ExtensionManagementUtility::addTCAcolumns('fe_users', $temporaryColumns, true); +ExtensionManagementUtility::addTCAcolumns('fe_users', $temporaryColumns); ExtensionManagementUtility::addToAllTCAtypes('fe_users', 'gender', '', 'after:company'); diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php new file mode 100644 index 0000000..c4ebab7 --- /dev/null +++ b/Configuration/TCA/Overrides/sys_template.php @@ -0,0 +1,3 @@ + 'new,create,edit,update,activate,delete' - ] + ], \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); diff --git a/ext_tables.php b/ext_tables.php index 33abe67..1fb4cce 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -5,10 +5,3 @@ if (!defined('TYPO3')) { die('Access denied.'); } - -/* TypoScript configuration */ -ExtensionManagementUtility::addStaticFile( - 'newsletterregistration', - 'Configuration/TypoScript', - 'Newsletter Registration' -); From 69c2ff6256579852f5556226b63f5e2dc4402643 Mon Sep 17 00:00:00 2001 From: Daniel Huf Date: Tue, 19 Aug 2025 09:49:46 +0200 Subject: [PATCH 03/11] chore: Run phpcs --- Classes/Controller/FrontendUserController.php | 128 ++++++++++-------- Classes/Domain/Model/FrontendUser.php | 26 ++-- .../Repository/FrontendUserRepository.php | 7 +- Configuration/Extbase/Persistence/Classes.php | 6 +- Configuration/TCA/Overrides/fe_users.php | 16 ++- Configuration/TCA/Overrides/tt_content.php | 5 +- ext_localconf.php | 11 +- ext_tables.php | 2 - 8 files changed, 107 insertions(+), 94 deletions(-) diff --git a/Classes/Controller/FrontendUserController.php b/Classes/Controller/FrontendUserController.php index 43a7444..011bf91 100644 --- a/Classes/Controller/FrontendUserController.php +++ b/Classes/Controller/FrontendUserController.php @@ -3,15 +3,17 @@ namespace Visol\Newsletterregistration\Controller; use Psr\Http\Message\ResponseInterface; +use TYPO3\CMS\Core\Crypto\HashService; use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory; use TYPO3\CMS\Core\Crypto\Random; +use TYPO3\CMS\Core\Mail\MailMessage; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Http\ForwardResponse; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; -use Visol\Newsletterregistration\Domain\Repository\FrontendUserRepository; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; -use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use Visol\Newsletterregistration\Domain\Model\FrontendUser; +use Visol\Newsletterregistration\Domain\Repository\FrontendUserRepository; /** * This file is part of the TYPO3 CMS project. @@ -27,7 +29,6 @@ */ class FrontendUserController extends ActionController { - /** * @var FrontendUserRepository */ @@ -40,49 +41,57 @@ class FrontendUserController extends ActionController */ protected $persistenceManager; - /** - * @param FrontendUser|null $newFrontendUser - */ - public function newAction(FrontendUser $newFrontendUser = null): ResponseInterface + public function newAction(?FrontendUser $newFrontendUser = null): ResponseInterface { $this->view->assign('newFrontendUser', $newFrontendUser); return $this->htmlResponse(); } - /** - * @param FrontendUser $newFrontendUser - */ public function createAction(FrontendUser $newFrontendUser) { /** @var FrontendUser $existingFrontendUser */ - $existingFrontendUser = $this->frontendUserRepository->findOneByEmailAndStoragePageId($newFrontendUser->getEmail(), - (int)$this->settings['userFolder']); + $existingFrontendUser = $this->frontendUserRepository->findOneByEmailAndStoragePageId( + $newFrontendUser->getEmail(), + (int) $this->settings['userFolder'] + ); if ($existingFrontendUser instanceof FrontendUser) { if ($existingFrontendUser->isDisable() === true) { // user is disabled, so maybe the opt-in failed - we send an opt-in-email again $url = $this->createOptInUri($existingFrontendUser->getUid()); - $optInUri = '' . $url . ''; - $emailContent = LocalizationUtility::translate('createFrontendUser.optInEmail.activate', + $optInUri = '' . $url . ''; + $emailContent = LocalizationUtility::translate( + 'createFrontendUser.optInEmail.activate', $this->request->getControllerExtensionName(), - [1 => $this->settings['newsletterTitle'], 2 => $optInUri]); + [1 => $this->settings['newsletterTitle'], 2 => $optInUri] + ); $this->sendEmail($existingFrontendUser->getEmail(), $this->settings['newsletterTitle'], $emailContent); } elseif (!empty($this->settings['fieldList'])) { // user exists and is active // user is editable, we send an edit profile link $optInUri = $this->createOptInUri($existingFrontendUser->getUid(), 'edit'); - $emailContent = LocalizationUtility::translate('createFrontendUser.optInEmail.edit.unsubscribeOnly', + $emailContent = LocalizationUtility::translate( + 'createFrontendUser.optInEmail.edit.unsubscribeOnly', $this->request->getControllerExtensionName(), - [1 => $this->settings['newsletterTitle'], 2 => $optInUri]); - $this->sendEmail($existingFrontendUser->getEmail(), $this->settings['newsletterTitle'], - $emailContent); + [1 => $this->settings['newsletterTitle'], 2 => $optInUri] + ); + $this->sendEmail( + $existingFrontendUser->getEmail(), + $this->settings['newsletterTitle'], + $emailContent + ); } else { // user is not editable, so we send an unsubscribe link $optInUri = $this->createOptInUri($existingFrontendUser->getUid(), 'delete'); - $emailContent = LocalizationUtility::translate('createFrontendUser.optInEmail.edit.unsubscribeOnly', + $emailContent = LocalizationUtility::translate( + 'createFrontendUser.optInEmail.edit.unsubscribeOnly', $this->request->getControllerExtensionName(), - [1 => $this->settings['newsletterTitle'], 2 => $optInUri]); - $this->sendEmail($existingFrontendUser->getEmail(), $this->settings['newsletterTitle'], - $emailContent); + [1 => $this->settings['newsletterTitle'], 2 => $optInUri] + ); + $this->sendEmail( + $existingFrontendUser->getEmail(), + $this->settings['newsletterTitle'], + $emailContent + ); } } else { $newFrontendUser->setUsername($newFrontendUser->getEmail()); @@ -90,14 +99,16 @@ public function createAction(FrontendUser $newFrontendUser) $newFrontendUser->setActivateNewsletter(true); $newFrontendUser->setReceiveHtmlMail(true); $newFrontendUser->setDisable(true); - $newFrontendUser->setPid((int)$this->settings['userFolder']); + $newFrontendUser->setPid((int) $this->settings['userFolder']); $this->frontendUserRepository->add($newFrontendUser); $this->persistenceManager->persistAll(); $url = $this->createOptInUri($newFrontendUser->getUid()); - $optInUri = '' . $url . ''; - $emailContent = LocalizationUtility::translate('createFrontendUser.optInEmail.activate', + $optInUri = '' . $url . ''; + $emailContent = LocalizationUtility::translate( + 'createFrontendUser.optInEmail.activate', $this->request->getControllerExtensionName(), - [1 => $this->settings['newsletterTitle'], 2 => $optInUri]); + [1 => $this->settings['newsletterTitle'], 2 => $optInUri] + ); $this->sendEmail($newFrontendUser->getEmail(), $this->settings['newsletterTitle'], $emailContent); } @@ -112,32 +123,29 @@ public function pendingOptInAction(): ResponseInterface return $this->htmlResponse(); } - /** - * @param string $ruid - * @param string $verify - */ public function activateAction(string $ruid = '', string $verify = '') { - $frontendUserUid = (int)base64_decode($ruid); + $frontendUserUid = (int) base64_decode($ruid); if ($frontendUserUid === 0) { return new ForwardResponse('invalidLink'); } - if ($verify === \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\HashService::class)->hmac($frontendUserUid, 'changeMe')) { + if ($verify === GeneralUtility::makeInstance(HashService::class)->hmac($frontendUserUid, 'changeMe')) { $frontendUser = $this->frontendUserRepository->findByUid($frontendUserUid, false); if ($frontendUser instanceof FrontendUser) { $frontendUser->setDisable(false); $this->frontendUserRepository->update($frontendUser); $this->persistenceManager->persistAll(); - $successMessage = LocalizationUtility::translate('activateFrontendUser.success', + $successMessage = LocalizationUtility::translate( + 'activateFrontendUser.success', $this->request->getControllerExtensionName(), - [1 => $this->settings['newsletterTitle']]); + [1 => $this->settings['newsletterTitle']] + ); $this->addFlashMessage($successMessage); return $this->redirect('edit', null, null, $this->request->getArguments()); } else { return new ForwardResponse('invalidLink'); } - } - else { + } else { return new ForwardResponse('invalidLink'); } return null; @@ -153,11 +161,11 @@ public function invalidLinkAction(): ResponseInterface public function editAction(string $ruid = '', string $verify = ''): ResponseInterface { - $frontendUserUid = (int)base64_decode($ruid); + $frontendUserUid = (int) base64_decode($ruid); if ($frontendUserUid === 0) { return new ForwardResponse('invalidLink'); } - if ($verify === \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\HashService::class)->hmac($frontendUserUid, 'changeMe')) { + if ($verify === GeneralUtility::makeInstance(HashService::class)->hmac($frontendUserUid, 'changeMe')) { $frontendUser = $this->frontendUserRepository->findByUid($frontendUserUid); if ($frontendUser instanceof FrontendUser) { $this->view->assign('frontendUser', $frontendUser); @@ -165,33 +173,36 @@ public function editAction(string $ruid = '', string $verify = ''): ResponseInte $this->view->assign('verify', $verify); if (!empty($this->settings['fieldList'])) { // If fields need to be rendered, pass the names of the fields to the view - $this->view->assign('fieldsToRender', - GeneralUtility::trimExplode(',', $this->settings['fieldList'])); + $this->view->assign( + 'fieldsToRender', + GeneralUtility::trimExplode(',', $this->settings['fieldList']) + ); } } else { return new ForwardResponse('invalidLink'); } - } - else { + } else { return new ForwardResponse('invalidLink'); } return $this->htmlResponse(); } - /** - * @param FrontendUser $frontendUser - * @param string $verify - */ - public function updateAction(FrontendUser $frontendUser, string $verify = ''): \Psr\Http\Message\ResponseInterface + public function updateAction(FrontendUser $frontendUser, string $verify = ''): ResponseInterface { - if ($verify === \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\HashService::class)->hmac($frontendUser->getUid(), 'changeMe')) { + if ($verify === GeneralUtility::makeInstance(HashService::class)->hmac($frontendUser->getUid(), 'changeMe')) { $this->frontendUserRepository->update($frontendUser); $this->persistenceManager->persistAll(); - $successMessage = LocalizationUtility::translate('updateFrontendUser.success', - $this->request->getControllerExtensionName()); + $successMessage = LocalizationUtility::translate( + 'updateFrontendUser.success', + $this->request->getControllerExtensionName() + ); $this->addFlashMessage($successMessage); - return $this->redirect('edit', null, null, - ['verify' => $verify, 'ruid' => base64_encode($frontendUser->getUid())]); + return $this->redirect( + 'edit', + null, + null, + ['verify' => $verify, 'ruid' => base64_encode($frontendUser->getUid())] + ); } return new ForwardResponse('updateError'); } @@ -206,12 +217,12 @@ public function updateErrorAction(): ResponseInterface public function deleteAction(string $ruid = '', string $verify = ''): ResponseInterface { - $frontendUserUid = (int)base64_decode($ruid); + $frontendUserUid = (int) base64_decode($ruid); if ($frontendUserUid === 0) { return new ForwardResponse('deleteError'); } - if ($verify === \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\HashService::class)->hmac($frontendUserUid, 'changeMe')) { + if ($verify === GeneralUtility::makeInstance(HashService::class)->hmac($frontendUserUid, 'changeMe')) { $frontendUser = $this->frontendUserRepository->findByUid($frontendUserUid); if ($frontendUser instanceof FrontendUser) { $this->frontendUserRepository->remove($frontendUser); @@ -240,7 +251,7 @@ protected function createOptInUri(int $uid, string $action = 'activate'): string 'controller' => 'FrontendUser', 'action' => $action, 'ruid' => base64_encode($uid), - 'verify' => \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\HashService::class)->hmac($uid, 'changeMe'), + 'verify' => GeneralUtility::makeInstance(HashService::class)->hmac($uid, 'changeMe'), ], ]; @@ -249,8 +260,8 @@ protected function createOptInUri(int $uid, string $action = 'activate'): string protected function sendEmail(string $email, string $subject, string $content, string $replyTo = '', string $returnPath = ''): bool { - /** @var $message \TYPO3\CMS\Core\Mail\MailMessage */ - $message = GeneralUtility::makeInstance('TYPO3\CMS\Core\Mail\MailMessage'); + /** @var MailMessage $message */ + $message = GeneralUtility::makeInstance(MailMessage::class); $message->addTo($email); $message->setFrom([$this->settings['sender']['email'] => $this->settings['sender']['name']]); @@ -303,5 +314,4 @@ protected function getHashedPassword(string $password): string $hashInstance = GeneralUtility::makeInstance(PasswordHashFactory::class)->getDefaultHashInstance('FE'); return $hashInstance->getHashedPassword($password); } - } diff --git a/Classes/Domain/Model/FrontendUser.php b/Classes/Domain/Model/FrontendUser.php index ce96315..af098a5 100644 --- a/Classes/Domain/Model/FrontendUser.php +++ b/Classes/Domain/Model/FrontendUser.php @@ -3,8 +3,9 @@ namespace Visol\Newsletterregistration\Domain\Model; use TYPO3\CMS\Extbase\Annotation as Extbase; -use TYPO3\CMS\Extbase\Persistence\ObjectStorage; use TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup; +use TYPO3\CMS\Extbase\Persistence\ObjectStorage; + /** * This file is part of the TYPO3 CMS project. * @@ -19,12 +20,9 @@ */ /** * A Frontend User - * - * @api */ class FrontendUser extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser { - /** * @var ObjectStorage */ @@ -36,17 +34,17 @@ class FrontendUser extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser protected $gender; /** - * @var boolean + * @var bool */ protected $activateNewsletter; /** - * @var boolean + * @var bool */ protected $receiveHtmlMail; /** - * @var boolean + * @var bool */ protected $disable; @@ -60,7 +58,6 @@ class FrontendUser extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser /** * Constructs a new Front-End User * - * @api * @param string $username * @param string $password */ @@ -86,7 +83,7 @@ public function setGender($gender): void } /** - * @return boolean + * @return bool */ public function isActivateNewsletter() { @@ -94,7 +91,7 @@ public function isActivateNewsletter() } /** - * @param boolean $activateNewsletter + * @param bool $activateNewsletter */ public function setActivateNewsletter($activateNewsletter): void { @@ -102,7 +99,7 @@ public function setActivateNewsletter($activateNewsletter): void } /** - * @return boolean + * @return bool */ public function isReceiveHtmlMail() { @@ -110,7 +107,7 @@ public function isReceiveHtmlMail() } /** - * @param boolean $receiveHtmlMail + * @param bool $receiveHtmlMail */ public function setReceiveHtmlMail($receiveHtmlMail): void { @@ -118,7 +115,7 @@ public function setReceiveHtmlMail($receiveHtmlMail): void } /** - * @return boolean + * @return bool */ public function isDisable() { @@ -126,11 +123,10 @@ public function isDisable() } /** - * @param boolean $disable + * @param bool $disable */ public function setDisable($disable): void { $this->disable = $disable; } - } diff --git a/Classes/Domain/Repository/FrontendUserRepository.php b/Classes/Domain/Repository/FrontendUserRepository.php index abeb474..78b2e0e 100644 --- a/Classes/Domain/Repository/FrontendUserRepository.php +++ b/Classes/Domain/Repository/FrontendUserRepository.php @@ -6,6 +6,7 @@ use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; use TYPO3\CMS\Extbase\Persistence\Repository; use Visol\Newsletterregistration\Domain\Model\FrontendUser; + /** * This file is part of the TYPO3 CMS project. * @@ -20,7 +21,6 @@ */ class FrontendUserRepository extends Repository { - public function initializeObject(): void { $querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class); @@ -30,8 +30,8 @@ public function initializeObject(): void /** * @param string $email - * @param integer $targetFolder - * @return FrontendUser|NULL + * @param int $targetFolder + * @return FrontendUser|null */ public function findOneByEmailAndStoragePageId($email, $targetFolder) { @@ -65,5 +65,4 @@ public function findByUid($uid, bool $respectEnableFields = true): ?FrontendUser ) )->execute()->getFirst(); } - } diff --git a/Configuration/Extbase/Persistence/Classes.php b/Configuration/Extbase/Persistence/Classes.php index d13fd60..c3145e5 100644 --- a/Configuration/Extbase/Persistence/Classes.php +++ b/Configuration/Extbase/Persistence/Classes.php @@ -9,11 +9,11 @@ 'tableName' => 'fe_users', 'properties' => [ 'activateNewsletter' => [ - 'fieldName' => 'module_sys_dmail_newsletter' + 'fieldName' => 'module_sys_dmail_newsletter', ], 'receiveHtmlMail' => [ - 'fieldName' => 'module_sys_dmail_html' + 'fieldName' => 'module_sys_dmail_html', ], - ] + ], ], ]; diff --git a/Configuration/TCA/Overrides/fe_users.php b/Configuration/TCA/Overrides/fe_users.php index cc1d44f..6055b15 100644 --- a/Configuration/TCA/Overrides/fe_users.php +++ b/Configuration/TCA/Overrides/fe_users.php @@ -1,5 +1,7 @@ 'm', 'items' => [ ['label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.m', 'value' => 'm'], - ['label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.f', 'value' => 'f'] - ] - ] + ['label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.f', 'value' => 'f'], + ], + ], ], ]; @@ -20,7 +22,11 @@ ExtensionManagementUtility::addToAllTCAtypes('fe_users', 'gender', '', 'after:company'); -ExtensionManagementUtility::addToAllTCAtypes('fe_users', 'title,first_name,last_name', '', - 'after:gender'); +ExtensionManagementUtility::addToAllTCAtypes( + 'fe_users', + 'title,first_name,last_name', + '', + 'after:gender' +); $GLOBALS['TCA']['fe_users']['columns']['usergroup']['config']['minitems'] = 0; diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 1362424..8157432 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -1,6 +1,7 @@ 'new,create,edit,update,pendingOptIn,activate,invalidLink,updateError,delete', ], // non-cacheable actions [ - FrontendUserController::class => 'new,create,edit,update,activate,delete' - ], \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + FrontendUserController::class => 'new,create,edit,update,activate,delete', + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); diff --git a/ext_tables.php b/ext_tables.php index 1fb4cce..01be305 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,7 +1,5 @@ Date: Tue, 19 Aug 2025 10:00:21 +0200 Subject: [PATCH 04/11] refactor: FrontendUser --- Classes/Domain/Model/FrontendUser.php | 105 +++++++++++--------------- 1 file changed, 44 insertions(+), 61 deletions(-) diff --git a/Classes/Domain/Model/FrontendUser.php b/Classes/Domain/Model/FrontendUser.php index af098a5..ab9522f 100644 --- a/Classes/Domain/Model/FrontendUser.php +++ b/Classes/Domain/Model/FrontendUser.php @@ -4,6 +4,7 @@ use TYPO3\CMS\Extbase\Annotation as Extbase; use TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; /** @@ -21,111 +22,93 @@ /** * A Frontend User */ -class FrontendUser extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser +class FrontendUser extends AbstractEntity { + protected string $username = ''; + + protected string $password = ''; + /** * @var ObjectStorage */ protected $usergroup; - /** - * @var string - */ - protected $gender; + protected string $gender; - /** - * @var bool - */ - protected $activateNewsletter; + protected bool $activateNewsletter; - /** - * @var bool - */ - protected $receiveHtmlMail; + protected bool $receiveHtmlMail; - /** - * @var bool - */ - protected $disable; + protected bool $disable; - /** - * @var string - */ #[Extbase\Validate(['validator' => 'EmailAddress'])] #[Extbase\Validate(['validator' => 'NotEmpty'])] - protected $email; + protected string $email; - /** - * Constructs a new Front-End User - * - * @param string $username - * @param string $password - */ - public function __construct($username = '', $password = '') + public function __construct( + string $username = '', + string $password = '') { - parent::__construct($username, $password); + $this->username = $username; + $this->password = $password; } - /** - * @return string - */ - public function getGender() + public function setUsername(string $username) + { + $this->username = $username; + } + + public function getUsername(): string + { + return $this->username; + } + + public function setPassword(string $password) + { + $this->password = $password; + } + + public function getPassword(): string + { + return $this->password; + } + + public function getGender(): string { return $this->gender; } - /** - * @param string $gender - */ - public function setGender($gender): void + public function setGender(string $gender): void { $this->gender = $gender; } - /** - * @return bool - */ - public function isActivateNewsletter() + public function isActivateNewsletter(): bool { return $this->activateNewsletter; } - /** - * @param bool $activateNewsletter - */ - public function setActivateNewsletter($activateNewsletter): void + public function setActivateNewsletter(bool $activateNewsletter): void { $this->activateNewsletter = $activateNewsletter; } - /** - * @return bool - */ - public function isReceiveHtmlMail() + public function isReceiveHtmlMail(): bool { return $this->receiveHtmlMail; } - /** - * @param bool $receiveHtmlMail - */ - public function setReceiveHtmlMail($receiveHtmlMail): void + public function setReceiveHtmlMail(bool $receiveHtmlMail): void { $this->receiveHtmlMail = $receiveHtmlMail; } - /** - * @return bool - */ - public function isDisable() + public function isDisable(): bool { return $this->disable; } - /** - * @param bool $disable - */ - public function setDisable($disable): void + public function setDisable(bool $disable): void { $this->disable = $disable; } From d49957e13a1164b062fd9b18957b2483a11b3125 Mon Sep 17 00:00:00 2001 From: Daniel Huf Date: Wed, 20 Aug 2025 12:57:01 +0200 Subject: [PATCH 05/11] refactor: Code cleanup --- Classes/Controller/FrontendUserController.php | 26 +++-------- Classes/Domain/Model/FrontendUser.php | 12 ++--- Configuration/Services.yaml | 8 ++++ Configuration/TCA/Overrides/fe_users.php | 42 +++++++++--------- Configuration/TCA/Overrides/tt_content.php | 35 +++++++++------ .../Private/Templates/FrontendUser/New.html | 6 ++- Resources/Public/Icons/Extension.gif | Bin 177 -> 0 bytes Resources/Public/Icons/Extension.svg | 1 + ext_icon.gif | Bin 177 -> 0 bytes ext_localconf.php | 29 ++++++------ ext_tables.php | 5 --- 11 files changed, 81 insertions(+), 83 deletions(-) create mode 100644 Configuration/Services.yaml delete mode 100644 Resources/Public/Icons/Extension.gif create mode 100644 Resources/Public/Icons/Extension.svg delete mode 100644 ext_icon.gif delete mode 100644 ext_tables.php diff --git a/Classes/Controller/FrontendUserController.php b/Classes/Controller/FrontendUserController.php index 011bf91..9540f8c 100644 --- a/Classes/Controller/FrontendUserController.php +++ b/Classes/Controller/FrontendUserController.php @@ -29,17 +29,11 @@ */ class FrontendUserController extends ActionController { - /** - * @var FrontendUserRepository - */ - protected $frontendUserRepository; - - /** - * persistenceManager - * - * @var PersistenceManager - */ - protected $persistenceManager; + public function __construct( + protected FrontendUserRepository $frontendUserRepository, + protected PersistenceManager $persistenceManager, + ) { + } public function newAction(?FrontendUser $newFrontendUser = null): ResponseInterface { @@ -292,16 +286,6 @@ protected function sendEmail(string $email, string $subject, string $content, st return $message->isSent(); } - public function injectFrontendUserRepository(FrontendUserRepository $frontendUserRepository): void - { - $this->frontendUserRepository = $frontendUserRepository; - } - - public function injectPersistenceManager(PersistenceManager $persistenceManager): void - { - $this->persistenceManager = $persistenceManager; - } - protected function getRandomPassword(): string { $randomPassword = GeneralUtility::makeInstance(Random::class)->generateRandomBytes(32); diff --git a/Classes/Domain/Model/FrontendUser.php b/Classes/Domain/Model/FrontendUser.php index ab9522f..586d76d 100644 --- a/Classes/Domain/Model/FrontendUser.php +++ b/Classes/Domain/Model/FrontendUser.php @@ -47,8 +47,8 @@ class FrontendUser extends AbstractEntity public function __construct( string $username = '', - string $password = '') - { + string $password = '' + ) { $this->username = $username; $this->password = $password; } @@ -56,22 +56,22 @@ public function __construct( public function setUsername(string $username) { $this->username = $username; - } + } public function getUsername(): string { return $this->username; - } + } public function setPassword(string $password) { $this->password = $password; - } + } public function getPassword(): string { return $this->password; - } + } public function getGender(): string { diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 0000000..574b1d5 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,8 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + Visol\Newsletterregistration\: + resource: '../Classes/*' diff --git a/Configuration/TCA/Overrides/fe_users.php b/Configuration/TCA/Overrides/fe_users.php index 6055b15..51ad3a3 100644 --- a/Configuration/TCA/Overrides/fe_users.php +++ b/Configuration/TCA/Overrides/fe_users.php @@ -4,29 +4,31 @@ defined('TYPO3') || die(); -$temporaryColumns = [ - 'gender' => [ - 'label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender', - 'config' => [ - 'type' => 'radio', - 'default' => 'm', - 'items' => [ - ['label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.m', 'value' => 'm'], - ['label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.f', 'value' => 'f'], +(static function (): void { + $temporaryColumns = [ + 'gender' => [ + 'label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender', + 'config' => [ + 'type' => 'radio', + 'default' => 'm', + 'items' => [ + ['label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.m', 'value' => 'm'], + ['label' => 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender.f', 'value' => 'f'], + ], ], ], - ], -]; + ]; -ExtensionManagementUtility::addTCAcolumns('fe_users', $temporaryColumns); + ExtensionManagementUtility::addTCAcolumns('fe_users', $temporaryColumns); -ExtensionManagementUtility::addToAllTCAtypes('fe_users', 'gender', '', 'after:company'); + ExtensionManagementUtility::addToAllTCAtypes('fe_users', 'gender', '', 'after:company'); -ExtensionManagementUtility::addToAllTCAtypes( - 'fe_users', - 'title,first_name,last_name', - '', - 'after:gender' -); + ExtensionManagementUtility::addToAllTCAtypes( + 'fe_users', + 'title,first_name,last_name', + '', + 'after:gender' + ); -$GLOBALS['TCA']['fe_users']['columns']['usergroup']['config']['minitems'] = 0; + $GLOBALS['TCA']['fe_users']['columns']['usergroup']['config']['minitems'] = 0; +})(); diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 8157432..b1741bf 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -5,18 +5,25 @@ defined('TYPO3') || die(); -/* Registration plugin with FlexForm */ -ExtensionUtility::registerPlugin( - 'newsletterregistration', - 'Newsletterregistration', - 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang.xlf:pluginLabel', - 'EXT:newsletterregistration/ext_icon.gif' -); +(static function (): void { + /* Registration plugin with FlexForm */ + ExtensionUtility::registerPlugin( + 'newsletterregistration', + 'newsletterregistration', + 'LLL:EXT:newsletterregistration/Resources/Private/Language/locallang.xlf:pluginLabel', + 'EXT:newsletterregistration/Resources/Public/Icons/Extension.svg' + ); -$pluginSignature = 'newsletterregistration_newsletterregistration'; -ExtensionManagementUtility::addToAllTCAtypes('tt_content', '--div--;Configuration,pi_flexform,', $pluginSignature, 'after:subheader'); -ExtensionManagementUtility::addPiFlexFormValue( - '*', - 'FILE:EXT:newsletterregistration/Configuration/FlexForm/flexform_newsletterregistration.xml', - $pluginSignature -); + $pluginSignature = 'newsletterregistration_newsletterregistration'; + ExtensionManagementUtility::addToAllTCAtypes( + 'tt_content', + '--div--;Configuration,pi_flexform,', + $pluginSignature, + 'after:subheader' + ); + ExtensionManagementUtility::addPiFlexFormValue( + '*', + 'FILE:EXT:newsletterregistration/Configuration/FlexForm/flexform_newsletterregistration.xml', + $pluginSignature + ); +})(); diff --git a/Resources/Private/Templates/FrontendUser/New.html b/Resources/Private/Templates/FrontendUser/New.html index 3136bd3..7a90b87 100644 --- a/Resources/Private/Templates/FrontendUser/New.html +++ b/Resources/Private/Templates/FrontendUser/New.html @@ -3,13 +3,15 @@ -

+

+ +

- +
diff --git a/Resources/Public/Icons/Extension.gif b/Resources/Public/Icons/Extension.gif deleted file mode 100644 index 1a832d4b660d1b498d5f980098a7c3953ff69a8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 177 zcmV;i08al$Nk%w1VG;lk0J8!BWo2cKj*jy3@|l^L$;ruVY;1*vg|V@*=H}+t*Vju+ zOI1}>D=RBPLPGxj{r~^~A^8LW00062EC2ui01^NY000DDP{>KEmFXN=lmdfw08JA} z4Wlvz6_lkRDJ!#33)}#bQJ)i%E+I(Nh?AENSWw+41YJXc5Fk4ec9G3FRl5J_Rh9}OA1rm-a80vh15)lA9z(qn} diff --git a/Resources/Public/Icons/Extension.svg b/Resources/Public/Icons/Extension.svg new file mode 100644 index 0000000..e1b4537 --- /dev/null +++ b/Resources/Public/Icons/Extension.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ext_icon.gif b/ext_icon.gif deleted file mode 100644 index 1a832d4b660d1b498d5f980098a7c3953ff69a8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 177 zcmV;i08al$Nk%w1VG;lk0J8!BWo2cKj*jy3@|l^L$;ruVY;1*vg|V@*=H}+t*Vju+ zOI1}>D=RBPLPGxj{r~^~A^8LW00062EC2ui01^NY000DDP{>KEmFXN=lmdfw08JA} z4Wlvz6_lkRDJ!#33)}#bQJ)i%E+I(Nh?AENSWw+41YJXc5Fk4ec9G3FRl5J_Rh9}OA1rm-a80vh15)lA9z(qn} diff --git a/ext_localconf.php b/ext_localconf.php index 9553e3d..c77e075 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -3,19 +3,18 @@ use TYPO3\CMS\Extbase\Utility\ExtensionUtility; use Visol\Newsletterregistration\Controller\FrontendUserController; -if (!defined('TYPO3')) { - die('Access denied.'); -} +defined('TYPO3') || die(); -/* Registration plugin */ -ExtensionUtility::configurePlugin( - 'newsletterregistration', - 'newsletterregistration', - [ - FrontendUserController::class => 'new,create,edit,update,pendingOptIn,activate,invalidLink,updateError,delete', - ], // non-cacheable actions - [ - FrontendUserController::class => 'new,create,edit,update,activate,delete', - ], - ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT -); +(static function (): void { + ExtensionUtility::configurePlugin( + 'newsletterregistration', + 'newsletterregistration', + [ + FrontendUserController::class => 'new,create,edit,update,pendingOptIn,activate,invalidLink,updateError,delete', + ], // non-cacheable actions + [ + FrontendUserController::class => 'new,create,edit,update,activate,delete', + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ); +})(); diff --git a/ext_tables.php b/ext_tables.php deleted file mode 100644 index 01be305..0000000 --- a/ext_tables.php +++ /dev/null @@ -1,5 +0,0 @@ - Date: Wed, 20 Aug 2025 16:10:48 +0200 Subject: [PATCH 06/11] fix: links in mail and add missing fields --- Classes/Controller/FrontendUserController.php | 8 ++- Classes/Domain/Model/FrontendUser.php | 58 ++++++++++++++++--- .../Private/Templates/FrontendUser/New.html | 4 +- 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/Classes/Controller/FrontendUserController.php b/Classes/Controller/FrontendUserController.php index 9540f8c..262dd24 100644 --- a/Classes/Controller/FrontendUserController.php +++ b/Classes/Controller/FrontendUserController.php @@ -41,7 +41,7 @@ public function newAction(?FrontendUser $newFrontendUser = null): ResponseInterf return $this->htmlResponse(); } - public function createAction(FrontendUser $newFrontendUser) + public function createAction(FrontendUser $newFrontendUser): ResponseInterface { /** @var FrontendUser $existingFrontendUser */ $existingFrontendUser = $this->frontendUserRepository->findOneByEmailAndStoragePageId( @@ -62,7 +62,8 @@ public function createAction(FrontendUser $newFrontendUser) } elseif (!empty($this->settings['fieldList'])) { // user exists and is active // user is editable, we send an edit profile link - $optInUri = $this->createOptInUri($existingFrontendUser->getUid(), 'edit'); + $url = $this->createOptInUri($existingFrontendUser->getUid(), 'edit'); + $optInUri = '' . $url . ''; $emailContent = LocalizationUtility::translate( 'createFrontendUser.optInEmail.edit.unsubscribeOnly', $this->request->getControllerExtensionName(), @@ -75,7 +76,8 @@ public function createAction(FrontendUser $newFrontendUser) ); } else { // user is not editable, so we send an unsubscribe link - $optInUri = $this->createOptInUri($existingFrontendUser->getUid(), 'delete'); + $url = $this->createOptInUri($existingFrontendUser->getUid(), 'delete'); + $optInUri = '' . $url . ''; $emailContent = LocalizationUtility::translate( 'createFrontendUser.optInEmail.edit.unsubscribeOnly', $this->request->getControllerExtensionName(), diff --git a/Classes/Domain/Model/FrontendUser.php b/Classes/Domain/Model/FrontendUser.php index 586d76d..0778c2a 100644 --- a/Classes/Domain/Model/FrontendUser.php +++ b/Classes/Domain/Model/FrontendUser.php @@ -24,10 +24,6 @@ */ class FrontendUser extends AbstractEntity { - protected string $username = ''; - - protected string $password = ''; - /** * @var ObjectStorage */ @@ -46,11 +42,11 @@ class FrontendUser extends AbstractEntity protected string $email; public function __construct( - string $username = '', - string $password = '' + protected string $username = '', + protected string $password = '', + protected string $firstName = '', + protected string $lastName = '', ) { - $this->username = $username; - $this->password = $password; } public function setUsername(string $username) @@ -112,4 +108,50 @@ public function setDisable(bool $disable): void { $this->disable = $disable; } + + public function getEmail(): string + { + return $this->email; + } + + public function setEmail(string $email): void + { + $this->email = $email; + } + + /** + * @return ObjectStorage + */ + public function getUsergroup(): ?ObjectStorage + { + return $this->usergroup; + } + + /** + * @param ObjectStorage $usergroup + */ + public function setUsergroup(ObjectStorage $usergroup): void + { + $this->usergroup = $usergroup; + } + + public function getFirstName(): string + { + return $this->firstName; + } + + public function setFirstName(string $firstName): void + { + $this->firstName = $firstName; + } + + public function getLastName(): string + { + return $this->lastName; + } + + public function setLastName(string $lastName): void + { + $this->lastName = $lastName; + } } diff --git a/Resources/Private/Templates/FrontendUser/New.html b/Resources/Private/Templates/FrontendUser/New.html index 7a90b87..5330e7c 100644 --- a/Resources/Private/Templates/FrontendUser/New.html +++ b/Resources/Private/Templates/FrontendUser/New.html @@ -2,7 +2,7 @@ - +

@@ -11,7 +11,7 @@ - +
From 79bc9d6a146db3497006c348ca80ac0027ebc3b7 Mon Sep 17 00:00:00 2001 From: Daniel Huf Date: Wed, 20 Aug 2025 16:16:25 +0200 Subject: [PATCH 07/11] chore: Run rector --- Classes/Controller/FrontendUserController.php | 7 ++----- Classes/Domain/Model/FrontendUser.php | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Classes/Controller/FrontendUserController.php b/Classes/Controller/FrontendUserController.php index 262dd24..0dd7d60 100644 --- a/Classes/Controller/FrontendUserController.php +++ b/Classes/Controller/FrontendUserController.php @@ -49,7 +49,7 @@ public function createAction(FrontendUser $newFrontendUser): ResponseInterface (int) $this->settings['userFolder'] ); if ($existingFrontendUser instanceof FrontendUser) { - if ($existingFrontendUser->isDisable() === true) { + if ($existingFrontendUser->isDisable()) { // user is disabled, so maybe the opt-in failed - we send an opt-in-email again $url = $this->createOptInUri($existingFrontendUser->getUid()); $optInUri = '' . $url . ''; @@ -138,13 +138,10 @@ public function activateAction(string $ruid = '', string $verify = '') ); $this->addFlashMessage($successMessage); return $this->redirect('edit', null, null, $this->request->getArguments()); - } else { - return new ForwardResponse('invalidLink'); } - } else { return new ForwardResponse('invalidLink'); } - return null; + return new ForwardResponse('invalidLink'); } /** diff --git a/Classes/Domain/Model/FrontendUser.php b/Classes/Domain/Model/FrontendUser.php index 0778c2a..18bb353 100644 --- a/Classes/Domain/Model/FrontendUser.php +++ b/Classes/Domain/Model/FrontendUser.php @@ -49,7 +49,7 @@ public function __construct( ) { } - public function setUsername(string $username) + public function setUsername(string $username): void { $this->username = $username; } @@ -59,7 +59,7 @@ public function getUsername(): string return $this->username; } - public function setPassword(string $password) + public function setPassword(string $password): void { $this->password = $password; } From 60c56e2940e7b90c1444d082d4527078813186e7 Mon Sep 17 00:00:00 2001 From: Daniel Huf Date: Wed, 20 Aug 2025 16:19:57 +0200 Subject: [PATCH 08/11] chore: Reduce checks to php 8.3 --- .github/workflows/ci.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b1e0fda..8dd023c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: 8.3 coverage: none tools: composer:v2 env: @@ -29,9 +29,7 @@ jobs: strategy: matrix: php-version: - - 7.4 - - 8.0 - - 8.1 + - 8.3 steps: - name: Checkout uses: actions/checkout@v2 From 7950f980e8da94360711c83a49ed293c10f9fbde Mon Sep 17 00:00:00 2001 From: Daniel Huf Date: Wed, 20 Aug 2025 16:21:59 +0200 Subject: [PATCH 09/11] chore: Update readme --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2c5e0ec..750a2d6 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,12 @@ This extension adds a simple and FlexForm-configurable plugin that enables the c This package is currently maintained for the following versions: -| TYPO3 Version | Package Version | Branch | Maintained | -|-----------------------|-----------------|---------|---------------| -| TYPO3 11.5.x | 3.x | master | Yes | -| TYPO3 8.7.x | 2.x | - | No | -| TYPO3 6.2.x - 7.9.x | 1.x | - | No | +| TYPO3 Version | Package Version | Branch | Maintained | +|---------------------|-----------------|--------|------------| +| TYPO3 13.4.x | 4.x | master | Yes | +| TYPO3 11.5.x | 3.x | - | No | +| TYPO3 8.7.x | 2.x | - | No | +| TYPO3 6.2.x - 7.9.x | 1.x | - | No | ## Contribute From 718d69167a8f9dc84462d0f89ed90b4c15825bec Mon Sep 17 00:00:00 2001 From: Daniel Huf Date: Mon, 15 Sep 2025 08:23:51 +0200 Subject: [PATCH 10/11] chore: run fractor --- .../flexform_newsletterregistration.xml | 111 ++++++++---------- Configuration/TypoScript/constants.typoscript | 26 ++-- Configuration/TypoScript/setup.typoscript | 44 +++---- 3 files changed, 87 insertions(+), 94 deletions(-) diff --git a/Configuration/FlexForm/flexform_newsletterregistration.xml b/Configuration/FlexForm/flexform_newsletterregistration.xml index 1e94346..10cf78b 100644 --- a/Configuration/FlexForm/flexform_newsletterregistration.xml +++ b/Configuration/FlexForm/flexform_newsletterregistration.xml @@ -1,3 +1,4 @@ + 1 @@ -5,67 +6,59 @@ - - LLL:EXT:newsletterregistration/Resources/Private/Language/locallang.xlf:flexform.sheetTitle - + LLL:EXT:newsletterregistration/Resources/Private/Language/locallang.xlf:flexform.sheetTitle array - - - 0 - - - input - trim,required - 30 - - - - - - 0 - - - select - selectMultipleSideBySide - - - LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender - gender - - - LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.first_name - firstName - - - LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.last_name - lastName - - - LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.company - company - - - 0 - 99 - 8 - - - - - - 0 - - - group - db - pages - 1 - 1 - 1 - - - + + 0 + + + input + trim,required + 30 + + + + 0 + + + select + selectMultipleSideBySide + + + LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender + gender + + + LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.first_name + firstName + + + LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.last_name + lastName + + + LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.company + company + + + 0 + 99 + 8 + + + + 0 + + + group + db + pages + 1 + 1 + 1 + + diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 513f041..b45dded 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -1,14 +1,14 @@ plugin.tx_newsletterregistration { - view { - # cat=plugin.tx_easyvote/file; type=string; label=Path to template root (FE) - templateRootPath = EXT:newsletterregistration/Resources/Private/Templates/ - # cat=plugin.tx_easyvote/file; type=string; label=Path to template partials (FE) - partialRootPath = EXT:newsletterregistration/Resources/Private/Partials/ - # cat=plugin.tx_easyvote/file; type=string; label=Path to template layouts (FE) - layoutRootPath = EXT:newsletterregistration/Resources/Private/Layouts/ - } - persistence { - # cat=plugin.tx_easyvote//a; type=string; label=Default storage PID - storagePid = - } -} \ No newline at end of file + view { + # cat=plugin.tx_easyvote/file; type=string; label=Path to template root (FE) + templateRootPath = EXT:newsletterregistration/Resources/Private/Templates/ + # cat=plugin.tx_easyvote/file; type=string; label=Path to template partials (FE) + partialRootPath = EXT:newsletterregistration/Resources/Private/Partials/ + # cat=plugin.tx_easyvote/file; type=string; label=Path to template layouts (FE) + layoutRootPath = EXT:newsletterregistration/Resources/Private/Layouts/ + } + persistence { + # cat=plugin.tx_easyvote//a; type=string; label=Default storage PID + storagePid = + } +} diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 8300a52..bc087a8 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -1,24 +1,24 @@ plugin.tx_newsletterregistration { - view { - templateRootPath = {$plugin.tx_newsletterregistration.view.templateRootPath} - partialRootPath = {$plugin.tx_newsletterregistration.view.partialRootPath} - layoutRootPath = {$plugin.tx_newsletterregistration.view.layoutRootPath} - } - persistence { - storagePid = {$plugin.tx_newsletterregistration.persistence.storagePid} - } - mvc { - callDefaultActionIfActionCantBeResolved = 1 - } - features { - skipDefaultArguments = 1 - } - settings { - sender { - name = My organization - email = no_reply@example.org - linkUrl = http://www.example.org - linkText = www.example.org - } - } + view { + templateRootPath = {$plugin.tx_newsletterregistration.view.templateRootPath} + partialRootPath = {$plugin.tx_newsletterregistration.view.partialRootPath} + layoutRootPath = {$plugin.tx_newsletterregistration.view.layoutRootPath} + } + persistence { + storagePid = {$plugin.tx_newsletterregistration.persistence.storagePid} + } + mvc { + callDefaultActionIfActionCantBeResolved = 1 + } + features { + skipDefaultArguments = 1 + } + settings { + sender { + name = My organization + email = no_reply@example.org + linkUrl = http://www.example.org + linkText = www.example.org + } + } } From 4e98fd2b1042d45f701355b6de0c267da9eef6d2 Mon Sep 17 00:00:00 2001 From: Daniel Huf Date: Mon, 15 Sep 2025 08:44:10 +0200 Subject: [PATCH 11/11] fix: flexform --- .../flexform_newsletterregistration.xml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Configuration/FlexForm/flexform_newsletterregistration.xml b/Configuration/FlexForm/flexform_newsletterregistration.xml index 10cf78b..1b7e45f 100644 --- a/Configuration/FlexForm/flexform_newsletterregistration.xml +++ b/Configuration/FlexForm/flexform_newsletterregistration.xml @@ -14,8 +14,9 @@ input - trim,required + trim 30 + 1 @@ -26,20 +27,20 @@ selectMultipleSideBySide - LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.gender - gender + + gender - LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.first_name - firstName + + firstName - LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.last_name - lastName + + lastName - LLL:EXT:newsletterregistration/Resources/Private/Language/locallang_db.xlf:fe_users.company - company + + company 0 @@ -52,7 +53,6 @@ group - db pages 1 1