diff --git a/Classes/Form/NodeExpansion/FieldInformation.php b/Classes/Form/NodeExpansion/FieldInformation.php deleted file mode 100644 index 08a44f250a3b1223c8df643ccf48984f4b5fa2da..0000000000000000000000000000000000000000 --- a/Classes/Form/NodeExpansion/FieldInformation.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -namespace SGalinski\SgMail\Form\NodeExpansion; - -/*************************************************************** - * Copyright notice - * - * (c) sgalinski Internet Services (https://www.sgalinski.de) - * - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use TYPO3\CMS\Backend\Form\AbstractNode; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Utility\LocalizationUtility; - -/** - * Renders additional TCA field information. - */ -class FieldInformation extends AbstractNode { - - /** - * @return array Result array - */ - public function render(): array { - $result = $this->initializeResultArray(); - $options = $this->data['renderData']['fieldInformationOptions'] - ?? $this->data['renderData']['fieldWizardOptions']; - - if ( - !isset($options['text']) - && (!isset($options['parentFields'], $options['parentTable'], $options['parentUidField'])) - ) { - return $result; - } - - $text = \trim($options['text'] ?? ''); - - if ($text === '') { - return $result; - } - - if (\strpos($text, 'LLL') === 0) { - $text = LocalizationUtility::translate($text); - } - - $tagOpen = '<span>'; - $tagClose = '</span>'; - - if (isset($options['tag'])) { - $tag = \trim(\str_replace(['<', '>'], '', $options['tag'])); - $tagSplit = GeneralUtility::trimExplode(' ', $tag); - $tagName = $tagSplit[0]; - - if ($tagName !== '') { - $tagOpen = '<' . $tag . '>'; - $tagClose = '</' . $tagName . '>'; - } - } - - $result['html'] = '<div>' . $tagOpen . $text . $tagClose . '</div>'; - - return $result; - } -} diff --git a/Classes/Service/MailTemplateService.php b/Classes/Service/MailTemplateService.php index 3f8ae42f1a4a035558f0a0ae957594ab5e59e340..9bf4ef2a3454c5e9a6a0f3ab6d0312ae2365524f 100644 --- a/Classes/Service/MailTemplateService.php +++ b/Classes/Service/MailTemplateService.php @@ -223,6 +223,16 @@ class MailTemplateService { */ private $subjectToSend; + /* + * @var string + */ + private $defaultFromAddress; + + /** + * @var string + */ + private $defaultFromName; + /** * @return string */ @@ -335,18 +345,18 @@ class MailTemplateService { // use defaultMailFromAddress if it is provided in LocalConfiguration.php; use the sg_mail TS setting as fallback if (\filter_var($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'], FILTER_VALIDATE_EMAIL)) { $this->fromAddress = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']; + $this->defaultFromAddress = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']; + } else if (!\filter_var($tsSettings['mail']['default']['from'], FILTER_VALIDATE_EMAIL)) { + $this->fromAddress = 'noreply@example.org'; + $this->defaultFromAddress = 'noreply@example.org'; } else { $this->fromAddress = $tsSettings['mail']['default']['from']; - - if (!\filter_var($tsSettings['mail']['default']['from'], FILTER_VALIDATE_EMAIL)) { - $this->fromAddress = 'noreply@example.org'; - } else { - $this->fromAddress = $tsSettings['mail']['default']['from']; - } + $this->defaultFromAddress = $tsSettings['mail']['default']['from']; } if ($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']) { $this->fromName = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']; + $this->defaultFromName = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']; } $this->mailMessage->setFrom($this->fromAddress, $this->fromName); @@ -573,6 +583,8 @@ class MailTemplateService { } /** + * IMPORTANT: make sure to set $this->>ignoreMailQueue(TRUE), if you're using this method to add an attachment! + * Otherwise the attachment is ignored when sending the mail via mail queue. * @param Swift_OutputByteStream $data * @param string $filename * @param string $contentType @@ -971,20 +983,24 @@ class MailTemplateService { //TODO: is this object even in use somewhere? $this->mailMessage->setSubject($subject); - if ($this->fromAddress === '') { + if ($this->fromAddress === $this->defaultFromAddress) { $fromMail = $this->parseMarkers( empty($this->overwrittenFromMail) && $template ? $template->getFromMail() : $this->overwrittenFromMail, $emailView ); - $this->setFromAddress($fromMail); + if ($fromMail) { // we don't want to override the default in that case + $this->setFromAddress($fromMail); + } } - if ($this->fromName === '') { + if ($this->fromName === $this->defaultFromName) { $fromName = $this->parseMarkers( (empty($this->overwrittenFromName) && $template ? $template->getFromName() : $this->overwrittenFromName), $emailView ); - $this->setFromName($fromName); + if ($fromName) { // we don't want to override the default if this value is empty here + $this->setFromName($fromName); + } } if ($this->replyToAddress === '') { diff --git a/Configuration/TCA/tx_sgmail_domain_model_layout.php b/Configuration/TCA/tx_sgmail_domain_model_layout.php index 53127a061dd471cd6056f83afa8ffd4dc72f39de..363da6e64aaf0a9ed736216ea8fe7b97ff248826 100644 --- a/Configuration/TCA/tx_sgmail_domain_model_layout.php +++ b/Configuration/TCA/tx_sgmail_domain_model_layout.php @@ -126,17 +126,10 @@ return [ 'content' => [ 'exclude' => TRUE, 'label' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_layout.content', + 'description' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_layout.content.info', 'config' => [ 'type' => 'text', - 'renderType' => 't3editor', - 'fieldInformation' => [ - 'info' => [ - 'renderType' => 'sgMailFieldInformation', - 'options' => [ - 'text' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_layout.content.info' - ] - ], - ], + 'renderType' => 't3editor' ], ], ] diff --git a/composer.json b/composer.json index 885564b3a71e74df85a70f243f820403204cefa7..47c32d5380261b30df014f4f5a8b3830a94b8c83 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "license": [ "GPL-2.0-or-later" ], - "version": "5.5.2", + "version": "5.5.3", "repositories": [ { "type": "composer", diff --git a/ext_emconf.php b/ext_emconf.php index 4ededb75dd39fdd7a931a1f13d576b37dd05bfe5..73ef5b9a1ddfc8c4cb111f93a79966e2119e6d19 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,7 +8,7 @@ $EM_CONF['sg_mail'] = [ 'title' => 'Mail Templates', 'description' => 'Mail Templates', 'category' => 'module', - 'version' => '5.5.2', + 'version' => '5.5.3', 'state' => 'stable', 'uploadfolder' => FALSE, 'createDirs' => '', diff --git a/ext_localconf.php b/ext_localconf.php index a78784e2f1c4a62f30752da2f80344fb616c4e72..106edb59ffc7bfbb2f4f6038676112e50a870b18 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -51,13 +51,6 @@ call_user_func( 'className' => \SGalinski\SgMail\XClass\Form\FormManagerController::class, ]; - // Register FormEngine node type resolvers - $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry']['sgMailFieldInformation'] = [ - 'nodeName' => 'sgMailFieldInformation', - 'priority' => 10, - 'class' => \SGalinski\SgMail\Form\NodeExpansion\FieldInformation::class, - ]; - // Datamap process hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = \SGalinski\SgMail\Hooks\ProcessDatamap::class;