From dd9b6fb728717103733de40ffec2614cce99195e Mon Sep 17 00:00:00 2001 From: KreativeKrise Date: Wed, 10 Mar 2021 17:14:09 +0100 Subject: [PATCH 1/2] [FEATURE] Flexform configuration for Opt-In Mail --- .../SendOptinConfirmationMailPreflight.php | 41 +++++++++++++++---- .../Service/Mail/SendSenderMailPreflight.php | 2 +- .../Mail/SenderMailPropertiesService.php | 30 ++++++++++++-- Configuration/FlexForms/FlexformPi1.xml | 33 +++++++++++++++ .../Private/Language/de.locallang_db.xlf | 12 ++++++ Resources/Private/Language/locallang_db.xlf | 9 ++++ .../Private/Templates/Mail/OptinMail.html | 13 +++++- 7 files changed, 126 insertions(+), 14 deletions(-) diff --git a/Classes/Domain/Service/Mail/SendOptinConfirmationMailPreflight.php b/Classes/Domain/Service/Mail/SendOptinConfirmationMailPreflight.php index ea7d76f45..6ff4b5d8f 100644 --- a/Classes/Domain/Service/Mail/SendOptinConfirmationMailPreflight.php +++ b/Classes/Domain/Service/Mail/SendOptinConfirmationMailPreflight.php @@ -65,6 +65,7 @@ public function __construct(array $settings, array $conf) */ public function sendOptinConfirmationMail(Mail $mail): void { + $senderService = ObjectUtility::getObjectManager()->get(SenderMailPropertiesService::class, $this->settings, $this->conf); $email = [ 'template' => 'Mail/OptinMail', 'receiverEmail' => $this->mailRepository->getSenderMailFromArguments($mail), @@ -72,15 +73,12 @@ public function sendOptinConfirmationMail(Mail $mail): void $mail, [$this->conf['sender.']['default.'], 'senderName'] ), - 'senderEmail' => $this->settings['sender']['email'], - 'senderName' => $this->settings['sender']['name'], - 'replyToEmail' => $this->settings['sender']['email'], - 'replyToName' => $this->settings['sender']['name'], - 'subject' => ObjectUtility::getContentObject()->cObjGetSingle( - $this->conf['optin.']['subject'], - $this->conf['optin.']['subject.'] - ), - 'rteBody' => '', + 'senderEmail' => $senderService->getSenderEmail(), + 'senderName' => $senderService->getSenderName(), + 'replyToEmail' => $senderService->getSenderEmail(), + 'replyToName' => $senderService->getSenderName(), + 'subject' => $senderService->getOptinSubject(), + 'rteBody' => $this->settings['optin']['body'], 'format' => $this->settings['sender']['mailformat'], 'variables' => [ 'hash' => HashUtility::getHash($mail), @@ -91,4 +89,29 @@ public function sendOptinConfirmationMail(Mail $mail): void ]; $this->sendMailService->sendMail($email, $mail, $this->settings, 'optin'); } + + /** + * Get optin subject from form settings. If empty, take value from TypoScript. + * + * @param string $typoScriptValue + * @return string + * @throws InvalidSlotException + * @throws InvalidSlotReturnException + * @throws Exception + */ + public function getOptinSubject(): string + { + if ($this->settings['optin']['subject'] !== '') { + $optinSubject = $this->settings['optin']['subject']; + } else { + $optinSubject = ObjectUtility::getContentObject()->cObjGetSingle( + $this->conf['optin.']['subject'], + $this->conf['optin.']['subject.'] + ); + } + + $signalArguments = [&$optinSubject, $this]; + $this->signalDispatch(__CLASS__, __FUNCTION__, $signalArguments); + return $optinSubject; + } } diff --git a/Classes/Domain/Service/Mail/SendSenderMailPreflight.php b/Classes/Domain/Service/Mail/SendSenderMailPreflight.php index 0d091994a..735994a41 100644 --- a/Classes/Domain/Service/Mail/SendSenderMailPreflight.php +++ b/Classes/Domain/Service/Mail/SendSenderMailPreflight.php @@ -65,7 +65,7 @@ public function __construct(array $settings, array $conf) */ public function sendSenderMail(Mail $mail): void { - $senderService = ObjectUtility::getObjectManager()->get(SenderMailPropertiesService::class, $this->settings); + $senderService = ObjectUtility::getObjectManager()->get(SenderMailPropertiesService::class, $this->settings, $this->conf); $email = [ 'template' => 'Mail/SenderMail', 'receiverEmail' => $this->mailRepository->getSenderMailFromArguments($mail), diff --git a/Classes/Domain/Service/Mail/SenderMailPropertiesService.php b/Classes/Domain/Service/Mail/SenderMailPropertiesService.php index b196d1b96..820d07c0b 100644 --- a/Classes/Domain/Service/Mail/SenderMailPropertiesService.php +++ b/Classes/Domain/Service/Mail/SenderMailPropertiesService.php @@ -35,13 +35,13 @@ class SenderMailPropertiesService /** * @param array $settings + * @param array $configuration * @throws Exception */ - public function __construct(array $settings) + public function __construct(array $settings, array $configuration) { $this->settings = $settings; - $typoScriptService = ObjectUtility::getObjectManager()->get(TypoScriptService::class); - $this->configuration = $typoScriptService->convertPlainArrayToTypoScriptArray($this->settings); + $this->configuration = $configuration; } /** @@ -95,4 +95,28 @@ public function getSenderName(): string $this->signalDispatch(__CLASS__, __FUNCTION__, $signalArguments); return $senderName; } + + /** + * Get optin subject from form settings. If empty, take value from TypoScript. + * + * @return string + * @throws InvalidSlotException + * @throws InvalidSlotReturnException + * @throws Exception + */ + public function getOptinSubject(): string + { + if ($this->settings['optin']['subject'] !== '') { + $optinSubject = $this->settings['optin']['subject']; + } else { + $optinSubject = ObjectUtility::getContentObject()->cObjGetSingle( + $this->configuration['optin.']['subject'], + $this->configuration['optin.']['subject.'] + ); + } + + $signalArguments = [&$optinSubject, $this]; + $this->signalDispatch(__CLASS__, __FUNCTION__, $signalArguments); + return $optinSubject; + } } diff --git a/Configuration/FlexForms/FlexformPi1.xml b/Configuration/FlexForms/FlexformPi1.xml index 71d7faddc..a476d5bd2 100644 --- a/Configuration/FlexForms/FlexformPi1.xml +++ b/Configuration/FlexForms/FlexformPi1.xml @@ -302,6 +302,39 @@ + + + + LLL:EXT:powermail/Resources/Private/Language/locallang_db.xlf:flexform.optin + + FIELD:main.settings.flexform.main.optin:=:1 + array + + + + 1 + + + input + trim + + + + + + 1 + + + text + 1 + default + + richtext[]:rte_transform[mode=ts_css] + + + + + diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index 248274061..3a1d46a43 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -700,6 +700,18 @@ Bodytext for Email to Sender Inhalt der Mail an Absender + + Double Opt-In Mail + Double Opt-In + + + Subject for Double Opt-In Email + Betreff der Double Opt-In E-Mail + + + Bodytext for Double Opt-in Email + Inhalt der Double Opt-In E-Mail + Submit Page Antwortseite diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 131e29dd1..4b964df15 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -501,6 +501,15 @@ Bodytext for Email to Sender + + Double Opt-In Mail + + + Subject for Double Opt-In Email + + + Bodytext for Double Opt-In Email + Submit Page diff --git a/Resources/Private/Templates/Mail/OptinMail.html b/Resources/Private/Templates/Mail/OptinMail.html index 890099244..cee67f791 100644 --- a/Resources/Private/Templates/Mail/OptinMail.html +++ b/Resources/Private/Templates/Mail/OptinMail.html @@ -6,13 +6,24 @@ Mail will only be send, if Optin was enabled by editor + {powermail_rte} Variable is filled with values from RTE in backend + {powermail_all} Outputs all fields {mail} Complete Mail Object {hash} Hash for optin URI {settings} TypoScript Settings -
+ + + + {powermail_rte} + + + +
+
+
From 140665a59981d85fdc5ade267773b3afe0cfae02 Mon Sep 17 00:00:00 2001 From: KreativeKrise Date: Wed, 10 Mar 2021 17:16:56 +0100 Subject: [PATCH 2/2] Fix: Remove useless function --- .../SendOptinConfirmationMailPreflight.php | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/Classes/Domain/Service/Mail/SendOptinConfirmationMailPreflight.php b/Classes/Domain/Service/Mail/SendOptinConfirmationMailPreflight.php index 6ff4b5d8f..e0c940d98 100644 --- a/Classes/Domain/Service/Mail/SendOptinConfirmationMailPreflight.php +++ b/Classes/Domain/Service/Mail/SendOptinConfirmationMailPreflight.php @@ -89,29 +89,4 @@ public function sendOptinConfirmationMail(Mail $mail): void ]; $this->sendMailService->sendMail($email, $mail, $this->settings, 'optin'); } - - /** - * Get optin subject from form settings. If empty, take value from TypoScript. - * - * @param string $typoScriptValue - * @return string - * @throws InvalidSlotException - * @throws InvalidSlotReturnException - * @throws Exception - */ - public function getOptinSubject(): string - { - if ($this->settings['optin']['subject'] !== '') { - $optinSubject = $this->settings['optin']['subject']; - } else { - $optinSubject = ObjectUtility::getContentObject()->cObjGetSingle( - $this->conf['optin.']['subject'], - $this->conf['optin.']['subject.'] - ); - } - - $signalArguments = [&$optinSubject, $this]; - $this->signalDispatch(__CLASS__, __FUNCTION__, $signalArguments); - return $optinSubject; - } }