From f3b037af17808d36fc094b4ebb754fea46959db0 Mon Sep 17 00:00:00 2001 From: Torsten Oppermann <torsten@sgalinski.de> Date: Fri, 4 Aug 2017 16:04:22 +0200 Subject: [PATCH] [TASK] Validation of cc & bcc mails --- Classes/Controller/MailController.php | 29 ++++++++ Resources/Private/Language/de.locallang.xlf | 8 +++ Resources/Private/Language/locallang.xlf | 6 ++ Resources/Private/Templates/Queue/Index.html | 75 +++++++++++--------- 4 files changed, 84 insertions(+), 34 deletions(-) diff --git a/Classes/Controller/MailController.php b/Classes/Controller/MailController.php index b914c8a4..808a213d 100644 --- a/Classes/Controller/MailController.php +++ b/Classes/Controller/MailController.php @@ -203,6 +203,35 @@ class MailController extends ActionController { * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException */ public function sendTestMailAction(array $parameters = []) { + foreach ($parameters['templates'] as $parameter) { + $ccAddresses = GeneralUtility::trimExplode(',', $parameter['cc']); + if (count($ccAddresses) > 0) { + + foreach ($ccAddresses as $ccAddress) { + if (!filter_var($ccAddress, FILTER_VALIDATE_EMAIL) && trim($ccAddress) !== '') { + $message = LocalizationUtility::translate('backend.error_cc', 'sg_mail'); + $this->addFlashMessage($message, '', FlashMessage::WARNING); + + $arguments = $this->request->getArguments(); + $this->redirect('index', NULL, NULL, $arguments); + } + } + } + + $bccAddresses = GeneralUtility::trimExplode(',', $parameter['bcc']); + if (count($bccAddresses) > 0) { + foreach ($bccAddresses as $bccAddress) { + if (!filter_var($bccAddress, FILTER_VALIDATE_EMAIL) && trim($bccAddress) !== '') { + $message = LocalizationUtility::translate('backend.error_bcc', 'sg_mail'); + $this->addFlashMessage($message, '', FlashMessage::WARNING); + + $arguments = $this->request->getArguments(); + $this->redirect('index', NULL, NULL, $arguments); + } + } + } + } + foreach ($parameters['templates'] as $key => $template) { BackendService::saveTemplate( (int) GeneralUtility::_GP('id'), $parameters['selectedExtension'], $parameters['selectedTemplate'], diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index 568c5bcf..92ec1cd2 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -49,6 +49,14 @@ <source>Queue Entry Date</source> <target>Erstellungsdatum</target> </trans-unit> + <trans-unit id="backend.error_bcc" approved="yes"> + <source>The bcc addresses are invalid</source> + <target>Ungültige bcc Adressen</target> + </trans-unit> + <trans-unit id="backend.error_cc" approved="yes"> + <source>The cc addresses are invalid</source> + <target>Ungültige cc Adressen</target> + </trans-unit> <trans-unit id="backend.failure_mail" approved="yes"> <source>There was an error when sending the preview email. Please check your configuration.</source> <target>Ein Fehler ist aufgetreten. Bitte überprüfen Sie die Konfiguration.</target> diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index ea7044a9..6166d70d 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -39,6 +39,12 @@ <trans-unit id="backend.entry_date"> <source>Queue Entry Date</source> </trans-unit> + <trans-unit id="backend.error_bcc"> + <source>The bcc addresses are invalid</source> + </trans-unit> + <trans-unit id="backend.error_cc"> + <source>The cc addresses are invalid</source> + </trans-unit> <trans-unit id="backend.failure_mail"> <source>There was an error when sending the preview email. Please check your configuration.</source> </trans-unit> diff --git a/Resources/Private/Templates/Queue/Index.html b/Resources/Private/Templates/Queue/Index.html index 10f44499..a986a7d0 100644 --- a/Resources/Private/Templates/Queue/Index.html +++ b/Resources/Private/Templates/Queue/Index.html @@ -28,50 +28,57 @@ <tbody> <f:for each="{paginatedMails}" as="mail"> {sgm:backend.editOnClick(table: 'tx_sgmail_domain_model_mail', uid: mail.uid) -> sgm:set(name: 'editOnClick') -> f:format.raw()} - <tr data-uid="{mail.uid}"> - <td nowrap="nowrap" class="col-icon"> - <f:format.raw> - <sgm:backend.icon table="tx_sgmail_domain_model_mail" row="{mail}" /> - </f:format.raw> - </td> - <td> - <span>{mail.from_address}</span> - <br> - <span>{mail.to_address}</span> - </td> - <td> - <span><f:format.crop maxCharacters="40" append="...">{mail.mail_subject}</f:format.crop></span> - </td> - <td> - <span><f:format.date format="d.m.Y h:i">{mail.crdate}</f:format.date></span> - <br> - <f:if condition="{mail.last_sending_time} != 0"> - <span><f:format.date format="d.m.Y h:i">{mail.last_sending_time}</f:format.date></span> - </f:if> - </td> - <td nowrap="nowrap" class="col-control"> - <f:format.raw> - <sgm:backend.control table="tx_sgmail_domain_model_mail" row="{mail}" /> - </f:format.raw> - </td> - <td> - <f:link.action class="btn btn-default btn-send-now" controller="Queue" action="sendMail" arguments="{uid: mail.uid, selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}"> + <f:if condition="{mail.sent}"> + <f:then> + <tr data-uid="{mail.uid}"> + </f:then> + <f:else> + <tr data-uid="{mail.uid}" style="background-color: #C8C8C8;"> + </f:else> + </f:if> + <td nowrap="nowrap" class="col-icon"> + <f:format.raw> + <sgm:backend.icon table="tx_sgmail_domain_model_mail" row="{mail}" /> + </f:format.raw> + </td> + <td> + <span>{mail.from_address}</span> + <br> + <span>{mail.to_address}</span> + </td> + <td> + <span><f:format.crop maxCharacters="40" append="...">{mail.mail_subject}</f:format.crop></span> + </td> + <td> + <span><f:format.date format="d.m.Y h:i">{mail.crdate}</f:format.date></span> + <br> + <f:if condition="{mail.last_sending_time} != 0"> + <span><f:format.date format="d.m.Y h:i">{mail.last_sending_time}</f:format.date></span> + </f:if> + </td> + <td nowrap="nowrap" class="col-control"> + <f:format.raw> + <sgm:backend.control table="tx_sgmail_domain_model_mail" row="{mail}" /> + </f:format.raw> + </td> + <td> + <f:link.action class="btn btn-default btn-send-now" controller="Queue" action="sendMail" arguments="{uid: mail.uid, selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}"> <span class="t3js-icon icon icon-size-small icon-state-default actions-document-import-t3d"> <span class="icon-markup"> <img src="/typo3/sysext/core/Resources/Public/Icons/T3Icons/actions/actions-document-import-t3d.svg" width="16" height="16"> </span> </span> - <f:translate key="backend.send_now" /> - </f:link.action> - <a class="btn btn-default btn-toggle" data-uid="{mail.uid}"> + <f:translate key="backend.send_now" /> + </f:link.action> + <a class="btn btn-default btn-toggle" data-uid="{mail.uid}"> <span class="t3js-icon icon icon-size-small icon-state-default actions-document-view"> <span class="icon-markup"> <img src="/typo3/sysext/core/Resources/Public/Icons/T3Icons/actions/actions-document-view.svg" width="16" height="16"> </span> </span> - <f:translate key="backend.showBody" /> - </a> - </td> + <f:translate key="backend.showBody" /> + </a> + </td> </tr><!-- Modal --> <div class="modal fade" id="toggle-{mail.uid}" tabindex="-1" role="dialog" aria-labelledby="login-modal-label"> <div class="modal-dialog" role="document"> -- GitLab