diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index b534186957..84cb7e372f 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -172,7 +172,8 @@ public function updateAllConfirmed(User $user) 'changes' => UserUtility::getDirtyPropertiesFromUser($existingUser), 'settings' => $this->settings, ], - $this->config['edit.']['email.']['notifyAdmin.'] ?? [] + $this->config['edit.']['email.']['notifyAdmin.'] ?? [], + $this->request ); } @@ -208,7 +209,8 @@ public function updateRequest($user) 'changes' => $dirtyProperties, 'hash' => HashUtility::createHashForUser($user), ], - $this->config['edit.']['email.']['updateRequest.'] ?? [] + $this->config['edit.']['email.']['updateRequest.'] ?? [], + $this->request ); $this->logUtility->log( Log::STATUS_PROFILEUPDATEREFUSEDADMIN, @@ -263,7 +265,8 @@ public function finalCreate( ConfigurationUtility::getValue('new./email./createUserNotify./subject.', $this->config), ), $variables, - ConfigurationUtility::getValue('new./email./createUserNotify.', $this->config) + ConfigurationUtility::getValue('new./email./createUserNotify.', $this->config), + $this->request ); } @@ -288,7 +291,8 @@ public function finalCreate( ConfigurationUtility::getValue('new./email./createAdminNotify./subject.', $this->config) ), $variables, - ConfigurationUtility::getValue('new./email./createAdminNotify.', $this->config) + ConfigurationUtility::getValue('new./email./createAdminNotify.', $this->config), + $this->request ); } @@ -351,7 +355,7 @@ protected function redirectByAction($action = 'new', $category = 'redirect') // if redirect target if ($target) { - $this->redirectToUri(StringUtility::removeDoubleSlashesFromUri($target)); + return $this->redirectToUri(StringUtility::removeDoubleSlashesFromUri($target)); } } @@ -545,7 +549,8 @@ public function sendCreateUserConfirmationMail(User $user) 'user' => $user, 'hash' => HashUtility::createHashForUser($user), ], - ConfigurationUtility::getValue('new./email./createUserConfirmation.', $this->config) + ConfigurationUtility::getValue('new./email./createUserConfirmation.', $this->config), + $this->request ); } } diff --git a/Classes/Controller/NewController.php b/Classes/Controller/NewController.php index ca00b1c889..7950480716 100644 --- a/Classes/Controller/NewController.php +++ b/Classes/Controller/NewController.php @@ -18,6 +18,7 @@ use In2code\Femanager\Utility\HashUtility; use In2code\Femanager\Utility\LocalizationUtility; use In2code\Femanager\Utility\StringUtility; +use In2code\Femanager\Utility\TemplateUtility; use In2code\Femanager\Utility\UserUtility; use JsonException; use Psr\Http\Message\ResponseInterface; @@ -29,6 +30,7 @@ use TYPO3\CMS\Extbase\Event\Mvc\AfterRequestDispatchedEvent; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; use TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException; +use TYPO3\CMS\Fluid\View\StandaloneView; /** * Class NewController @@ -67,6 +69,7 @@ public function newAction(User $user = null): ResponseInterface #[Validate(['validator' => CaptchaValidator::class, 'param' => 'user'])] public function createAction(User $user): ResponseInterface { + if ($this->ratelimiterService->isLimited()) { $this->addFlashMessage( LocalizationUtility::translate('ratelimiter_too_many_attempts'), @@ -156,7 +159,7 @@ public function confirmCreateRequestAction(int $user, string $hash, string $stat } if ($furtherFunctions) { - $this->redirectByAction('new', $status . 'Redirect'); + return $this->redirectByAction('new', $status . 'Redirect'); } return $this->redirect('new'); @@ -283,7 +286,8 @@ protected function statusAdminConfirmationRefused(User $user, $hash, $status): b ['sender@femanager.org' => 'Sender Name'], 'Your profile was refused', ['user' => $user], - ConfigurationUtility::getValue('new./email./createUserNotifyRefused.', $this->config) + ConfigurationUtility::getValue('new./email./createUserNotifyRefused.', $this->config), + $this->request ); } $this->userRepository->remove($user); @@ -370,7 +374,8 @@ protected function createAdminConfirmationRequest(User $user) 'user' => $user, 'hash' => HashUtility::createHashForUser($user) ], - ConfigurationUtility::getValue('new./email./createAdminConfirmation.', $this->config) + ConfigurationUtility::getValue('new./email./createAdminConfirmation.', $this->config), + $this->request ); $this->addFlashMessage(LocalizationUtility::translate('createRequestWaitingForAdminConfirm')); } diff --git a/Classes/Domain/Service/SendMailService.php b/Classes/Domain/Service/SendMailService.php index 7068a8d0d1..7aafe1bdd3 100644 --- a/Classes/Domain/Service/SendMailService.php +++ b/Classes/Domain/Service/SendMailService.php @@ -14,6 +14,7 @@ use TYPO3\CMS\Core\Mail\Mailer; use TYPO3\CMS\Core\Mail\MailMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Mvc\RequestInterface; /** * Class SendMailService @@ -61,7 +62,8 @@ public function send( array $sender, string $subject, array $variables = [], - array $typoScript = [] + array $typoScript = [], + RequestInterface|null $request = null ): bool { if (false === $this->isMailEnabled($typoScript, $receiver)) { return false; @@ -70,7 +72,7 @@ public function send( $this->contentObjectStart($variables); $email = GeneralUtility::makeInstance(MailMessage::class); $variables = $this->embedImages($variables, $typoScript, $email); - $this->prepareMailObject($template, $receiver, $sender, $subject, $variables, $email); + $this->prepareMailObject($template, $receiver, $sender, $subject, $variables, $email, $request); $this->overwriteEmailReceiver($typoScript, $email); $this->overwriteEmailSender($typoScript, $email); $this->setSubject($typoScript, $email); @@ -91,9 +93,9 @@ public function send( * @param string $template Template file in Templates/Email/ * @param array $variables Variables for assignMultiple */ - protected function getMailBody(string $template, array $variables): string + protected function getMailBody(string $template, array $variables, RequestInterface|null $request = null): string { - $standAloneView = TemplateUtility::getDefaultStandAloneView(); + $standAloneView = TemplateUtility::getDefaultStandAloneView($request); $standAloneView->setTemplatePathAndFilename($this->getRelativeEmailPathAndFilename($template)); $standAloneView->assignMultiple($variables); return $standAloneView->render(); @@ -130,9 +132,10 @@ protected function prepareMailObject( array $sender, string $subject, array $variables, - MailMessage $email + MailMessage $email, + RequestInterface|null $request = null ): void { - $html = $this->getMailBody($template, $variables); + $html = $this->getMailBody($template, $variables, $request); $email->setTo($receiver) ->setFrom($sender) ->setSubject($subject) diff --git a/Classes/Utility/TemplateUtility.php b/Classes/Utility/TemplateUtility.php index fb38250bf1..8cead51fd9 100644 --- a/Classes/Utility/TemplateUtility.php +++ b/Classes/Utility/TemplateUtility.php @@ -5,6 +5,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; +use TYPO3\CMS\Extbase\Mvc\RequestInterface; use TYPO3\CMS\Fluid\View\StandaloneView; /** @@ -111,10 +112,14 @@ public static function getTemplatePaths($pathAndFilename, $part = 'template') * @return StandaloneView */ public static function getDefaultStandAloneView( + RequestInterface|null $request = null, string $format = 'html' ) { /** @var StandaloneView $standAloneView */ $standAloneView = GeneralUtility::makeInstance(StandaloneView::class); + if ($request instanceof RequestInterface) { + $standAloneView->setRequest($request); + } $standAloneView->setFormat($format); $standAloneView->setLayoutRootPaths(TemplateUtility::getTemplateFolders('layout')); $standAloneView->setPartialRootPaths(TemplateUtility::getTemplateFolders('partial')); diff --git a/Resources/Private/Partials/Mail/UserProperties.html b/Resources/Private/Partials/Mail/UserProperties.html index f44b78ae21..632dbbac6f 100644 --- a/Resources/Private/Partials/Mail/UserProperties.html +++ b/Resources/Private/Partials/Mail/UserProperties.html @@ -1,7 +1,7 @@ - + @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -25,7 +25,7 @@ - + @@ -33,7 +33,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -57,7 +57,7 @@ - + @@ -65,29 +65,29 @@ - + - + - + - + @@ -95,7 +95,7 @@ - + @@ -103,7 +103,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -119,7 +119,7 @@ - + @@ -127,7 +127,7 @@ - + @@ -135,7 +135,7 @@ - + - + - + diff --git a/Resources/Private/Templates/Email/CreateAdminConfirmation.html b/Resources/Private/Templates/Email/CreateAdminConfirmation.html index f68bb4ff0f..cd6d5f14ce 100644 --- a/Resources/Private/Templates/Email/CreateAdminConfirmation.html +++ b/Resources/Private/Templates/Email/CreateAdminConfirmation.html @@ -10,34 +10,34 @@ {hash} Hash to ensure authentication of link -

+

-

+

- +
- +

- +
- +

- +
- +

diff --git a/Resources/Private/Templates/Email/CreateNotify.html b/Resources/Private/Templates/Email/CreateNotify.html index 0c4fa0e672..1841df735f 100644 --- a/Resources/Private/Templates/Email/CreateNotify.html +++ b/Resources/Private/Templates/Email/CreateNotify.html @@ -10,30 +10,30 @@ {settings} Array with Flexform and TypoScript settings -

+

- +

-

+

- +
- +

- +
- +

diff --git a/Resources/Private/Templates/Email/CreateUserConfirmation.html b/Resources/Private/Templates/Email/CreateUserConfirmation.html index a40de23204..d736940c3c 100644 --- a/Resources/Private/Templates/Email/CreateUserConfirmation.html +++ b/Resources/Private/Templates/Email/CreateUserConfirmation.html @@ -10,23 +10,23 @@ {hash} Hash to ensure authentication of link -

{user.username},

+

{user.username},

- +
- +

- +
- +

-

-
\ No newline at end of file +

+ diff --git a/Resources/Private/Templates/Email/CreateUserNotifyRefused.html b/Resources/Private/Templates/Email/CreateUserNotifyRefused.html index 79b9d62612..08c26a99a5 100644 --- a/Resources/Private/Templates/Email/CreateUserNotifyRefused.html +++ b/Resources/Private/Templates/Email/CreateUserNotifyRefused.html @@ -9,9 +9,9 @@ {user} User Object -

{user.username},

+

{user.username},

-

+

-

-
\ No newline at end of file +

+ diff --git a/Resources/Private/Templates/Email/Invitation.html b/Resources/Private/Templates/Email/Invitation.html index c1f73892db..47376e2b49 100644 --- a/Resources/Private/Templates/Email/Invitation.html +++ b/Resources/Private/Templates/Email/Invitation.html @@ -10,25 +10,25 @@ {hash} Hash to ensure authentication of link -

{user.username},

+

{user.username},

-

+

- +
- +

- +
- +

-

-
\ No newline at end of file +

+ diff --git a/Resources/Private/Templates/Email/InvitationNotify.html b/Resources/Private/Templates/Email/InvitationNotify.html index c7f335e619..154f3f641e 100644 --- a/Resources/Private/Templates/Email/InvitationNotify.html +++ b/Resources/Private/Templates/Email/InvitationNotify.html @@ -10,14 +10,14 @@ {settings} Array with Flexform and TypoScript settings -

+

- +

-

+

diff --git a/Resources/Private/Templates/Email/InvitationNotifyStep1.html b/Resources/Private/Templates/Email/InvitationNotifyStep1.html index 5b473bc6ea..49c333ba75 100644 --- a/Resources/Private/Templates/Email/InvitationNotifyStep1.html +++ b/Resources/Private/Templates/Email/InvitationNotifyStep1.html @@ -10,14 +10,14 @@ {settings} Array with Flexform and TypoScript settings -

+

- +

-

+

diff --git a/Resources/Private/Templates/Email/InvitationRefused.html b/Resources/Private/Templates/Email/InvitationRefused.html index c78acfdb06..feef7462f4 100644 --- a/Resources/Private/Templates/Email/InvitationRefused.html +++ b/Resources/Private/Templates/Email/InvitationRefused.html @@ -10,14 +10,14 @@ {settings} Array with Flexform and TypoScript settings -

+

- +

-

+

diff --git a/Resources/Private/Templates/Email/UpdateNotify.html b/Resources/Private/Templates/Email/UpdateNotify.html index dc7b4a8efa..3ea6a76829 100644 --- a/Resources/Private/Templates/Email/UpdateNotify.html +++ b/Resources/Private/Templates/Email/UpdateNotify.html @@ -11,23 +11,23 @@ {settings} Array with Flexform and TypoScript settings -

+

- +

{user.username}
{user.email}
{user.www}
{user.title}
{user.firstName}
{user.middleName}
{user.lastName}
{user.name}
{user.company}
- +
- {user.dateOfBirth} + {user.dateOfBirth}
{user.telephone}
{user.fax}
{user.address}
{user.zip}
{user.city}
{user.country}
{user.state} @@ -144,7 +144,7 @@
Error in User Image @@ -154,7 +154,7 @@
{usergroup.title},
- - - + + + - +
@@ -35,12 +35,12 @@ - + - {change.old} + {change.old} {change.old} @@ -50,7 +50,7 @@ - [] + [] @@ -64,12 +64,12 @@ - + - {change.new} + {change.new} {change.new} diff --git a/Resources/Private/Templates/Email/UpdateRequest.html b/Resources/Private/Templates/Email/UpdateRequest.html index 37b54b229e..1e6d761e7c 100644 --- a/Resources/Private/Templates/Email/UpdateRequest.html +++ b/Resources/Private/Templates/Email/UpdateRequest.html @@ -11,25 +11,25 @@ {hash} Hash to ensure authentication of link -

+

- +

-

+

- - - + + + - +
@@ -37,12 +37,12 @@ - + - {change.old} + {change.old} {change.old} @@ -52,7 +52,7 @@ - [] + [] @@ -66,12 +66,12 @@ - + - {change.new} + {change.new} {change.new} @@ -92,17 +92,17 @@
  • - +
  • - +
  • - +
diff --git a/Resources/Private/Templates/Email/UpdateRequestRefused.html b/Resources/Private/Templates/Email/UpdateRequestRefused.html index bd7a1acd2d..4b2335cdbb 100644 --- a/Resources/Private/Templates/Email/UpdateRequestRefused.html +++ b/Resources/Private/Templates/Email/UpdateRequestRefused.html @@ -9,16 +9,16 @@ {user} User Object -

{user.username},

+

{user.username},

-

+

- +

-

+