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/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/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 95% rename from Configuration/TypoScript/setup.txt rename to Configuration/TypoScript/setup.typoscript index 12171bd5..3d9efecc 100755 --- a/Configuration/TypoScript/setup.txt +++ 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 # -------------- @@ -131,7 +136,7 @@ printCal { config { disableAllHeaderCode = 1 - additionalHeaders { + additionalHeaders { 10 { header = Content-type:text/calendar; charset=utf-8; } 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. 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 @@ * - - + + 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 @@