Commit dd9bb695 authored by Georgi Mateev's avatar Georgi Mateev
Browse files

[BUGFIX] 1583 Release Version 5.4.2

Fixed:
- preview markers in the newsletter
- keep values in the newsletter form after sending
- fixed pagination performance in MailQueue
parent 2f2dd73c
......@@ -382,6 +382,7 @@ class MailController extends ActionController {
$mailTemplateService->setFromAddress($template['fromMail']);
$mailTemplateService->setTemplateName($parameters['selectedTemplate']);
$mailTemplateService->setExtensionKey($parameters['selectedExtension']);
$mailTemplateService->setPreviewMarkers();
$mailIsSend = $mailTemplateService->sendEmail(TRUE);
}
......
......@@ -210,7 +210,7 @@ class NewsletterController extends ActionController {
// if no templates are in the db, get the default from the files
$templates = [];
$subject = $registerArray[$parameters['selectedExtension']][$parameters['selectedTemplate']]['subject'];
$subject = $arguments['subject'] ?? $registerArray[$parameters['selectedExtension']][$parameters['selectedTemplate']]['subject'];
/** @var Template $template */
foreach ($templatesFromDb as $key => $template) {
if ($template === NULL) {
......@@ -225,7 +225,7 @@ class NewsletterController extends ActionController {
$subject = LocalizationUtility::translate($subject, NULL, NULL, $key);
}
$templateFromFile->setSubject($subject);
$subject = $registerArray[$parameters['selectedExtension']][$parameters['selectedTemplate']]['subject'];
$subject = $arguments['subject'] ?? $registerArray[$parameters['selectedExtension']][$parameters['selectedTemplate']]['subject'];
if ($registerArray[$parameters['selectedExtension']][$parameters['selectedTemplate']]['templateContent']) {
$templateFromFile->setContent(
$registerArray[$parameters['selectedExtension']][$parameters['selectedTemplate']]['templateContent']
......@@ -238,8 +238,29 @@ class NewsletterController extends ActionController {
$template->setIsOverwritten(TRUE);
}
if (!empty($arguments['mailBody'])) {
$templates[$key]->setContent($arguments['mailBody']);
if (!empty($arguments['content'])) {
$templates[$key]->setContent($arguments['content']);
}
if (!empty($arguments['cc'])) {
$templates[$key]->setCc($arguments['cc']);
}
if (!empty($arguments['bcc'])) {
$templates[$key]->setBcc($arguments['bcc']);
}
if (!empty($arguments['fromName'])) {
$templates[$key]->setFromName($arguments['fromName']);
}
if (!empty($arguments['fromMail'])) {
$templates[$key]->setFromMail($arguments['fromMail']);
}
if (!empty($arguments['replyTo'])) {
$templates[$key]->setReplyTo($arguments['replyTo']);
}
if (!empty($arguments['layout'])) {
$templates[$key]->setLayout($arguments['layout']);
}
if (!empty($arguments['subject'])) {
$templates[$key]->setSubject($arguments['subject']);
}
}
......@@ -310,7 +331,8 @@ class NewsletterController extends ActionController {
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
$this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version));
/** @noinspection PhpInternalEntityUsedInspection */
$this->view->assign('beUserMail', $GLOBALS['BE_USER']->user['email']);
$beUserMail = (!empty($arguments['emailAddress'])?$arguments['emailAddress']:$GLOBALS['BE_USER']->user['email']);
$this->view->assign('beUserMail', $beUserMail);
// get the default language label and pass it to the view
$pageTsConfig = BackendUtility::getPagesTSconfig($pageUid);
......@@ -398,16 +420,37 @@ class NewsletterController extends ActionController {
);
$mailIsSend = FALSE;
$mailTemplateService->setSubject($parameter['subject']);
$mailTemplateService->setReplyToAddress($parameter['replyTo']);
$mailTemplateService->setTemplateName($parameters['selectedTemplate']);
$mailTemplateService->setExtensionKey($parameters['selectedExtension']);
$mailTemplateService->setFromAddress($parameter['fromMail']);
if (!$this->request->hasArgument('sendDirectly')) {
// Send test emails
$message = LocalizationUtility::translate('backend.success_mail', 'sg_mail');
foreach ((array) $parameters['templates'] as $key => $template) {
$mailTemplateService->setLanguage($key);
$mailTemplateService->setToAddresses($parameters['emailAddress']);
$mailTemplateService->setFromAddress($template['fromMail']);
$mailTemplateService->setTemplateName($parameters['selectedTemplate']);
$mailTemplateService->setExtensionKey($parameters['selectedExtension']);
$mailTemplateService->setOverwrittenEmailBody($parameter['content']);
$mailTemplateService->setMarkers([
'user' => [
'username' => 'username@example.com',
'name' => 'Max Mustermann',
'title' => 'Dr.',
'first_name' => 'Max',
'last_name' => 'Mustermann',
'address' => 'Berlin, Germany',
'zip' => '89073',
'city' => 'Ulm',
'country' => 'Germany',
'telephone' => '491535555555',
'email' => 'max.mustermann@example.com',
'company' => 'Muster GmbH',
'www' => ' www.example.com',
]
]);
$mailIsSend = $mailTemplateService->sendEmail(TRUE);
}
......@@ -420,10 +463,9 @@ class NewsletterController extends ActionController {
foreach ((array) $parameters['templates'] as $key => $template) {
$mailTemplateService->setLanguage($key);
$mailTemplateService->setFromAddress($template['fromMail']);
$mailTemplateService->setTemplateName($parameters['selectedTemplate']);
$mailTemplateService->setExtensionKey($parameters['selectedExtension']);
$mailTemplateService->setOverwrittenEmailBody($parameter['content']);
$mailTemplateService->setBccAddresses($parameter['bcc']);
$mailTemplateService->setCcAddresses($parameter['cc']);
foreach ($recipients as $recipient) {
......@@ -455,7 +497,8 @@ class NewsletterController extends ActionController {
$this->addFlashMessage($message, '', FlashMessage::ERROR);
}
$arguments['selectedGroups'] = $parameters['selectedGroups'];
$arguments['mailBody'] = $parameter['content'];
$arguments = array_merge($arguments, $parameter);
$arguments['emailAddress'] = $parameters['emailAddress'];
$this->redirect('index', NULL, NULL, $arguments);
}
......
......@@ -167,6 +167,10 @@ class MailRepository extends AbstractRepository {
$constraintsAnd[] = $query->equals('pid', (int) $pid);
$query->setOrderings(['tstamp' => Query::ORDER_DESCENDING]);
return $query->matching($query->logicalAnd($constraintsAnd))->execute(TRUE);
$query->matching($query->logicalAnd($constraintsAnd));
// $queryParser = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class);
// $doctrineQuery = ($queryParser->convertQueryToDoctrineQueryBuilder($query));
return $query->execute();
}
}
......@@ -563,6 +563,45 @@ class MailTemplateService {
return $generatedMarker;
}
/**
* Set preview markers for the template editor
*
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public function setPreviewMarkers() {
$previewMarker = [];
// get default template content from register array
$registerService = GeneralUtility::makeInstance(RegisterService::class);
/** @var array $markerArray */
$markerArray = $registerService->getRegisterArray()[$this->extensionKey][$this->templateName]['marker'];
foreach ($markerArray as $marker) {
$markerPath = GeneralUtility::trimExplode('.', $marker['marker']);
$temporaryMarkerArray = [];
foreach (\array_reverse($markerPath) as $index => $markerPathSegment) {
if ($index === 0) {
if ($marker['markerLabel']) {
$markerPathSegment = $marker['markerLabel'];
}
if ($marker['backend_translation_key']) {
$temporaryMarkerArray[$markerPathSegment] = LocalizationUtility::translate(
$marker['backend_translation_key'], $marker['extension_key']
);
} else {
$temporaryMarkerArray[$markerPathSegment] = $marker['value'];
}
} else {
$temporaryMarkerArray = [$markerPathSegment => $temporaryMarkerArray];
}
}
/** @noinspection SlowArrayOperationsInLoopInspection */
$previewMarker = \array_merge_recursive($previewMarker, $temporaryMarkerArray);
}
$this->setMarkers($previewMarker);
}
/**
* Send the Email
*
......@@ -670,35 +709,8 @@ class MailTemplateService {
}
if ($isPreview) {
$previewMarker = [];
/** @var array $markerArray */
$markerArray = $registerService->getRegisterArray()[$this->extensionKey][$this->templateName]['marker'];
foreach ($markerArray as $marker) {
$markerPath = GeneralUtility::trimExplode('.', $marker['marker']);
$temporaryMarkerArray = [];
foreach (\array_reverse($markerPath) as $index => $markerPathSegment) {
if ($index === 0) {
if ($marker['markerLabel']) {
$markerPathSegment = $marker['markerLabel'];
}
if ($marker['backend_translation_key']) {
$temporaryMarkerArray[$markerPathSegment] = LocalizationUtility::translate(
$marker['backend_translation_key'], $marker['extension_key']
);
} else {
$temporaryMarkerArray[$markerPathSegment] = $marker['value'];
}
} else {
$temporaryMarkerArray = [$markerPathSegment => $temporaryMarkerArray];
}
}
/** @noinspection SlowArrayOperationsInLoopInspection */
$previewMarker = \array_merge_recursive($previewMarker, $temporaryMarkerArray);
}
$this->setIgnoreMailQueue(TRUE);
$this->setMarkers($previewMarker);
}
/** @var StandaloneView $emailView */
......
......@@ -43,7 +43,7 @@ class ControlViewHelper extends AbstractViewHelper {
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('table', 'string', 'The table to control', TRUE);
$this->registerArgument('row', 'array', 'The row of the record', TRUE);
$this->registerArgument('row', 'mixed', 'The row of the record', TRUE);
$this->registerArgument('clipboard', 'bool', 'If true, renders the clipboard controls', FALSE);
}
......
......@@ -43,7 +43,7 @@ class IconViewHelper extends AbstractViewHelper {
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('table', 'string', 'The table for the icon', TRUE);
$this->registerArgument('row', 'array', 'The row of the record', TRUE);
$this->registerArgument('row', 'mixed', 'The row of the record', TRUE);
$this->registerArgument('clickMenu', 'bool', 'Render a clickMenu around the icon', FALSE, TRUE);
}
......
......@@ -70,7 +70,7 @@ class PaginateController extends \TYPO3\CMS\Fluid\ViewHelpers\Be\Widget\Controll
if ($this->currentPage > 1) {
$query->setOffset($this->offset);
}
$modifiedObjects = $query->execute();
$modifiedObjects = $query->execute(TRUE);
}
}
$this->view->assign(
......
......@@ -8,7 +8,6 @@
<f:flashMessages />
<f:if condition="!{pages}">
<f:render partial="Queue/Filter" arguments="{filterFields: filterFields, filters: filters, languages: languages, templatesFilter: templatesFilter, selectedTemplateFilter: selectedTemplateFilter, selectedExtensionFilter: selectedExtensionFilter}" />
<f:if condition="{queue -> f:count()} > 0">
<f:then>
<div class="panel panel-default recordlist">
<div class="table-fit">
......@@ -95,7 +94,6 @@
<f:else>
<f:render partial="Queue/Empty" />
</f:else>
</f:if>
</f:if>
<f:if condition="{pages}">
......
......@@ -6,7 +6,7 @@
"license": [
"GPL-2.0-or-later"
],
"version": "5.4.1",
"version": "5.4.2",
"repositories": [
{
"type": "composer",
......
......@@ -8,7 +8,7 @@ $EM_CONF['sg_mail'] = [
'title' => 'Mail Templates',
'description' => 'Mail Templates',
'category' => 'module',
'version' => '5.4.1',
'version' => '5.4.2',
'state' => 'stable',
'uploadfolder' => FALSE,
'createDirs' => '',
......
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