diff --git a/.project/tests/phpstan-baseline.neon b/.project/tests/phpstan-baseline.neon
index 906357462..8a6229ed9 100644
--- a/.project/tests/phpstan-baseline.neon
+++ b/.project/tests/phpstan-baseline.neon
@@ -3405,6 +3405,11 @@ parameters:
count: 1
path: ../../Classes/UserFunc/DateConverter.php
+ -
+ message: "#^Method In2code\\\\Powermail\\\\UserFunc\\\\TestForFeature\\:\\:isFeatureEnabled\\(\\) has parameter \\$arguments with no value type specified in iterable type array\\.$#"
+ count: 1
+ path: ../../Classes/UserFunc/TestForFeature.php
+
-
message: "#^Method In2code\\\\Powermail\\\\Utility\\\\ArrayUtility\\:\\:arrayMergeRecursiveOverrule\\(\\) has parameter \\$firstArray with no value type specified in iterable type array\\.$#"
count: 1
diff --git a/.project/typo3/additional.php b/.project/typo3/additional.php
index b5be9dcc4..c3acb2a3a 100644
--- a/.project/typo3/additional.php
+++ b/.project/typo3/additional.php
@@ -51,6 +51,9 @@
'sitename' => 'LOKAL: ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
'displayErrors' => 1,
'enableDeprecationLog' => 'file',
+ 'features' => [
+ 'powermailEditorsAreAllowedToSendAttachments' => true,
+ ],
'systemLogLevel' => 0,
'devIPmask' => '*',
'clearCacheSystem' => 1,
diff --git a/Classes/UserFunc/TestForFeature.php b/Classes/UserFunc/TestForFeature.php
new file mode 100644
index 000000000..7a74c2efd
--- /dev/null
+++ b/Classes/UserFunc/TestForFeature.php
@@ -0,0 +1,20 @@
+isFeatureEnabled($arguments['conditionParameters'][0])) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/Classes/Utility/ConfigurationUtility.php b/Classes/Utility/ConfigurationUtility.php
index cac0dd7ce..03baee2d1 100644
--- a/Classes/Utility/ConfigurationUtility.php
+++ b/Classes/Utility/ConfigurationUtility.php
@@ -7,6 +7,7 @@
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
+use TYPO3\CMS\Core\Configuration\Features;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\ArrayUtility as CoreArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -211,6 +212,7 @@ public static function testGdExtension(): void
*/
public static function mergeTypoScript2FlexForm(array $settings, string $typoScriptLevel = 'setup'): array
{
+ $originalSettings = $settings;
if (array_key_exists($typoScriptLevel, $settings) && array_key_exists('flexform', $settings)) {
$settings = ArrayUtility::arrayMergeRecursiveOverrule(
(array)$settings[$typoScriptLevel],
@@ -218,6 +220,16 @@ public static function mergeTypoScript2FlexForm(array $settings, string $typoScr
false,
false
);
+
+ $features = GeneralUtility::makeInstance(Features::class);
+ if ($features->isFeatureEnabled('powermailEditorsAreAllowedToSendAttachments')) {
+ if (isset($originalSettings['flexform']['receiver']['attachment'])) {
+ $settings['receiver']['attachment'] = $originalSettings['flexform']['receiver']['attachment'];
+ }
+ if (isset($originalSettings['flexform']['sender']['attachment'])) {
+ $settings['sender']['attachment'] = $originalSettings['flexform']['sender']['attachment'];
+ }
+ }
}
return $settings;
}
diff --git a/Configuration/FlexForms/FlexformPi1.xml b/Configuration/FlexForms/FlexformPi1.xml
index 81bd0b791..166a13115 100644
--- a/Configuration/FlexForms/FlexformPi1.xml
+++ b/Configuration/FlexForms/FlexformPi1.xml
@@ -211,7 +211,16 @@
1
-
+
+ USER:In2code\Powermail\UserFunc\TestForFeature->isFeatureEnabled:powermailEditorsAreAllowedToSendAttachments
+ 1
+
+
+ check
+ 0
+
+
+
@@ -252,7 +261,16 @@
1
-
+
+ USER:In2code\Powermail\UserFunc\TestForFeature->isFeatureEnabled:powermailEditorsAreAllowedToSendAttachments
+ 1
+
+
+ check
+ 0
+
+
+
diff --git a/Configuration/TSConfig/EditorsSendAttachments.typoscript b/Configuration/TSConfig/EditorsSendAttachments.typoscript
new file mode 100644
index 000000000..ee8a11c2d
--- /dev/null
+++ b/Configuration/TSConfig/EditorsSendAttachments.typoscript
@@ -0,0 +1,18 @@
+TCEFORM {
+ tt_content {
+ pi_flexform {
+ powermail_pi1 {
+ sender {
+ settings\.flexform\.sender\.attachment {
+ disabled = 1
+ }
+ }
+ receiver {
+ settings\.flexform\.receiver\.attachment {
+ disabled = 1
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/Documentation/ForAdministrators/BestPractice/SendAttachments.md b/Documentation/ForAdministrators/BestPractice/SendAttachments.md
new file mode 100644
index 000000000..74b6b30aa
--- /dev/null
+++ b/Documentation/ForAdministrators/BestPractice/SendAttachments.md
@@ -0,0 +1,57 @@
+# How to send attachments
+
+## Defined by TypoScript
+
+In versions < 12.5 it was only possible to define, whether attachments are sent or not, via TypoScript. This setting
+was used for all forms and plugins (unless you used conditions or set the value in the database).
+
+```typo3_typoscript
+plugin.tx_powermail.settings.setup {
+ reciever {
+ attachment = {$plugin.tx_powermail.settings.receiver.attachment}
+ }
+ sender {
+ attachment = {$plugin.tx_powermail.settings.sender.attachment}
+ }
+}
+```
+
+## Defined by editors
+
+Since version 12.5 it is possible, that editors define, whether attachments should be sent or not. This feature is
+"hidden" behind a feature toggle and restrictive page tsconfig settings.
+
+### Steps for activation
+
+1) Activate the feature toggle in site settings
+
+```php
+$GLOBALS['TYPO3_CONF_VARS']['SYS']['features']['powermailEditorsAreAllowedToSendAttachments'] = true;
+```
+
+2) Activate the fields in PageTSconfig
+
+Due to security reasons these fields are hidden by default, so that the admin must take an additional step. Editors
+should not get more permissions, than necessary by a feature release. ;-)
+
+```typo3_typoscript
+TCEFORM {
+ tt_content {
+ pi_flexform {
+ powermail_pi1 {
+ sender {
+ settings\.flexform\.sender\.attachment {
+ disabled = 0
+ }
+ }
+ receiver {
+ settings\.flexform\.receiver\.attachment {
+ disabled = 0
+ }
+ }
+ }
+ }
+ }
+}
+```
+
diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf
index 8b69e7f26..16eefed23 100644
--- a/Resources/Private/Language/locallang_db.xlf
+++ b/Resources/Private/Language/locallang_db.xlf
@@ -489,6 +489,9 @@
+
+
+
@@ -504,6 +507,9 @@
+
+
+
diff --git a/ext_localconf.php b/ext_localconf.php
index db76626d0..288669a7b 100644
--- a/ext_localconf.php
+++ b/ext_localconf.php
@@ -78,18 +78,17 @@
);
/**
- * ContentElementWizard for Pi1
+ * Include PageTSconfig
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'@import \'EXT:powermail/Configuration/TSConfig/ContentElementWizard.typoscript\''
);
-
- /**
- * PageTSConfig for backend mod list
- */
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'@import \'EXT:powermail/Configuration/TSConfig/WebList.typoscript\''
);
+ \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
+ '@import \'EXT:powermail/Configuration/TSConfig/EditorsSendAttachments.typoscript\''
+ );
/**
* Hook for initially filling the marker field in backend
@@ -141,4 +140,10 @@
= \In2code\Powermail\Update\PowermailPermissionUpdater::class;
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['powermailPermissionSubmodulesUpdater']
= \In2code\Powermail\Update\PowermailPermissionSubmoduleUpdater::class;
+
+ /**
+ * Feature toggle
+ */
+
+ $GLOBALS['TYPO3_CONF_VARS']['SYS']['features']['powermailEditorsAreAllowedToSendAttachments'] ??= false;
});