From 3914e7aa1f298e29ff0b2b124b08277410390764 Mon Sep 17 00:00:00 2001 From: Oliver Bartsch Date: Mon, 21 Jun 2021 15:37:28 +0200 Subject: [PATCH] [BUGFIX] Respect TSconfig when adding page translations to recordlist Since #27471 it's possible to hide all or specific tables within the recordlist. However, the special "page translations" table did not respect those settings, making it impossible to hide this table. This is now fixed by respecting the corresponding settings. Resolves: #94386 Releases: master, 10.4 Change-Id: I33575624ade9ecf840b6fde713a7d3214d6506be Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69535 Tested-by: core-ci Tested-by: Benni Mack Tested-by: Christian Kuhn Tested-by: Jochen Tested-by: Oliver Bartsch Reviewed-by: Benni Mack Reviewed-by: Christian Kuhn Reviewed-by: Jochen Reviewed-by: Oliver Bartsch --- .../Controller/RecordListController.php | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/typo3/sysext/recordlist/Classes/Controller/RecordListController.php b/typo3/sysext/recordlist/Classes/Controller/RecordListController.php index 2804468b2aa8..84338156e0c4 100644 --- a/typo3/sysext/recordlist/Classes/Controller/RecordListController.php +++ b/typo3/sysext/recordlist/Classes/Controller/RecordListController.php @@ -265,18 +265,20 @@ function editRecords(table,idList,addParams,CBflag) { $beforeOutput = ''; $output = ''; - // Show the selector to add page translations and the list of translations of the current page - // but only when in "default" mode + // Show the selector to add page translations, but only when in "default" mode. + // If not disabled via module TSconfig and the user is allowed, also show the page translations table. if ($this->id && !$search_field && !$cmd && !$table) { $beforeOutput .= $this->languageSelector($request->getAttribute('normalizedParams')->getRequestUri()); - $pageTranslationsDatabaseRecordList = clone $dblist; - $pageTranslationsDatabaseRecordList->listOnlyInSingleTableMode = false; - $pageTranslationsDatabaseRecordList->disableSingleTableView = true; - $pageTranslationsDatabaseRecordList->deniedNewTables = ['pages']; - $pageTranslationsDatabaseRecordList->hideTranslations = ''; - $pageTranslationsDatabaseRecordList->setLanguagesAllowedForUser($this->siteLanguages); - $pageTranslationsDatabaseRecordList->showOnlyTranslatedRecords(true); - $output .= $pageTranslationsDatabaseRecordList->getTable('pages', $this->id); + if ($this->showPageTranslations()) { + $pageTranslationsDatabaseRecordList = clone $dblist; + $pageTranslationsDatabaseRecordList->listOnlyInSingleTableMode = false; + $pageTranslationsDatabaseRecordList->disableSingleTableView = true; + $pageTranslationsDatabaseRecordList->deniedNewTables = ['pages']; + $pageTranslationsDatabaseRecordList->hideTranslations = ''; + $pageTranslationsDatabaseRecordList->setLanguagesAllowedForUser($this->siteLanguages); + $pageTranslationsDatabaseRecordList->showOnlyTranslatedRecords(true); + $output .= $pageTranslationsDatabaseRecordList->getTable('pages', $this->id); + } } // search box toolbar @@ -699,6 +701,22 @@ protected function getShortcutTitle(array $arguments): string )); } + protected function showPageTranslations(): bool + { + if (!$this->getBackendUserAuthentication()->check('tables_select', 'pages')) { + return false; + } + + if (isset($this->modTSconfig['pages.']['hideTable'])) { + return !$this->modTSconfig['pages.']['hideTable']; + } + + $hideTables = $this->modTSconfig['hideTables'] ?? ''; + return ($GLOBALS['TCA']['pages']['ctrl']['hideTable'] ?? false) + && $hideTables !== '*' + && !in_array('pages', GeneralUtility::trimExplode(',', $hideTables), true); + } + protected function htmlResponse(string $html): ResponseInterface { $response = $this->responseFactory->createResponse()