diff --git a/CHANGELOG.md b/CHANGELOG.md index ebe01ea..ec1e4b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 4.0.1 (2025-07-22) +[TASK] use Configuration/page.tsconfig for template overrides +[TASK] raise version number to 4.0.1 + +## 4.0.0 (2025-06-16) +[TASK] TYPO3 13.4 compatibility + ## 3.0.0 (2022-12-14) [TASK] Add actions + small php fixes diff --git a/Classes/Hooks/RecordListGetTableHook.php b/Classes/Hooks/RecordListGetTableHook.php deleted file mode 100644 index 6cac530..0000000 --- a/Classes/Hooks/RecordListGetTableHook.php +++ /dev/null @@ -1,63 +0,0 @@ - - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ -use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList; -use TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface; -use TYPO3\CMS\Backend\Utility\BackendUtility; - -/** - * Hook to modify the getTable query for Powermail mails and answers - */ -class RecordListGetTableHook implements RecordListGetTableHookInterface -{ - - /** - * modifies the DB list query - * - * @param string $table The current database table - * @param integer $pageId The record's page ID - * @param string $additionalWhereClause An additional WHERE clause - * @param string $selectedFieldsList Comma separated list of selected fields - * @param DatabaseRecordList $parentObject Parent localRecordList object - * @return void - */ - public function getDBlistQuery($table, $pageId, &$additionalWhereClause, &$selectedFieldsList, &$parentObject): void - { - if ($GLOBALS['BE_USER']->isAdmin()) { - // early return if user is admin - return; - } - - if ($table === 'tx_powermail_domain_model_answer' || $table === 'tx_powermail_domain_model_mail') { - // 16 = permission to edit content on the page - if (!$GLOBALS['BE_USER']->doesUserHaveAccess(BackendUtility::getRecord('pages', $pageId), 16)) { - // user does not have permission to edit contents on this page, so we add a clause not to show any records - $additionalWhereClause = 'AND 1=2'; - } - } - } - -} diff --git a/Classes/ViewHelpers/UserHasWritePermissionForPageViewHelper.php b/Classes/ViewHelpers/UserHasWritePermissionForPageViewHelper.php index d42746f..47cc806 100644 --- a/Classes/ViewHelpers/UserHasWritePermissionForPageViewHelper.php +++ b/Classes/ViewHelpers/UserHasWritePermissionForPageViewHelper.php @@ -2,19 +2,16 @@ namespace Visol\PowermailExportperms\ViewHelpers; -use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3\CMS\Backend\Utility\BackendUtility; -use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Http\ServerRequestFactory; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; class UserHasWritePermissionForPageViewHelper extends AbstractViewHelper { - - /** - * @return bool - */ public function render(): bool { - $currentPageUid = (int)GeneralUtility::_GET('id'); + $request = ServerRequestFactory::fromGlobals(); + $currentPageUid = (int) ($request->getQueryParams()['id'] ?? 0); // 16 = permission to edit content on the page if (!$GLOBALS['BE_USER']->doesUserHaveAccess(BackendUtility::getRecord('pages', $currentPageUid), 16)) { // user does not have permission to edit contents on this page diff --git a/Configuration/page.tsconfig b/Configuration/page.tsconfig new file mode 100644 index 0000000..2933e20 --- /dev/null +++ b/Configuration/page.tsconfig @@ -0,0 +1,2 @@ +# override backend templates. Config is setting $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] +templates.in2code/powermail.1752658658 = visol/powermail-exportperms:Resources/Private/TemplateOverrides diff --git a/README.md b/README.md index e5d0bb2..0c2ed0a 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,22 @@ Powermail Export Permissions ============================ By default, an editor who has read access to a page in TYPO3, access to Powermail mails and answers and permissions to - use the Powermail module can read and export the submitted form data. If you're working with a page where every editor - can see every page but only edit those he has permissions for, this might not be desirable. +use the Powermail module can read and export the submitted form data. If you're working with a page where every editor +can see every page but only edit those he has permissions for, this might not be desirable. This simple extension hooks into the Powermail and the List module and check for write access to the page. If there is - no write access, the mails cannot be exported. +no write access, the mails cannot be exported. ## Compatibility and Maintenance This package is currently maintained for the following versions: -| TYPO3 Version | Package Version | Branch | Maintained | -|-----------------------|-----------------|---------|---------------| -| TYPO3 11.5.x | 3.x | master | Yes | -| TYPO3 8.7.x | 2.x | - | No | -| TYPO3 6.2.x | 1.x | - | No | +| TYPO3 Version | Package Version | Branch | Maintained | +|---------------|-----------------|--------|------------| +| TYPO3 13.4.x | 4.x | master | Yes | +| TYPO3 11.5.x | 3.x | v11 | No | +| TYPO3 8.7.x | 2.x | - | No | +| TYPO3 6.2.x | 1.x | - | No | Installation ------------ @@ -31,43 +32,22 @@ Usage The list view doesn't display records from the tables tx_powermail_domain_model_mails and tx_powermail_domain_model answers if the user doesn't have at least content editing permissions on a page. This is done by using a hook in the TYPO3 core. -To use this functionality in the Powermail backend module, copy the backend templates to your template extension (or anywhere you want) -and configure the module to use them: +The template `typo3/vendor/in2code/powermail/Resources/Private/Templates/Module/List.html` will be overridden by +[powermail_exportperms/Resources/Private/TemplateOverrides/Templates/Module/List.html](./Resources/Private/TemplateOverrides/Templates/Module/List.html) - module.tx_powermail { - view { - templateRootPath = path/to/Templates - partialRootPath = path/to/Partials - layoutRootPath = path/to/Layouts - } - } - -Then, import the namespace of the extension's ViewHelper: - - {namespace pmep=Visol\PowermailExportperms\ViewHelpers} - -And wrap whatever you want to show and hide depending on the editing rights with an if condition using the UserHasWritePermissionForPage ViewHelper: - - - - [Show stuff] - - - Access denied. - - +by `$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] .= chr(10) . 'templates.in2code/powermail.1752658658 = visol/powermail-exportperms:Resources/Private/TemplateOverrides';` defined in [ext_localconf.php](./ext_localconf.php) Security considerations ----------------------- Be aware that this extension merely hides records from the user. It does not prevent fetching the records with other views - providing database listing or by manipulating URL parameters from the edit/show record functionalities in the TYPO3 backend. +providing database listing or by manipulating URL parameters from the edit/show record functionalities in the TYPO3 backend. Do not use the extension if you are obliged to make the records completely inaccessible for a user. Requirements ------------ -* TYPO3 8.7 LTS+ -* Tested with Powermail 5.3 +* TYPO3 13 LTS+ +* Tested with Powermail 13 diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf new file mode 100644 index 0000000..b087061 --- /dev/null +++ b/Resources/Private/Language/de.locallang.xlf @@ -0,0 +1,12 @@ + + + +
+ + + Only visible if editor owns appropriate edit rights on the selected page. + Nur sichtbar für Editor*innen, die über Schreibrechte auf der ausgewählten Seite verfügen. + + + + diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf new file mode 100644 index 0000000..0ecbe6f --- /dev/null +++ b/Resources/Private/Language/locallang.xlf @@ -0,0 +1,14 @@ + + + +
+ + + Only visible if editor owns appropriate edit rights on the selected page. + + + Only visible if editor owns appropriate edit rights on the selected page. + + + + diff --git a/Resources/Private/TemplateOverrides/Templates/Module/List.html b/Resources/Private/TemplateOverrides/Templates/Module/List.html new file mode 100644 index 0000000..7b64b2d --- /dev/null +++ b/Resources/Private/TemplateOverrides/Templates/Module/List.html @@ -0,0 +1,81 @@ +{namespace pmep=Visol\PowermailExportperms\ViewHelpers} + + + + +Show Backend Module: Powermail List + + + + + + + +

+ +
+
+ + + +
+
+
+ +
+
+
+ + + Filter Area + + + + + +
+ + + + + + + +

+

+
+
+
+
+ +
+
+ + + +
+
+
Datensatzinformationen
+
+ +
+
+
+
+
+ +
+ + diff --git a/Resources/Public/Icons/Extension.gif b/Resources/Public/Icons/Extension.gif deleted file mode 100644 index 1a832d4..0000000 Binary files a/Resources/Public/Icons/Extension.gif and /dev/null differ diff --git a/Resources/Public/Icons/Extension.svg b/Resources/Public/Icons/Extension.svg new file mode 100644 index 0000000..e1b4537 --- /dev/null +++ b/Resources/Public/Icons/Extension.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/composer.json b/composer.json index f4d2fd7..618e088 100644 --- a/composer.json +++ b/composer.json @@ -1,22 +1,24 @@ { - "name": "visol/powermail-exportperms", - "type": "typo3-cms-extension", - "description": "Powermail Export Permissions", - "homepage": "https://github.com/visol/ext-powermail_exportperms", - "license": [ - "GPL-2.0-or-later" - ], - "extra": { - "typo3/cms": { - "extension-key": "powermail_exportperms" - } - }, - "autoload": { - "psr-4": { - "Visol\\PowermailExportperms\\": "Classes" - } - }, - "require": { - "typo3/cms-core": "^11.5" - } + "name": "visol/powermail-exportperms", + "version": "4.0.1", + "type": "typo3-cms-extension", + "description": "Powermail Export Permissions", + "homepage": "https://github.com/visol/ext-powermail_exportperms", + "license": [ + "GPL-2.0-or-later" + ], + "extra": { + "typo3/cms": { + "extension-key": "powermail_exportperms" + } + }, + "autoload": { + "psr-4": { + "Visol\\PowermailExportperms\\": "Classes" + } + }, + "require": { + "typo3/cms-core": "^13.4", + "in2code/powermail": "^13.0" + } } diff --git a/ext_icon.gif b/ext_icon.gif deleted file mode 100644 index 1a832d4..0000000 Binary files a/ext_icon.gif and /dev/null differ diff --git a/ext_localconf.php b/ext_localconf.php index 98acef8..01be305 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,8 +1,5 @@