Skip to content

[FEATURE] Flexform configuration for Opt-In Mail #657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,20 @@ 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),
'receiverName' => $this->mailRepository->getSenderNameFromArguments(
$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),
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Service/Mail/SendSenderMailPreflight.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
30 changes: 27 additions & 3 deletions Classes/Domain/Service/Mail/SenderMailPropertiesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}
}
33 changes: 33 additions & 0 deletions Configuration/FlexForms/FlexformPi1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,39 @@
</el>
</ROOT>
</sender>
<optin>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:powermail/Resources/Private/Language/locallang_db.xlf:flexform.optin</sheetTitle>
</TCEforms>
<displayCond>FIELD:main.settings.flexform.main.optin:=:1</displayCond>
<type>array</type>
<el>
<settings.flexform.optin.subject>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:powermail/Resources/Private/Language/locallang_db.xlf:flexform.optin.subject</label>
<config>
<type>input</type>
<eval>trim</eval>
</config>
</TCEforms>
</settings.flexform.optin.subject>
<settings.flexform.optin.body>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:powermail/Resources/Private/Language/locallang_db.xlf:flexform.optin.body</label>
<config>
<type>text</type>
<enableRichtext>1</enableRichtext>
<richtextConfiguration>default</richtextConfiguration>
</config>
<defaultExtras>richtext[]:rte_transform[mode=ts_css]</defaultExtras>
</TCEforms>
</settings.flexform.optin.body>
</el>
</ROOT>
</optin>
<thx>
<ROOT>
<TCEforms>
Expand Down
12 changes: 12 additions & 0 deletions Resources/Private/Language/de.locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,18 @@
<source>Bodytext for Email to Sender</source>
<target state="translated">Inhalt der Mail an Absender</target>
</trans-unit>
<trans-unit id="flexform.optin">
<source>Double Opt-In Mail</source>
<target state="translated">Double Opt-In</target>
</trans-unit>
<trans-unit id="flexform.optin.subject">
<source>Subject for Double Opt-In Email</source>
<target state="translated">Betreff der Double Opt-In E-Mail</target>
</trans-unit>
<trans-unit id="flexform.optin.body">
<source>Bodytext for Double Opt-in Email</source>
<target state="translated">Inhalt der Double Opt-In E-Mail</target>
</trans-unit>
<trans-unit id="flexform.thx">
<source>Submit Page</source>
<target state="translated">Antwortseite</target>
Expand Down
9 changes: 9 additions & 0 deletions Resources/Private/Language/locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,15 @@
<trans-unit id="flexform.sender.body" resname="flexform.sender.body">
<source>Bodytext for Email to Sender</source>
</trans-unit>
<trans-unit id="flexform.optin" resname="flexform.optin">
<source>Double Opt-In Mail</source>
</trans-unit>
<trans-unit id="flexform.optin.subject" resname="flexform.optin.subject">
<source>Subject for Double Opt-In Email</source>
</trans-unit>
<trans-unit id="flexform.optin.body" resname="flexform.optin.body">
<source>Bodytext for Double Opt-In Email</source>
</trans-unit>
<trans-unit id="flexform.thx" resname="flexform.thx">
<source>Submit Page</source>
</trans-unit>
Expand Down
13 changes: 12 additions & 1 deletion Resources/Private/Templates/Mail/OptinMail.html
Original file line number Diff line number Diff line change
Expand Up @@ -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


<f:section name="main">
<f:translate key="optin_mail_link" /><br>
<f:if condition="{settings.optin.body}">
<f:then>
<vh:misc.variables mail="{mail}" type="mail" function="sender">
<f:format.html parseFuncTSPath="lib.parseFunc_powermail">{powermail_rte}</f:format.html>
</vh:misc.variables>
</f:then>
<f:else>
<f:translate key="optin_mail_link" /><br>
</f:else>
</f:if>

<f:format.htmlentitiesDecode>
<f:link.action action="optinConfirm" absolute="1" arguments="{hash: hash, mail: mail}">
Expand Down