Skip to content
Snippets Groups Projects
Commit b38d8d02 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Refactored template blacklist to respect site root ids

parent ab54147d
No related branches found
No related tags found
1 merge request!6Feature 4 3
......@@ -96,22 +96,11 @@ class MailController extends ActionController {
$this->redirect('index', $this->session->getDataByKey('mode'));
}
$registerArray = MailTemplateService::getRegisterArray();
$extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sg_mail']);
if (isset($extensionConfiguration['excludeTemplates']) && $extensionConfiguration['excludeTemplates'] !== '') {
$excludedTemplates = GeneralUtility::trimExplode(',', $extensionConfiguration['excludeTemplates'], TRUE);
if ($excludedTemplates && count($excludedTemplates)) {
foreach ($excludedTemplates as $excludedTemplate) {
list($extensionKey, $templateName) = GeneralUtility::trimExplode('.', $excludedTemplate);
if ($extensionKey && $templateName && isset($registerArray[$extensionKey][$templateName])) {
unset($registerArray[$extensionKey][$templateName]);
}
}
}
}
$registerArray = BackendService::getWhitelistedTemplates(1);
$removeExtensionKeys = [];
foreach ($registerArray as $extensionKey => $extensionTemplates) {
if (count($extensionTemplates) === 0) {
if (\count($extensionTemplates) === 0) {
$removeExtensionKeys[] = $extensionKey;
}
}
......@@ -195,7 +184,7 @@ class MailController extends ActionController {
$templateDescription = $registerArray[$parameters['selectedExtension']][$parameters['selectedTemplate']]['description'];
if (is_array($templateDescription)) {
if (\is_array($templateDescription)) {
if ($languages[0]['isocode']) {
$templateDescription = $templateDescription[$languages[0]['isocode']];
}
......
......@@ -393,4 +393,38 @@ class BackendService {
return trim(preg_replace('/\s\s+/', ' ', strip_tags($exportString)));
}
/**
* Filter the register array to have only whitelisted templates for this domain
*
* @param int $siteRootId
* @throws \InvalidArgumentException
* @throws \BadFunctionCallException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public static function getWhitelistedTemplates($siteRootId) {
$siteRootId = (int) $siteRootId;
$registerArray = MailTemplateService::getRegisterArray();
$extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sg_mail'], []);
if (isset($extensionConfiguration['excludeTemplates']) && $extensionConfiguration['excludeTemplates'] !== '') {
$excludedTemplatesWithSiteId = GeneralUtility::trimExplode(
';', $extensionConfiguration['excludeTemplates'], TRUE
);
foreach ($excludedTemplatesWithSiteId as $currentSite) {
$currentSiteBlacklist = GeneralUtility::trimExplode(',', $currentSite, TRUE);
if ((int) $currentSiteBlacklist[0] === $siteRootId) {
foreach ($currentSiteBlacklist as $excludedTemplate) {
list($extensionKey, $templateName) = GeneralUtility::trimExplode('.', $excludedTemplate);
if ($extensionKey && $templateName && isset($registerArray[$extensionKey][$templateName])) {
unset($registerArray[$extensionKey][$templateName]);
}
}
}
}
}
return $registerArray;
}
}
......@@ -313,9 +313,27 @@
<source>Example</source>
<target>Beispiel</target>
</trans-unit>
<trans-unit id="configuration.excludeTemplates">
<source>Exclude Mail Templates:Comma-separated list of {extension_key}.{template_name}</source>
<target>Mail-Templates ausschließen:Kommagetrennte Liste von {extension_key}.{template_name}</target>
<trans-unit id="configuration.excludeTemplates" approved="yes" xml:space="preserve">
<source>Exclude Mail Templates for certain Domains:
Semicolon separated list of comma separated list with the site id and a list of templates to be excluded like: {extension_key}.{template_name}.
Example:
1, sg_mail.exampleA, sg_mail.exampleB;10, sg_mail.exampleB
In this example the templates sg_mail.exampleA, sg_mail.exampleB are excluded for the page with id = 1 and the template sg_mail.exampleB is excluded for the page with id = 2.
If the given page ids do not exist or are not site roots, the configuration is ignored.</source>
<target>Ausschließen von Mail Templates für bestimmte Domains:
Strichpunkt separierte list von Komma separierten Listen mit einer page id und einer Liste von Templates in folgender Form: {extension_key}.{template_name}.
Beispiel:
1, sg_mail.exampleA, sg_mail.exampleB;10, sg_mail.exampleB
Hier sind die Templates sg_mail.exampleA, sg_mail.exampleB ausgeschlossen für die Seite mit der page id = 1 und das Template sg_mail.exampleB ist ausgeschlossen für die Seite mit der page id = 2.
Existiert die angegebene page id nicht oder sollte die Seite keine root page sein, dann wird dieser Teil der Konfiguration nicht berücksichtigt.</target>
</trans-unit>
<trans-unit id="mlang_labels_tabdescr" approved="yes">
<source>Mail Templates</source>
......
......@@ -237,8 +237,17 @@
<trans-unit id="backend.value">
<source>Example</source>
</trans-unit>
<trans-unit id="configuration.excludeTemplates">
<source>Exclude Mail Templates:Comma-separated list of {extension_key}.{template_name}</source>
<trans-unit id="configuration.excludeTemplates" xml:space="preserve">
<source>Exclude Mail Templates for certain Domains:
Semicolon separated list of comma separated list with the site id and a list of templates to be excluded like: {extension_key}.{template_name}.
Example:
1, sg_mail.exampleA, sg_mail.exampleB;10, sg_mail.exampleB
In this example the templates sg_mail.exampleA, sg_mail.exampleB are excluded for the page with id = 1 and the template sg_mail.exampleB is excluded for the page with id = 2.
If the given page ids do not exist or are not site roots, the configuration is ignored.</source>
</trans-unit>
<trans-unit id="mlang_labels_tabdescr">
<source>Mail Templates</source>
......
# cat=general; type=string; label=LLL:EXT:sg_mail/Resources/Private/Language/locallang.xlf:configuration.excludeTemplates
excludeTemplates =
excludeTemplates =
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment