Commit cfe01493 authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[BUGFIX] Fix language and pid determination of fresh templates

parent b914f5eb
......@@ -723,6 +723,8 @@ class MailTemplateService implements SingletonInterface {
} elseif (is_bool($value)) {
$valueAsString = $value ? 'true' : 'false';
$allMarker .= $key . ': ' . $valueAsString . PHP_EOL;
} elseif ($value instanceof DateTime) {
$allMarker .= $key . ': ' . $value->format('d.m.Y') . PHP_EOL;
} elseif (is_object($value)) {
if (method_exists($value, '__toString')) {
$allMarker .= $key . ': ' . $value->__toString() . PHP_EOL;
......@@ -756,6 +758,8 @@ class MailTemplateService implements SingletonInterface {
} elseif (is_bool($value)) {
$valueAsString = $value ? 'true' : 'false';
$allMarker .= '<tr><th>' . $key . ' </th><td> ' . $valueAsString . '</td></tr>';
} elseif ($value instanceof DateTime) {
$allMarker .= '<tr><th>' . $key . ' </th><td> ' . $value->format('d.m.Y') . '</td></tr>';
} elseif (is_object($value)) {
if (method_exists($value, '__toString')) {
$allMarker .= '<tr><th>' . $key . ' </th><td> ' . $value->__toString() . '</td></tr>';
......@@ -942,7 +946,18 @@ class MailTemplateService implements SingletonInterface {
$toAddresses = $addressesArray;
}
$mailMessage->setTo($toAddresses);
if ($toAddresses === '') {
if (\filter_var($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'], FILTER_VALIDATE_EMAIL)) {
$mailMessage->setTo($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']);
} else {
$mail->setStatus(Mail::STATUS_ERROR);
$mail->setErrorMessage(LocalizationUtility::translate('error.noValidToAddress', 'sg_mail'));
continue;
}
} else {
$mailMessage->setTo($toAddresses);
}
$mailMessage->setFrom($mail->getFromAddress(), $mail->getFromName());
$mailMessage->setCc(
GeneralUtility::trimExplode(',', $mail->getCcAddresses(), TRUE)
......@@ -993,7 +1008,7 @@ class MailTemplateService implements SingletonInterface {
$success = $mailMessage->send();
if (!$success) {
$mail->setStatus(Mail::STATUS_ERROR);
$mail->setErrorMessage(LocalizationUtility::translate('backend.success_mail_queue', 'sg_mail'));
$mail->setErrorMessage(LocalizationUtility::translate('error.mailsending', 'sg_mail'));
}
$mail->setStatus(Mail::STATUS_SENT);
} catch (TransportException $exception) {
......
......@@ -617,6 +617,14 @@ Die Templates declined und approved der Extension sg_comments sind für alle Dom
<source><![CDATA[Preview could not be generated]]></source>
<target><![CDATA[Vorschau konnte nicht generiert werden]]></target>
</trans-unit>
<trans-unit id="error.mailsending">
<source><![CDATA[Something went wrong with sending the mail]]></source>
<target><![CDATA[Die Mail konnte nicht versendet werden]]></target>
</trans-unit>
<trans-unit id="error.noValidToAddress">
<source><![CDATA[The supplied To-Address is not valid]]></source>
<target><![CDATA[Die Empfänger Adresse ist nicht valide]]></target>
</trans-unit>
</body>
</file>
</xliff>
......@@ -462,6 +462,12 @@ The templates declined and approved of the sg_comments extension are blacklisted
<trans-unit id="backend.preview.error">
<source><![CDATA[Preview could not be generated]]></source>
</trans-unit>
<trans-unit id="error.mailsending">
<source><![CDATA[Something went wrong with sending the mail]]></source>
</trans-unit>
<trans-unit id="error.noValidToAddress">
<source><![CDATA[The supplied To-Address is not valid]]></source>
</trans-unit>
</body>
</file>
</xliff>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment