From b53755ef609fdd7fb0f4575446bb9f5750360b39 Mon Sep 17 00:00:00 2001 From: Alexander Bigga Date: Sat, 12 Jun 2021 23:00:54 +0200 Subject: [PATCH 1/3] Rename TypoScript files to current naming convention --- .editorconfig | 66 +++++++++++++++++++ .../{constants.txt => constants.typoscript} | 0 .../{setup.txt => setup.typoscript} | 2 +- ext_localconf.php | 4 +- ext_tables.php | 5 +- 5 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 .editorconfig rename Configuration/TypoScript/{constants.txt => constants.typoscript} (100%) rename Configuration/TypoScript/{setup.txt => setup.typoscript} (99%) diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..14b91260 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,66 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +# CSS-Files +[*.css] +indent_style = space +indent_size = 4 + +# HTML-Files +[*.html] +indent_style = space +indent_size = 4 + +# TMPL-Files +[*.tmpl] +indent_style = space +indent_size = 4 + +# LESS-Files +[*.less] +indent_style = space +indent_size = 4 + +# JS-Files +[*.js] +indent_style = space +indent_size = 4 + +# PHP-Files +[*.php] +indent_style = space +indent_size = 4 + +# MD-Files +[*.md] +indent_style = space +indent_size = 4 + +# ReST-Files +[*.rst] +indent_style = space +indent_size = 3 + +# TypoScript +[*.typoscript] +indent_style = space +indent_size = 4 + +# YML-Files +[{*.yml,*.yaml}] +indent_style = space +indent_size = 4 + +# package.json, composer.json or .travis.yml +[{package.json,composer.json,.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/Configuration/TypoScript/constants.txt b/Configuration/TypoScript/constants.typoscript similarity index 100% rename from Configuration/TypoScript/constants.txt rename to Configuration/TypoScript/constants.typoscript diff --git a/Configuration/TypoScript/setup.txt b/Configuration/TypoScript/setup.typoscript similarity index 99% rename from Configuration/TypoScript/setup.txt rename to Configuration/TypoScript/setup.typoscript index 12171bd5..0b53c824 100755 --- a/Configuration/TypoScript/setup.txt +++ b/Configuration/TypoScript/setup.typoscript @@ -131,7 +131,7 @@ printCal { config { disableAllHeaderCode = 1 - additionalHeaders { + additionalHeaders { 10 { header = Content-type:text/calendar; charset=utf-8; } diff --git a/ext_localconf.php b/ext_localconf.php index 080301fc..03f658c7 100755 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,7 +1,5 @@ Date: Mon, 14 Jun 2021 17:14:20 +0200 Subject: [PATCH 2/3] Introduce new TypoScript constant to keep files sent by email for debugging --- Classes/Helper/EmailHelper.php | 40 ++++++++++++++++++- Configuration/TypoScript/setup.typoscript | 5 +++ .../Partials/Subscriber/FormFields.html | 4 +- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/Classes/Helper/EmailHelper.php b/Classes/Helper/EmailHelper.php index 20e763ba..4144f3d2 100755 --- a/Classes/Helper/EmailHelper.php +++ b/Classes/Helper/EmailHelper.php @@ -67,6 +67,9 @@ public static function sendTemplateEmail( $useSimfonyMailer = true; } + // array of files to unlink after email has been sent + $unlinkFiles = []; + /** @var \TYPO3Fluid\Fluid\View\StandaloneView $emailViewHTML */ $emailViewHTML = $objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView'); $emailViewHTML->getRequest()->setControllerExtensionName('SlubEvents'); @@ -93,8 +96,7 @@ public static function sendTemplateEmail( } else { $message->setBody(EmailHelper::html2rest($emailTextHTML)); $message->addPart($emailTextHTML, 'text/html'); - } - + } // attach ics-File if ($variables['attachIcs'] == true) { @@ -117,11 +119,14 @@ public static function sendTemplateEmail( 20 ) . '-' . strtolower($templateName) . '-' . $variables['event']->getUid() . '.ics'; + GeneralUtility::writeFileToTypo3tempDir( $eventIcsFile, implode("\r\n", array_filter(explode("\r\n", $ics->render()))) ); + $unlinkFiles[] = $eventIcsFile; + // attach additionally ics as file if ($useSimfonyMailer) { $message->attachFromPath($eventIcsFile); @@ -132,6 +137,17 @@ public static function sendTemplateEmail( $message->addPart(implode("\r\n", array_filter(explode("\r\n", $ics->render()))), 'text/calendar', 'utf-8'); } + if ($variables['settings']['email']['keepLocalFilesForDebugging']) { + $debugFile = Environment::getPublicPath() . 'typo3temp/tx_slubevents/' . + substr( + preg_replace('/[^\w]/', '', strtolower($variables['nameTo'])), + 0, + 20 + ) + . '-' . strtolower($templateName) . (isset($variables['event']) ? '-' . $variables['event']->getUid() : '' ) . '.html'; + GeneralUtility::writeFileToTypo3tempDir($debugFile, $emailViewHTML->render()); + } + } // attach CSV-File if ($variables['attachCsv'] == true) { @@ -156,6 +172,8 @@ public static function sendTemplateEmail( . '-' . strtolower($templateName) . '.csv'; GeneralUtility::writeFileToTypo3tempDir($eventCsvFile, $csv->render()); + $unlinkFiles[] = $eventCsvFile; + // attach CSV-File if ($useSimfonyMailer) { $message->attachFromPath($eventCsvFile); @@ -165,8 +183,26 @@ public static function sendTemplateEmail( } } + if ($variables['settings']['email']['keepLocalFilesForDebugging']) { + $debugFile = Environment::getPublicPath() . '/typo3temp/tx_slubevents/' . + substr( + preg_replace('/[^\w]/', '', strtolower($variables['nameTo'])), + 0, + 20 + ) + . '-' . strtolower($templateName) . (isset($variables['event']) ? '-' . $variables['event']->getUid() : '' ) . '.html'; + GeneralUtility::writeFileToTypo3tempDir($debugFile, $emailTextHTML); + } + $message->send(); + // remove files from typo3temp if not kept for debuggin purpose + if (empty($variables['settings']['email']['keepLocalFilesForDebugging'])) { + foreach ($unlinkFiles as $file) { + GeneralUtility::unlink_tempfile($file); + } + } + return $message->isSent(); } diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 0b53c824..3d9efecc 100755 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -45,6 +45,11 @@ plugin.tx_slubevents { sendEmailOnEveryBooking = 0 } + email { + # Keep ICS and html files sent to contacts for debugging purpose. DON'T USE IN PRODUCTION! + keepLocalFilesForDebugging = 0 + } + # -------------- # List # -------------- diff --git a/Resources/Private/Partials/Subscriber/FormFields.html b/Resources/Private/Partials/Subscriber/FormFields.html index 900be732..f3866a81 100755 --- a/Resources/Private/Partials/Subscriber/FormFields.html +++ b/Resources/Private/Partials/Subscriber/FormFields.html @@ -33,8 +33,6 @@ * - - + + From aff6fc54a8bea83965d2510f1c32d36ad40c6456 Mon Sep 17 00:00:00 2001 From: Alexander Bigga Date: Mon, 14 Jun 2021 17:26:14 +0200 Subject: [PATCH 3/3] Update documentation --- Documentation/AdministratorManual/Index.rst | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Documentation/AdministratorManual/Index.rst b/Documentation/AdministratorManual/Index.rst index ae06445a..a5e7b883 100755 --- a/Documentation/AdministratorManual/Index.rst +++ b/Documentation/AdministratorManual/Index.rst @@ -77,6 +77,23 @@ Configure Email Handling Default ``webmaster@example.com`` +.. container:: table-row + + Property + email.keepLocalFilesForDebugging + + Data type + string + + Description + Keep files (.ics, .csv, .html) sent by email for debugging purpose. + The files are stored in :code:`typo3temp/tx_slubevents/`. + + **Do not use this setting on production environment!** + + Default + 0 - Do not keep files. + .. container:: table-row Property @@ -273,4 +290,4 @@ simply add these line to your registration form template While the property ``acceptpp`` is submitted, it's needed to be checked -to submit a valid registration. \ No newline at end of file +to submit a valid registration.