Commit 574d9c63 authored by Kevin von Spiczak's avatar Kevin von Spiczak
Browse files

Merge remote-tracking branch 'origin/master' into feature_2251_mail_changes

parents 31a4dd56 cfc394d1
<?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;
}
}
......@@ -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 === '') {
......
......@@ -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'
],
],
]
......
......@@ -6,7 +6,7 @@
"license": [
"GPL-2.0-or-later"
],
"version": "5.5.2",
"version": "5.5.3",
"repositories": [
{
"type": "composer",
......
......@@ -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' => '',
......
......@@ -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;
......
Supports Markdown
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