diff --git a/typo3/sysext/adminpanel/Classes/Middleware/AdminPanelInitiator.php b/typo3/sysext/adminpanel/Classes/Middleware/AdminPanelInitiator.php index b0dba87b80d19467da6f59b1a2fc7bbbc0576a0b..e4ee084c951fdec965e34fc0207a29bc7f2171a8 100644 --- a/typo3/sysext/adminpanel/Classes/Middleware/AdminPanelInitiator.php +++ b/typo3/sysext/adminpanel/Classes/Middleware/AdminPanelInitiator.php @@ -47,7 +47,7 @@ class AdminPanelInitiator implements MiddlewareInterface // Initialize admin panel since simulation settings are required here $beUser = $GLOBALS['BE_USER']; // set legacy config - $beUser->extAdminConfig = $beUser->getTSConfigProp('admPanel'); + $beUser->extAdminConfig = $beUser->getTSConfig()['admPanel.'] ?? []; $adminPanelConfiguration = $beUser->extAdminConfig; if (isset($adminPanelConfiguration['enable.'])) { foreach ($adminPanelConfiguration['enable.'] as $value) { diff --git a/typo3/sysext/adminpanel/Classes/Modules/AbstractModule.php b/typo3/sysext/adminpanel/Classes/Modules/AbstractModule.php index 2dbb5d93988146714b913a1f9597cef377b60748..a66fa8f21e7a74046bf5aa7a9ca1e93f10890a4a 100644 --- a/typo3/sysext/adminpanel/Classes/Modules/AbstractModule.php +++ b/typo3/sysext/adminpanel/Classes/Modules/AbstractModule.php @@ -39,7 +39,7 @@ abstract class AbstractModule implements AdminPanelModuleInterface public function __construct() { - $this->mainConfiguration = $this->getBackendUser()->getTSConfigProp('admPanel'); + $this->mainConfiguration = $this->getBackendUser()->getTSConfig()['admPanel.'] ?? []; } /** diff --git a/typo3/sysext/adminpanel/Classes/Modules/EditModule.php b/typo3/sysext/adminpanel/Classes/Modules/EditModule.php index a6cbbdf349d295ba74a1d86844148a34793c0fe4..56e194ad67ff8541bcd3fec2d79ec8624a47d944 100644 --- a/typo3/sysext/adminpanel/Classes/Modules/EditModule.php +++ b/typo3/sysext/adminpanel/Classes/Modules/EditModule.php @@ -74,11 +74,8 @@ class EditModule extends AbstractModule */ private function getPageModule(): string { - $newPageModule = \trim( - (string)$this->getBackendUser() - ->getTSConfigVal('options.overridePageModule') - ); - return BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout'; + $pageModule = \trim($this->getBackendUser()->getTSConfig()['options.']['overridePageModule'] ?? ''); + return BackendUtility::isModuleSetInTBE_MODULES($pageModule) ? $pageModule : 'web_layout'; } /** diff --git a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php index bd123e0afe52799bba4d18825227dc6e0c5a2664..e79f2dee80469f999d6634ddefef29e821f6a207 100644 --- a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php +++ b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php @@ -46,11 +46,12 @@ class ClearCacheToolbarItem implements ToolbarItemInterface public function __construct() { $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/ClearCacheMenu'); - $backendUser = $this->getBackendUser(); - + $isAdmin = $this->getBackendUser()->isAdmin(); + $userTsConfig = $this->getBackendUser()->getTSConfig(); $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); + // Clear all page-related caches - if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.pages')) { + if ($isAdmin || $userTsConfig['options.']['clearCache.']['pages'] ?? false) { $this->cacheActions[] = [ 'id' => 'pages', 'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:flushPageCachesTitle', @@ -64,7 +65,9 @@ class ClearCacheToolbarItem implements ToolbarItemInterface // Clearing of all caches is only shown if explicitly enabled via TSConfig // or if BE-User is admin and the TSconfig explicitly disables the possibility for admins. // This is useful for big production systems where admins accidentally could slow down the system. - if ($backendUser->getTSConfigVal('options.clearCache.all') || ($backendUser->isAdmin() && $backendUser->getTSConfigVal('options.clearCache.all') !== '0')) { + if ($userTsConfig['options.']['clearCache.']['all'] ?? false + || ($isAdmin && (bool)($userTsConfig['options.']['clearCache.']['all'] ?? true)) + ) { $this->cacheActions[] = [ 'id' => 'all', 'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:flushAllCachesTitle2', @@ -97,7 +100,7 @@ class ClearCacheToolbarItem implements ToolbarItemInterface return true; } foreach ($this->optionValues as $value) { - if ($backendUser->getTSConfigVal('options.clearCache.' . $value)) { + if ($backendUser->getTSConfig()['options.']['clearCache.'][$value] ?? false) { return true; } } diff --git a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php index 1607a3f9894aa45c593b7947fd18e311b5e1a129..f98979480fb93f2fcfb65d83cafca38d10043cd5 100644 --- a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php +++ b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php @@ -125,7 +125,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface */ public function checkAccess() { - return (bool)$this->getBackendUser()->getTSConfigVal('options.enableBookmarks'); + return (bool)($this->getBackendUser()->getTSConfig()['options.']['enableBookmarks'] ?? false); } /** @@ -392,7 +392,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface $languageService = $this->getLanguageService(); $backendUser = $this->getBackendUser(); // Groups from TSConfig - $bookmarkGroups = $backendUser->getTSConfigProp('options.bookmarkGroups'); + $bookmarkGroups = $backendUser->getTSConfig()['options.']['bookmarkGroups.'] ?? []; if (is_array($bookmarkGroups) && !empty($bookmarkGroups)) { foreach ($bookmarkGroups as $groupId => $label) { if (!empty($label)) { diff --git a/typo3/sysext/backend/Classes/Clipboard/Clipboard.php b/typo3/sysext/backend/Classes/Clipboard/Clipboard.php index a2a5588bc816e082908ba07a57ee1f52aceccd99..5d83e015c529b70379a5b004cdcf89bebb50b4a3 100644 --- a/typo3/sysext/backend/Classes/Clipboard/Clipboard.php +++ b/typo3/sysext/backend/Classes/Clipboard/Clipboard.php @@ -114,13 +114,10 @@ class Clipboard */ public function initializeClipboard() { + $userTsConfig = $this->getBackendUser()->getTSConfig(); // Get data - $clipData = $this->getBackendUser()->getModuleData('clipboard', $this->getBackendUser()->getTSConfigVal('options.saveClipboard') ? '' : 'ses'); - // NumberTabs - $clNP = $this->getBackendUser()->getTSConfigVal('options.clipboardNumberPads'); - if (MathUtility::canBeInterpretedAsInteger($clNP) && $clNP >= 0) { - $this->numberTabs = MathUtility::forceIntegerInRange($clNP, 0, 20); - } + $clipData = $this->getBackendUser()->getModuleData('clipboard', $userTsConfig['options.']['saveClipboard'] ? '' : 'ses'); + $this->numberTabs = MathUtility::forceIntegerInRange((int)($userTsConfig['options.']['clipboardNumberPads'] ?? 3), 0, 20); // Resets/reinstates the clipboard pads $this->clipData['normal'] = is_array($clipData['normal']) ? $clipData['normal'] : []; for ($a = 1; $a <= $this->numberTabs; $a++) { diff --git a/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/AbstractProvider.php b/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/AbstractProvider.php index c0ed264f0230f354f2ba8312e9ce0c1122162d5a..2e93d4bcfae89f5ab543dd8a051b0b98d6777cfc 100644 --- a/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/AbstractProvider.php +++ b/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/AbstractProvider.php @@ -144,7 +144,11 @@ class AbstractProvider implements ProviderInterface protected function initDisabledItems() { $TSkey = $this->table . ($this->context ? '.' . $this->context : ''); - $this->disabledItems = GeneralUtility::trimExplode(',', $this->backendUser->getTSConfigVal('options.contextMenu.table.' . $TSkey . '.disableItems'), true); + $this->disabledItems = GeneralUtility::trimExplode( + ',', + $this->backendUser->getTSConfig()['options.']['contextMenu.']['table.'][$TSkey . '.']['disableItems'] ?? '', + true + ); } /** diff --git a/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/PageProvider.php b/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/PageProvider.php index 14896173bf16e1518ed7b1315c2720f6ed1966d3..12161050d9ec58390cebd373e6804b45f9b4220d 100644 --- a/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/PageProvider.php +++ b/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/PageProvider.php @@ -402,7 +402,7 @@ class PageProvider extends RecordProvider protected function canClearCache(): bool { return !$this->isRoot() - && ($this->backendUser->isAdmin() || $this->backendUser->getTSConfigVal('options.clearCache.pages')); + && ($this->backendUser->isAdmin() || $this->backendUser->getTSConfig()['options.']['clearCache.']['pages'] ?? false); } /** diff --git a/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/RecordProvider.php b/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/RecordProvider.php index 5675dcc88a24952b551f2c6fe9bdadf18772c636..51898b12856fa2e11bf3a984be65cdbda4fe6b19 100644 --- a/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/RecordProvider.php +++ b/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/RecordProvider.php @@ -460,9 +460,8 @@ class RecordProvider extends AbstractProvider */ protected function canShowHistory(): bool { - $showHistoryTS = $this->backendUser->getTSConfig('options.showHistory'); - $showHistory = (bool)trim($showHistoryTS['properties'][$this->table] ?? $showHistoryTS['value'] ?? '1'); - return $showHistory; + $userTsConfig = $this->backendUser->getTSConfig(); + return (bool)(\trim($userTsConfig['options.']['showHistory.'][$this->table] ?? $userTsConfig['options.']['showHistory'] ?? '1')); } /** diff --git a/typo3/sysext/backend/Classes/Controller/BackendController.php b/typo3/sysext/backend/Classes/Controller/BackendController.php index c8a02dcd595d122e4abe6cac2512905f7eae2785..62b713fb33ba663172f6359d8b58ab0ed903aa19 100644 --- a/typo3/sysext/backend/Classes/Controller/BackendController.php +++ b/typo3/sysext/backend/Classes/Controller/BackendController.php @@ -391,7 +391,7 @@ class BackendController $this->pageRenderer->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat); // If another page module was specified, replace the default Page module with the new one - $newPageModule = trim($beUser->getTSConfigVal('options.overridePageModule')); + $newPageModule = trim($beUser->getTSConfig()['options.']['overridePageModule'] ?? ''); $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout'; if (!$beUser->check('modules', $pageModule)) { $pageModule = ''; @@ -432,6 +432,7 @@ class BackendController protected function handlePageEditing() { $beUser = $this->getBackendUser(); + $userTsConfig = $this->getBackendUser()->getTSConfig(); // EDIT page: $editId = preg_replace('/[^[:alnum:]_]/', '', GeneralUtility::_GET('edit')); if ($editId) { @@ -474,8 +475,8 @@ class BackendController window.setTimeout("top.loadEditId(' . (int)$editRecord['uid'] . ');", 500); '; // Checking page edit parameter: - if (!$beUser->getTSConfigVal('options.bookmark_onEditId_dontSetPageTree')) { - $bookmarkKeepExpanded = $beUser->getTSConfigVal('options.bookmark_onEditId_keepExistingExpanded'); + if (!($userTsConfig['options.']['bookmark_onEditId_dontSetPageTree'] ?? false)) { + $bookmarkKeepExpanded = (bool)($userTsConfig['options.']['bookmark_onEditId_keepExistingExpanded'] ?? false); // Expanding page tree: BackendUtility::openPageTree((int)$editRecord['pid'], !$bookmarkKeepExpanded); } diff --git a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php index af7879e40710d36641e65d23323f29784a6390f1..1293665aa9c7e58e918adf899c4786a411936a29 100644 --- a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php +++ b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php @@ -647,7 +647,7 @@ class EditDocumentController $tce->setControl($parsedBody['control'] ?? $queryParams['control'] ?? []); // Set default values specific for the user - $TCAdefaultOverride = $beUser->getTSConfigProp('TCAdefaults'); + $TCAdefaultOverride = $beUser->getTSConfig()['TCAdefaults.'] ?? null; if (is_array($TCAdefaultOverride)) { $tce->setDefaultsFromUserTS($TCAdefaultOverride); } diff --git a/typo3/sysext/backend/Classes/Controller/LoginController.php b/typo3/sysext/backend/Classes/Controller/LoginController.php index 782cc2fb3b882737af9453368a0797045ade11fc..43d4611ad9399b766db8abee5228f43f9884f4bb 100644 --- a/typo3/sysext/backend/Classes/Controller/LoginController.php +++ b/typo3/sysext/backend/Classes/Controller/LoginController.php @@ -309,7 +309,8 @@ class LoginController implements LoggerAwareInterface */ protected function checkRedirect(ServerRequestInterface $request): void { - if (empty($this->getBackendUserAuthentication()->user['uid'])) { + $backendUser = $this->getBackendUserAuthentication(); + if (empty($backendUser->user['uid'])) { return; } @@ -331,7 +332,7 @@ class LoginController implements LoggerAwareInterface // try it once again - that might be needed for auto login $this->redirectToURL = 'index.php?commandLI=setCookie'; } - $redirectToUrl = (string)$this->getBackendUserAuthentication()->getTSConfigVal('auth.BE.redirectToURL'); + $redirectToUrl = (string)($backendUser->getTSConfig()['auth.']['BE.']['redirectToURL'] ?? ''); if (empty($redirectToUrl)) { // Based on the interface we set the redirect script $parsedBody = $request->getParsedBody(); @@ -351,8 +352,8 @@ class LoginController implements LoggerAwareInterface $interface = ''; } // store interface - $this->getBackendUserAuthentication()->uc['interfaceSetup'] = $interface; - $this->getBackendUserAuthentication()->writeUC(); + $backendUser->uc['interfaceSetup'] = $interface; + $backendUser->writeUC(); $formProtection = FormProtectionFactory::get(); if (!$formProtection instanceof BackendFormProtection) { diff --git a/typo3/sysext/backend/Classes/Controller/NewRecordController.php b/typo3/sysext/backend/Classes/Controller/NewRecordController.php index feb55690e6ddc68235dbef483443d933be719846..76daa150ff31d8baeceac3f317428284155acc7f 100644 --- a/typo3/sysext/backend/Classes/Controller/NewRecordController.php +++ b/typo3/sysext/backend/Classes/Controller/NewRecordController.php @@ -337,15 +337,14 @@ class NewRecordController // Page-selection permission clause (reading) $this->perms_clause = $beUser->getPagePermsClause(Permission::PAGE_SHOW); // This will hide records from display - it has nothing to do with user rights!! - if ($pidList = $beUser->getTSConfigVal('options.hideRecords.pages')) { - if (!empty($pidList)) { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) - ->getQueryBuilderForTable('pages'); - $this->perms_clause .= ' AND ' . $queryBuilder->expr()->notIn( - 'pages.uid', - GeneralUtility::intExplode(',', $pidList) - ); - } + $pidList = $beUser->getTSConfig()['options.']['hideRecords.']['pages'] ?? ''; + if (!empty($pidList)) { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) + ->getQueryBuilderForTable('pages'); + $this->perms_clause .= ' AND ' . $queryBuilder->expr()->notIn( + 'pages.uid', + GeneralUtility::intExplode(',', $pidList) + ); } // Setting GPvars: $parsedBody = $request->getParsedBody(); diff --git a/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php b/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php index 50ca222a19b9fa1eaaf0fcc7a2ed2fe79cb0d22f..8f7ab9cee2dc5647582fd4d048cbe760412d7fa2 100644 --- a/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php +++ b/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php @@ -181,7 +181,7 @@ class NewMultiplePagesController $dataHandler = GeneralUtility::makeInstance(DataHandler::class); // Set default TCA values specific for the user $backendUser = $this->getBackendUser(); - $tcaDefaultOverride = $backendUser->getTSConfigProp('TCAdefaults'); + $tcaDefaultOverride = $backendUser->getTSConfig()['TCAdefaults.'] ?? null; if (is_array($tcaDefaultOverride)) { $dataHandler->setDefaultsFromUserTS($tcaDefaultOverride); } diff --git a/typo3/sysext/backend/Classes/Controller/Page/TreeController.php b/typo3/sysext/backend/Classes/Controller/Page/TreeController.php index 397c14ce419beb8abed9fa2bb2095ff5cf79b7e8..6b0762c8512713bcbe327b6c459dc0b680a4fb4d 100644 --- a/typo3/sysext/backend/Classes/Controller/Page/TreeController.php +++ b/typo3/sysext/backend/Classes/Controller/Page/TreeController.php @@ -106,7 +106,7 @@ class TreeController public function __construct() { $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); - $this->useNavTitle = (bool)$this->getBackendUser()->getTSConfigVal('options.pageTree.showNavTitle'); + $this->useNavTitle = (bool)($this->getBackendUser()->getTSConfig()['options.']['pageTree.']['showNavTitle'] ?? false); } /** @@ -136,6 +136,7 @@ class TreeController */ protected function getDokTypes(): array { + $backendUser = $this->getBackendUser(); $doktypeLabelMap = []; foreach ($GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'] as $doktypeItemConfig) { if ($doktypeItemConfig[1] === '--div--') { @@ -143,10 +144,10 @@ class TreeController } $doktypeLabelMap[$doktypeItemConfig[1]] = $doktypeItemConfig[0]; } - $doktypes = GeneralUtility::intExplode(',', $this->getBackendUser()->getTSConfigVal('options.pageTree.doktypesToShowInNewPageDragArea'), true); + $doktypes = GeneralUtility::intExplode(',', $backendUser->getTSConfig()['options.']['pageTree.']['doktypesToShowInNewPageDragArea'] ?? '', true); $output = []; - $allowedDoktypes = GeneralUtility::intExplode(',', $this->getBackendUser()->groupData['pagetypes_select'], true); - $isAdmin = $this->getBackendUser()->isAdmin(); + $allowedDoktypes = GeneralUtility::intExplode(',', $backendUser->groupData['pagetypes_select'], true); + $isAdmin = $backendUser->isAdmin(); // Early return if backend user may not create any doktype if (!$isAdmin && empty($allowedDoktypes)) { return $output; @@ -174,11 +175,12 @@ class TreeController */ public function fetchDataAction(ServerRequestInterface $request): ResponseInterface { - $this->hiddenRecords = GeneralUtility::intExplode(',', $this->getBackendUser()->getTSConfigVal('options.hideRecords.pages'), true); - $this->backgroundColors = $this->getBackendUser()->getTSConfigProp('options.pageTree.backgroundColor'); - $this->addIdAsPrefix = (bool)$this->getBackendUser()->getTSConfigVal('options.pageTree.showPageIdWithTitle'); - $this->addDomainName = (bool)$this->getBackendUser()->getTSConfigVal('options.pageTree.showDomainNameWithTitle'); - $this->showMountPathAboveMounts = (bool)$this->getBackendUser()->getTSConfigVal('options.pageTree.showPathAboveMounts'); + $userTsConfig = $this->getBackendUser()->getTSConfig(); + $this->hiddenRecords = GeneralUtility::intExplode(',', $userTsConfig['options.']['hideRecords.']['pages'] ?? '', true); + $this->backgroundColors = $userTsConfig['options.']['pageTree.']['backgroundColor.'] ?? []; + $this->addIdAsPrefix = (bool)($userTsConfig['options.']['pageTree.']['showPageIdWithTitle'] ?? false); + $this->addDomainName = (bool)($userTsConfig['options.']['pageTree.']['showDomainNameWithTitle'] ?? false); + $this->showMountPathAboveMounts = (bool)($userTsConfig['options.']['pageTree.']['showPathAboveMounts'] ?? false); $backendUserConfiguration = GeneralUtility::makeInstance(BackendUserConfiguration::class); $this->expandedState = $backendUserConfiguration->get('BackendComponents.States.Pagetree'); if (is_object($this->expandedState->stateHash)) { diff --git a/typo3/sysext/backend/Classes/Controller/SimpleDataHandlerController.php b/typo3/sysext/backend/Classes/Controller/SimpleDataHandlerController.php index 535ee4fdf00838e17715713a52947b99ce6b8df9..68a18eb7ffb497379816b06fce5778ebdeb0320b 100644 --- a/typo3/sysext/backend/Classes/Controller/SimpleDataHandlerController.php +++ b/typo3/sysext/backend/Classes/Controller/SimpleDataHandlerController.php @@ -228,7 +228,7 @@ class SimpleDataHandlerController if ($beUser->uc['neverHideAtCopy']) { $this->tce->neverHideAtCopy = 1; } - $TCAdefaultOverride = $beUser->getTSConfigProp('TCAdefaults'); + $TCAdefaultOverride = $beUser->getTSConfig()['TCAdefaults.'] ?? null; if (is_array($TCAdefaultOverride)) { $this->tce->setDefaultsFromUserTS($TCAdefaultOverride); } diff --git a/typo3/sysext/backend/Classes/Domain/Repository/Module/BackendModuleRepository.php b/typo3/sysext/backend/Classes/Domain/Repository/Module/BackendModuleRepository.php index 6c87305bd5a9b90a1c6c58be28329b7165c74c64..95f6204c5a8a35fce04682ba5a9ee089a26587c2 100644 --- a/typo3/sysext/backend/Classes/Domain/Repository/Module/BackendModuleRepository.php +++ b/typo3/sysext/backend/Classes/Domain/Repository/Module/BackendModuleRepository.php @@ -15,8 +15,11 @@ namespace TYPO3\CMS\Backend\Domain\Repository\Module; */ use TYPO3\CMS\Backend\Module\ModuleLoader; +use TYPO3\CMS\Backend\Routing\UriBuilder; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Imaging\IconRegistry; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -211,16 +214,6 @@ class BackendModuleRepository implements \TYPO3\CMS\Core\SingletonInterface } } - /** - * Return language service instance - * - * @return \TYPO3\CMS\Core\Localization\LanguageService - */ - protected function getLanguageService() - { - return $GLOBALS['LANG']; - } - /** * loads the module menu from the moduleloader based on $GLOBALS['TBE_MODULES'] * and compiles an array with all the data needed for menu etc. @@ -240,8 +233,7 @@ class BackendModuleRepository implements \TYPO3\CMS\Core\SingletonInterface // Unset modules that are meant to be hidden from the menu. $loadedModules = $this->removeHiddenModules($loadedModules); - /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ - $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $dummyScript = (string)$uriBuilder->buildUriFromRoute('dummy'); foreach ($loadedModules as $moduleName => $moduleData) { $moduleLink = ''; @@ -317,22 +309,21 @@ class BackendModuleRepository implements \TYPO3\CMS\Core\SingletonInterface */ protected function removeHiddenModules($loadedModules) { - $hiddenModules = $GLOBALS['BE_USER']->getTSConfig('options.hideModules'); + $userTsConfig = $this->getBackendUser()->getTSConfig(); // Hide modules if set in userTS. - if (!empty($hiddenModules['value'])) { - $hiddenMainModules = explode(',', $hiddenModules['value']); - foreach ($hiddenMainModules as $hiddenMainModule) { - unset($loadedModules[trim($hiddenMainModule)]); - } + $hiddenMainModules = GeneralUtility::trimExplode(',', $userTsConfig['options.']['hideModules'] ?? '', true); + foreach ($hiddenMainModules as $hiddenMainModule) { + unset($loadedModules[$hiddenMainModule]); } // Hide sub-modules if set in userTS. - if (!empty($hiddenModules['properties']) && is_array($hiddenModules['properties'])) { - foreach ($hiddenModules['properties'] as $mainModuleName => $subModules) { - $hiddenSubModules = explode(',', $subModules); + $hiddenModules = $userTsConfig['options.']['hideModules.'] ?? []; + if (is_array($hiddenModules)) { + foreach ($hiddenModules as $mainModuleName => $subModules) { + $hiddenSubModules = GeneralUtility::trimExplode(',', $subModules, true); foreach ($hiddenSubModules as $hiddenSubModule) { - unset($loadedModules[$mainModuleName]['sub'][trim($hiddenSubModule)]); + unset($loadedModules[$mainModuleName]['sub'][$hiddenSubModule]); } } } @@ -359,4 +350,22 @@ class BackendModuleRepository implements \TYPO3\CMS\Core\SingletonInterface } return ''; } + + /** + * Return language service instance + * + * @return LanguageService + */ + protected function getLanguageService() + { + return $GLOBALS['LANG']; + } + + /** + * @return BackendUserAuthentication + */ + protected function getBackendUser(): BackendUserAuthentication + { + return $GLOBALS['BE_USER']; + } } diff --git a/typo3/sysext/backend/Classes/Form/FormResultCompiler.php b/typo3/sysext/backend/Classes/Form/FormResultCompiler.php index ad9031cf74ca037e2ef7218c4d366f7000aad5dd..dbb2471e6ffccdf95b3e7c318f47f2e18d60e050 100644 --- a/typo3/sysext/backend/Classes/Form/FormResultCompiler.php +++ b/typo3/sysext/backend/Classes/Form/FormResultCompiler.php @@ -218,18 +218,18 @@ class FormResultCompiler } } $pageRenderer->loadJquery(); - $beUserAuth = $this->getBackendUserAuthentication(); + $backendUser = $this->getBackendUserAuthentication(); // define the window size of the element browser etc. $popupWindowWidth = 800; $popupWindowHeight = 600; - $popupWindowSize = trim($beUserAuth->getTSConfigVal('options.popupWindowSize')); + $popupWindowSize = trim($backendUser->getTSConfig()['options.']['popupWindowSize'] ?? ''); if (!empty($popupWindowSize)) { list($popupWindowWidth, $popupWindowHeight) = GeneralUtility::intExplode('x', $popupWindowSize); } // define the window size of the popups within the RTE - $rtePopupWindowSize = trim($beUserAuth->getTSConfigVal('options.rte.popupWindowSize')); + $rtePopupWindowSize = trim($backendUser->getTSConfig()['options.']['rte.']['popupWindowSize'] ?? ''); if (!empty($rtePopupWindowSize)) { list($rtePopupWindowWidth, $rtePopupWindowHeight) = GeneralUtility::trimExplode('x', $rtePopupWindowSize); } @@ -238,7 +238,7 @@ class FormResultCompiler // Make textareas resizable and flexible ("autogrow" in height) $textareaSettings = [ - 'autosize' => (bool)$beUserAuth->uc['resizeTextareas_Flexible'], + 'autosize' => (bool)$backendUser->uc['resizeTextareas_Flexible'], 'RTEPopupWindow' => [ 'width' => $rtePopupWindowWidth, 'height' => $rtePopupWindowHeight diff --git a/typo3/sysext/backend/Classes/Tree/View/AbstractTreeView.php b/typo3/sysext/backend/Classes/Tree/View/AbstractTreeView.php index 5ff1f4fae04c66c40803bba82d34f883516eea9f..4a1b18d57833469b5f69020b23ed33da11a46f10 100644 --- a/typo3/sysext/backend/Classes/Tree/View/AbstractTreeView.php +++ b/typo3/sysext/backend/Classes/Tree/View/AbstractTreeView.php @@ -1070,7 +1070,9 @@ abstract class AbstractTreeView foreach ($rootline as $rootlineElement) { $record = BackendUtility::getRecordWSOL('pages', $rootlineElement['uid'], 'title, nav_title', '', true, true); $text = $record['title']; - if ((bool)$this->getBackendUser()->getTSConfigVal('options.pageTree.showNavTitle') && trim($record['nav_title'] ?? '') !== '') { + if ((bool)($this->getBackendUser()->getTSConfig()['options.']['pageTree.']['showNavTitle'] ?? false) + && trim($record['nav_title'] ?? '') !== '' + ) { $text = $record['nav_title']; } $path[] = htmlspecialchars($text); diff --git a/typo3/sysext/backend/Classes/Tree/View/BrowseTreeView.php b/typo3/sysext/backend/Classes/Tree/View/BrowseTreeView.php index b1f775df8f8efeac53fc8a7833d431b2c2b70e6b..27b843a215f37611025352b9021d542ae0c3c1dd 100644 --- a/typo3/sysext/backend/Classes/Tree/View/BrowseTreeView.php +++ b/typo3/sysext/backend/Classes/Tree/View/BrowseTreeView.php @@ -81,17 +81,19 @@ class BrowseTreeView extends AbstractTreeView */ public function init($clause = '', $orderByFields = '') { + $backendUser = $this->getBackendUser(); // This will hide records from display - it has nothing to do with user rights!! $clauseExcludePidList = ''; - if ($pidList = $this->getBackendUser()->getTSConfigVal('options.hideRecords.pages')) { + $pidList = $backendUser->getTSConfig()['options.']['hideRecords.']['pages'] ?? ''; + if (!empty($pidList)) { if ($pidList = implode(',', GeneralUtility::intExplode(',', $pidList))) { $clauseExcludePidList = ' AND pages.uid NOT IN (' . $pidList . ')'; } } // This is very important for making trees of pages: Filtering out deleted pages, pages with no access to and sorting them correctly: - parent::init(' AND deleted=0 AND sys_language_uid=0 AND ' . $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW) . ' ' . $clause . $clauseExcludePidList, 'sorting'); + parent::init(' AND deleted=0 AND sys_language_uid=0 AND ' . $backendUser->getPagePermsClause(Permission::PAGE_SHOW) . ' ' . $clause . $clauseExcludePidList, 'sorting'); $this->title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; - $this->MOUNTS = $this->getBackendUser()->returnWebmounts(); + $this->MOUNTS = $backendUser->returnWebmounts(); if ($pidList) { // Remove mountpoint if explicitly set in options.hideRecords.pages (see above) $hideList = explode(',', $pidList); @@ -148,7 +150,9 @@ class BrowseTreeView extends AbstractTreeView } else { $title = parent::getTitleStr($row, $titleLen); } - if (!empty($row['is_siteroot']) && $this->getBackendUser()->getTSConfigVal('options.pageTree.showDomainNameWithTitle')) { + if (!empty($row['is_siteroot']) + && $this->getBackendUser()->getTSConfig()['options.']['pageTree.']['showDomainNameWithTitle'] ?? false + ) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_domain'); $row = $queryBuilder ->select('domainName', 'sorting') diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index 770c2200e6a0e1a664a64edc5eb08903e7a9a260..2c74eee16b26f1a6e8c3ed3ae52d6ea647f8bf7f 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -2687,9 +2687,9 @@ class BackendUtility { // Look if a fixed preview language should be added: $beUser = static::getBackendUserAuthentication(); - $viewLanguageOrder = $beUser->getTSConfigVal('options.view.languageOrder'); + $viewLanguageOrder = (string)($beUser->getTSConfig()['options.']['view.']['languageOrder'] ?? ''); - if ((string)$viewLanguageOrder !== '') { + if (!empty($viewLanguageOrder)) { $suffix = ''; // Find allowed languages (if none, all are allowed!) $allowedLanguages = null; @@ -2747,15 +2747,12 @@ class BackendUtility if (!empty($rootLine)) { $urlParts = parse_url($domain); $protocol = GeneralUtility::getIndpEnv('TYPO3_SSL') ? 'https' : 'http'; - $previewDomainConfig = static::getBackendUserAuthentication()->getTSConfig( - 'TCEMAIN.previewDomain', - self::getPagesTSconfig($pageId) - ); - if ($previewDomainConfig['value']) { - if (strpos($previewDomainConfig['value'], '://') !== false) { - list($protocol, $domainName) = explode('://', $previewDomainConfig['value']); + $previewDomainConfig = self::getPagesTSconfig($pageId)['TCEMAIN.']['previewDomain'] ?? ''; + if (!empty($previewDomainConfig)) { + if (strpos($previewDomainConfig, '://') !== false) { + list($protocol, $domainName) = explode('://', $previewDomainConfig); } else { - $domainName = $previewDomainConfig['value']; + $domainName = $previewDomainConfig; } } else { $domainName = self::firstDomainRecord($rootLine); diff --git a/typo3/sysext/backend/Classes/View/PageLayoutView.php b/typo3/sysext/backend/Classes/View/PageLayoutView.php index 3aa39969bee70b3439027403152a602afaf6094e..ecdb09f6ae4c7c44d656f8019ac9edc39fd93997 100644 --- a/typo3/sysext/backend/Classes/View/PageLayoutView.php +++ b/typo3/sysext/backend/Classes/View/PageLayoutView.php @@ -1955,9 +1955,10 @@ class PageLayoutView implements LoggerAwareInterface */ public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = false, $langMode = false, $dragDropEnabled = false) { + $backendUser = $this->getBackendUser(); $out = ''; // If show info is set...; - if ($this->tt_contentConfig['showInfo'] && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) { + if ($this->tt_contentConfig['showInfo'] && $backendUser->recordEditAccessInternals('tt_content', $row)) { // Render control panel for the element: if ($this->tt_contentConfig['showCommands'] && $this->doEdit) { // Edit content element: @@ -1981,7 +1982,7 @@ class PageLayoutView implements LoggerAwareInterface $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled']; if ($hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField] && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude'] - || $this->getBackendUser()->check('non_exclude_fields', 'tt_content:' . $hiddenField)) + || $backendUser->check('non_exclude_fields', 'tt_content:' . $hiddenField)) ) { if ($row[$hiddenField]) { $value = 0; @@ -1997,8 +1998,11 @@ class PageLayoutView implements LoggerAwareInterface . $this->iconFactory->getIcon('actions-edit-' . strtolower($label), Icon::SIZE_SMALL)->render() . '</a>'; } // Delete - $disableDeleteTS = $this->getBackendUser()->getTSConfig('options.disableDelete'); - $disableDelete = (bool)trim($disableDeleteTS['properties']['tt_content'] ?? $disableDeleteTS['value']); + $disableDelete = (bool)\trim( + $backendUser->getTSConfig()['options.']['disableDelete.']['tt_content'] + ?? $backendUser->getTSConfig()['options.']['disableDelete'] + ?? '0' + ); if (!$disableDelete) { $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1'; $refCountMsg = BackendUtility::referenceCount( @@ -2020,7 +2024,7 @@ class PageLayoutView implements LoggerAwareInterface . ' data-button-close-text="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')) . '"' . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('deleteItem')) . '">' . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>'; - if ($out && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) { + if ($out && $backendUser->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) { $out = '<div class="btn-group btn-group-sm" role="group">' . $out . '</div>'; } else { $out = ''; @@ -3093,11 +3097,9 @@ class PageLayoutView implements LoggerAwareInterface ->expr(); $permsClause = $expressionBuilder->andX($backendUser->getPagePermsClause(Permission::PAGE_SHOW)); // This will hide records from display - it has nothing to do with user rights!! - if ($pidList = $backendUser->getTSConfigVal('options.hideRecords.pages')) { - $pidList = GeneralUtility::intExplode(',', $pidList, true); - if (!empty($pidList)) { - $permsClause->add($expressionBuilder->notIn('pages.uid', $pidList)); - } + $pidList = GeneralUtility::intExplode(',', $backendUser->getTSConfig()['options.']['hideRecords.']['pages'] ?? '', true); + if (!empty($pidList)) { + $permsClause->add($expressionBuilder->notIn('pages.uid', $pidList)); } $this->perms_clause = (string)$permsClause; diff --git a/typo3/sysext/backend/Tests/Unit/Controller/LoginControllerTest.php b/typo3/sysext/backend/Tests/Unit/Controller/LoginControllerTest.php index 06d42d8abb4bb959984a91837f145fe455e60d21..0dc16ad454a7b1dde7fbaf7703e42f113150d7fb 100644 --- a/typo3/sysext/backend/Tests/Unit/Controller/LoginControllerTest.php +++ b/typo3/sysext/backend/Tests/Unit/Controller/LoginControllerTest.php @@ -168,7 +168,13 @@ class LoginControllerTest extends UnitTestCase { $GLOBALS['LANG'] = ($this->prophesize(LanguageService::class))->reveal(); $authenticationProphecy = $this->prophesize(BackendUserAuthentication::class); - $authenticationProphecy->getTSConfigVal('auth.BE.redirectToURL')->willReturn('http://example.com'); + $authenticationProphecy->getTSConfig()->willReturn([ + 'auth.' => [ + 'BE.' => [ + 'redirectToURL' => 'http://example.com' + ] + ] + ]); $authenticationProphecy->writeUC()->willReturn(); $authenticationProphecy->getSessionData('formProtectionSessionToken')->willReturn('foo'); $GLOBALS['BE_USER'] = $authenticationProphecy->reveal(); @@ -197,7 +203,13 @@ class LoginControllerTest extends UnitTestCase { $GLOBALS['LANG'] = $this->prophesize(LanguageService::class)->reveal(); $authenticationProphecy = $this->prophesize(BackendUserAuthentication::class); - $authenticationProphecy->getTSConfigVal('auth.BE.redirectToURL')->willReturn('http://example.com'); + $authenticationProphecy->getTSConfig()->willReturn([ + 'auth.' => [ + 'BE.' => [ + 'redirectToURL' => 'http://example.com' + ] + ] + ]); $authenticationProphecy->writeUC()->willReturn(); $this->prophesizeFormProtection(); $GLOBALS['BE_USER'] = $authenticationProphecy->reveal(); @@ -228,7 +240,13 @@ class LoginControllerTest extends UnitTestCase { $GLOBALS['LANG'] = $this->prophesize(LanguageService::class)->reveal(); $authenticationProphecy = $this->prophesize(BackendUserAuthentication::class); - $authenticationProphecy->getTSConfigVal('auth.BE.redirectToURL')->willReturn('http://example.com'); + $authenticationProphecy->getTSConfig()->willReturn([ + 'auth.' => [ + 'BE.' => [ + 'redirectToURL' => 'http://example.com' + ] + ] + ]); $authenticationProphecy->writeUC()->willReturn(); $GLOBALS['BE_USER'] = $authenticationProphecy->reveal(); $this->prophesizeFormProtection(); diff --git a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php index 112e5d510c7776ff55c56b159e21ffc23d6df113..9724263d99325ce47189f343826c2a3667740f49 100644 --- a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php +++ b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php @@ -929,8 +929,8 @@ class BackendUserAuthentication extends AbstractUserAuthentication */ public function mayMakeShortcut() { - return $this->getTSConfigVal('options.enableBookmarks') - && !$this->getTSConfigVal('options.mayNotCreateEditBookmarks'); + return $this->getTSConfig()['options.']['enableBookmarks'] ?? false + && !($this->getTSConfig()['options.']['mayNotCreateEditBookmarks'] ?? false); } /** @@ -1242,9 +1242,11 @@ class BackendUserAuthentication extends AbstractUserAuthentication * @param string $objectString Object string, eg. "somestring.someproperty.somesubproperty * @return string The value for that object string (object path) * @see getTSConfig() + * @deprecated since core v9, will be removed with core v10 */ public function getTSConfigVal($objectString) { + trigger_error('This getTSConfigVal() will be removed in TYPO3 v10. Use getTSConfig() instead.', E_USER_DEPRECATED); $TSConf = $this->getTSConfig($objectString); return $TSConf['value']; } @@ -1255,9 +1257,11 @@ class BackendUserAuthentication extends AbstractUserAuthentication * @param string $objectString Object string, eg. "somestring.someproperty.somesubproperty * @return array The properties for that object string (object path) - if any * @see getTSConfig() + * @deprecated since core v9, will be removed with core v10 */ public function getTSConfigProp($objectString) { + trigger_error('This getTSConfigProp() will be removed in TYPO3 v10. Use getTSConfig() instead.', E_USER_DEPRECATED); $TSConf = $this->getTSConfig($objectString); return $TSConf['properties']; } @@ -1304,7 +1308,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication public function jsConfirmation($bitmask) { try { - $alertPopupsSetting = trim((string)$this->getTSConfig('options.alertPopups')['value']); + $alertPopupsSetting = trim((string)($this->getTSConfig()['options.']['alertPopups'] ?? '')); $alertPopup = JsConfirmation::cast($alertPopupsSetting === '' ? null : (int)$alertPopupsSetting); } catch (InvalidEnumerationValueException $e) { $alertPopup = new JsConfirmation(); @@ -1401,7 +1405,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication } // Processing webmounts // Admin's always have the root mounted - if ($this->isAdmin() && !$this->getTSConfigVal('options.dontMountAdminMounts')) { + if ($this->isAdmin() && !($this->getTSConfig()['options.']['dontMountAdminMounts'] ?? false)) { $this->dataLists['webmount_list'] = '0,' . $this->dataLists['webmount_list']; } // The lists are cleaned for duplicates @@ -1696,7 +1700,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication } // Read-only file mounts - $readOnlyMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints')); + $readOnlyMountPoints = \trim($this->getTSConfig()['options.']['folderTree.']['altElementBrowserMountPoints'] ?? ''); if ($readOnlyMountPoints) { // We cannot use the API here but need to fetch the default storage record directly // to not instantiate it (which directly applies mount points) before all mount points are resolved! @@ -1948,7 +1952,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication */ public function getDefaultUploadFolder($pid = null, $table = null, $field = null) { - $uploadFolder = $this->getTSConfigVal('options.defaultUploadFolder'); + $uploadFolder = $this->getTSConfig()['options.']['defaultUploadFolder'] ?? ''; if ($uploadFolder) { $uploadFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($uploadFolder); } else { @@ -2062,9 +2066,9 @@ class BackendUserAuthentication extends AbstractUserAuthentication $this->setWorkspace($this->user['workspace_id']); // Limiting the DB mountpoints if there any selected in the workspace record $this->initializeDbMountpointsInWorkspace(); - if ($allowed_languages = $this->getTSConfigVal('options.workspaces.allowed_languages.' . $this->workspace)) { - $this->groupData['allowed_languages'] = $allowed_languages; - $this->groupData['allowed_languages'] = GeneralUtility::uniqueList($this->groupData['allowed_languages']); + $allowed_languages = $this->getTSConfig()['options.']['workspaces.']['allowed_languages.'][$this->workspace] ?? ''; + if (!empty($allowed_languages)) { + $this->groupData['allowed_languages'] = GeneralUtility::uniqueList($allowed_languages); } } @@ -2486,8 +2490,8 @@ This is a dump of the failures: { $isValid = true; if ($GLOBALS['TYPO3_CONF_VARS']['BE']['enabledBeUserIPLock']) { - $IPList = $this->getTSConfigVal('options.lockToIP'); - if (trim($IPList)) { + $IPList = trim($this->getTSConfig()['options.']['lockToIP'] ?? ''); + if (!empty($IPList)) { $isValid = GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $IPList); } } @@ -2560,7 +2564,7 @@ This is a dump of the failures: $this->uc = array_merge( $this->uc_default, (array)$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUC'], - GeneralUtility::removeDotsFromTS((array)$this->getTSConfigProp('setup.default')), + GeneralUtility::removeDotsFromTS((array)($this->getTSConfig()['setup.']['default.'] ?? [])), $originalUc ); $this->overrideUC(); @@ -2595,7 +2599,7 @@ This is a dump of the failures: */ public function overrideUC() { - $this->uc = array_merge((array)$this->uc, (array)$this->getTSConfigProp('setup.override')); + $this->uc = array_merge((array)$this->uc, (array)($this->getTSConfig()['setup.']['override.'] ?? [])); } /** diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 41111aced56f84b973916b0acfb666c88460809f..49c72db81dfeeee54dd9122172cd2956c53554ac 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -8582,9 +8582,10 @@ class DataHandler implements LoggerAwareInterface if (is_object($this->BE_USER)) { $this->BE_USER->writelog(3, 1, 0, 0, 'User %s has cleared the cache (cacheCmd=%s)', [$this->BE_USER->user['username'], $cacheCmd]); } + $userTsConfig = $this->BE_USER->getTSConfig(); switch (strtolower($cacheCmd)) { case 'pages': - if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.pages')) { + if ($this->admin || $userTsConfig['options.']['clearCache.']['pages'] ?? false) { $this->getCacheManager()->flushCachesInGroup('pages'); } break; @@ -8592,7 +8593,9 @@ class DataHandler implements LoggerAwareInterface // allow to clear all caches if the TS config option is enabled or the option is not explicitly // disabled for admins (which could clear all caches by default). The latter option is useful // for big production sites where it should be possible to restrict the cache clearing for some admins. - if ($this->BE_USER->getTSConfigVal('options.clearCache.all') || ($this->admin && $this->BE_USER->getTSConfigVal('options.clearCache.all') !== '0')) { + if ($userTsConfig['options.']['clearCache.']['all'] ?? false + || ($this->admin && (bool)($userTsConfig['options.']['clearCache.']['all'] ?? true)) + ) { $this->getCacheManager()->flushCaches(); GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionForTable('cache_treelist') @@ -8610,7 +8613,7 @@ class DataHandler implements LoggerAwareInterface . ' instead or call the group cache clearing of "system" group directly via a custom extension.', E_USER_DEPRECATED ); - if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.system')) { + if ($this->admin || $userTsConfig['options.']['clearCache.']['system'] ?? false) { $this->getCacheManager()->flushCachesInGroup('system'); } break; diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84993-DeprecateSomeTSconfigRelatedMethods.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84993-DeprecateSomeTSconfigRelatedMethods.rst new file mode 100644 index 0000000000000000000000000000000000000000..6a881f3eb66ab7f756d76bb1b584feaad87f514c --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84993-DeprecateSomeTSconfigRelatedMethods.rst @@ -0,0 +1,74 @@ +.. include:: ../../Includes.txt + +============================================================= +Deprecation: #84993 - Deprecate some TSconfig related methods +============================================================= + +See :issue:`84993` + +Description +=========== + +Some user TSconfig related methods have been deprecated: + +* :php:`TYPO3\CMS\core\Authentication\BackendUserAuthentication->getTSConfigVal()` +* :php:`TYPO3\CMS\core\Authentication\BackendUserAuthentication->getTSConfigProp()` + + +Impact +====== + +Calling the above methods logs a deprecation message. + + +Affected Installations +====================== + +Extensions with backend modules may call these methods. The extension scanner +will find affected code occurrences in extensions. + + +Migration +========= + +Change the calls to use :php:`BackendUserAuthentication->getTSConfig()` instead, it +comes with a slightly changed return syntax. + +:php:`getTSConfig()` without arguments simply returns the entire user TSconfig as array, similar to other +methods that return parsed TypoScript arrays. The examples below show some imaginary user TSConfig TypoScript, +the full parsed array returned by :php:`getTSConfig()` and some typical access patterns with fallback. Note +it's almost always useful to use the null coalescence :php:`??` operator for a fallback value to suppress +PHP notice level warnings:: + + // Incoming user TSconfig: + // options.someToggle = 1 + // options.somePartWithSubToggles = foo + // options.somePartWithSubToggles.aValue = bar + + // Parsed array returned by getTSConfig(), note the dot if a property has sub keys: + // [ + // 'options.' => [ + // 'someToggle' => '1', + // 'somePartWithSubToggles' => 'foo', + // 'somePartWithSubToggles.' => [ + // 'aValue' => 'bar', + // ], + // ], + // ], + $userTsConfig = $backendUserAuthentication->getTSConfig(): + + // Typical call to retrieve a sanitized value: + $isToggleEnabled = (bool)($userTsConfig['options.']['someToggle'] ?? false); + + // And to retrieve a sub set, note the dot at the end: + $subArray = $userTsConfig['options.']['somePartWithSubToggles.'] ?? []; + + // Switch an old getTSConfigVal() to getTSConfig(), note the parenthesis: + $value = (bool)$backendUser->getTSConfigVal('options.someToggle'); + $value = (bool)($backendUser->getTSConfig()['options.']['someToggle] ?? false); + + // Switch an old getTSConfigProp() to getTSConfig(), note the parenthesis and the trailing dot: + $value = (array)$backendUser->getTSConfigProp('options.somePartWithSubToggles'); + $value = (array)($backendUser->getTSConfig()['options.']['somePartWithSubToggles.'] ?? []); + +.. index:: Backend, PHP-API, TSConfig, FullyScanned \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Unit/Authentication/BackendUserAuthenticationTest.php b/typo3/sysext/core/Tests/Unit/Authentication/BackendUserAuthenticationTest.php index 7dc762f9e89bbec881616d225c041e4fe57d8582..6fc2e5195181ae305bcafc4df1a1a9902d2c4cbe 100644 --- a/typo3/sysext/core/Tests/Unit/Authentication/BackendUserAuthenticationTest.php +++ b/typo3/sysext/core/Tests/Unit/Authentication/BackendUserAuthenticationTest.php @@ -723,8 +723,11 @@ class BackendUserAuthenticationTest extends UnitTestCase $subject = $this->getMockBuilder(BackendUserAuthentication::class) ->setMethods(['getTSConfig']) ->getMock(); - $subject->method('getTSConfig')->with('options.alertPopups')->willReturn(['value' => 1]); - + $subject->method('getTSConfig')->with()->willReturn([ + 'options.' => [ + 'alertPopups' => 1 + ], + ]); $this->assertTrue($subject->jsConfirmation(JsConfirmation::TYPE_CHANGE)); $this->assertFalse($subject->jsConfirmation(JsConfirmation::COPY_MOVE_PASTE)); } @@ -738,8 +741,11 @@ class BackendUserAuthenticationTest extends UnitTestCase $subject = $this->getMockBuilder(BackendUserAuthentication::class) ->setMethods(['getTSConfig']) ->getMock(); - $subject->method('getTSConfig')->with('options.alertPopups')->willReturn(['value' => 3]); - + $subject->method('getTSConfig')->with()->willReturn([ + 'options.' => [ + 'alertPopups' => 3 + ], + ]); $this->assertTrue($subject->jsConfirmation(JsConfirmation::TYPE_CHANGE)); $this->assertTrue($subject->jsConfirmation(JsConfirmation::COPY_MOVE_PASTE)); } @@ -760,8 +766,11 @@ class BackendUserAuthenticationTest extends UnitTestCase $subject = $this->getMockBuilder(BackendUserAuthentication::class) ->setMethods(['getTSConfig']) ->getMock(); - $subject->method('getTSConfig')->with('options.alertPopups')->willReturn(['value' => $jsConfirmation]); - + $subject->method('getTSConfig')->with()->willReturn([ + 'options.' => [ + 'alertPopups' => $jsConfirmation + ], + ]); $this->assertEquals($typeChangeAllowed, $subject->jsConfirmation(JsConfirmation::TYPE_CHANGE)); $this->assertEquals($copyMovePasteAllowed, $subject->jsConfirmation(JsConfirmation::COPY_MOVE_PASTE)); $this->assertEquals($deleteAllowed, $subject->jsConfirmation(JsConfirmation::DELETE)); @@ -803,8 +812,11 @@ class BackendUserAuthenticationTest extends UnitTestCase $subject = $this->getMockBuilder(BackendUserAuthentication::class) ->setMethods(['getTSConfig']) ->getMock(); - $subject->method('getTSConfig')->with('options.alertPopups')->willReturn(['value' => 0]); - + $subject->method('getTSConfig')->with()->willReturn([ + 'options.' => [ + 'alertPopups' => 0 + ], + ]); $this->assertFalse($subject->jsConfirmation(JsConfirmation::TYPE_CHANGE)); $this->assertFalse($subject->jsConfirmation(JsConfirmation::COPY_MOVE_PASTE)); } diff --git a/typo3/sysext/documentation/Classes/Controller/DocumentController.php b/typo3/sysext/documentation/Classes/Controller/DocumentController.php index 4f26d857f1e93d08d970b023bf20c09cc2f0047d..cd623ad3a9d07b5eceaab630ccbd2d2374dee57c 100644 --- a/typo3/sysext/documentation/Classes/Controller/DocumentController.php +++ b/typo3/sysext/documentation/Classes/Controller/DocumentController.php @@ -143,13 +143,12 @@ class DocumentController extends ActionController $documents = $this->getDocuments(); // Filter documents to be shown for current user - $hideDocuments = $this->getBackendUser()->getTSConfigVal('mod.help_DocumentationDocumentation.documents.hide'); - $hideDocuments = GeneralUtility::trimExplode(',', $hideDocuments, true); + $userTsConfig = $this->getBackendUser()->getTSConfig(); + $hideDocuments = GeneralUtility::trimExplode(',', $userTsConfig['mod.']['help_DocumentationDocumentation.']['documents.']['hide'] ?? '', true); if (!empty($hideDocuments)) { $documents = array_diff_key($documents, array_flip($hideDocuments)); } - $showDocuments = $this->getBackendUser()->getTSConfigVal('mod.help_DocumentationDocumentation.documents.show'); - $showDocuments = GeneralUtility::trimExplode(',', $showDocuments, true); + $showDocuments = GeneralUtility::trimExplode(',', $userTsConfig['mod.']['help_DocumentationDocumentation.']['documents.']['show'] ?? '', true); if (!empty($showDocuments)) { $documents = array_intersect_key($documents, array_flip($showDocuments)); } diff --git a/typo3/sysext/feedit/Classes/FrontendEditPanel.php b/typo3/sysext/feedit/Classes/FrontendEditPanel.php index 01331773c82913f244d754e4fd6f253a41b20211..1aea7fa70846d42f8f2f533596c5f68296e9c29c 100644 --- a/typo3/sysext/feedit/Classes/FrontendEditPanel.php +++ b/typo3/sysext/feedit/Classes/FrontendEditPanel.php @@ -296,8 +296,8 @@ class FrontendEditPanel */ protected function editPanelLinkWrap_doWrap($string, $url, $additionalClasses = '') { - $width = MathUtility::forceIntegerInRange($this->backendUser->getTSConfigVal('options.feedit.popupWidth'), 690, 5000, 690); - $height = MathUtility::forceIntegerInRange($this->backendUser->getTSConfigVal('options.feedit.popupHeight'), 500, 5000, 500); + $width = MathUtility::forceIntegerInRange($this->backendUser->getTSConfig()['options.']['feedit.']['popupWidth'] ?? 690, 690, 5000, 690); + $height = MathUtility::forceIntegerInRange($this->backendUser->getTSConfig()['options.']['feedit.']['popupHeight'] ?? 500, 500, 5000, 500); $onclick = 'vHWin=window.open(' . GeneralUtility::quoteJSvalue($url . '&returnUrl=' . rawurlencode(PathUtility::getAbsoluteWebPath(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Public/Html/Close.html')))) . ',\'FEquickEditWindow\',\'width=' . $width . ',height=' . $height . ',status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;'; return '<a href="#" class="typo3-editPanel-btn typo3-editPanel-btn-default frontEndEditIconLinks ' . htmlspecialchars($additionalClasses) . '" onclick="' . htmlspecialchars($onclick) . '" style="display: none;">' . $string . '</a>'; } diff --git a/typo3/sysext/feedit/Classes/Middleware/FrontendEditInitiator.php b/typo3/sysext/feedit/Classes/Middleware/FrontendEditInitiator.php index 29b8ade5d3deb6374a4994207cd5e93da5b209d7..d2f886ba94eab6d8220379cd46224ecce70fe9a4 100644 --- a/typo3/sysext/feedit/Classes/Middleware/FrontendEditInitiator.php +++ b/typo3/sysext/feedit/Classes/Middleware/FrontendEditInitiator.php @@ -42,7 +42,7 @@ class FrontendEditInitiator implements MiddlewareInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { if (isset($GLOBALS['BE_USER']) && $GLOBALS['BE_USER'] instanceof FrontendBackendUserAuthentication) { - $config = $GLOBALS['BE_USER']->getTSConfigProp('admPanel'); + $config = $GLOBALS['BE_USER']->getTSConfig()['admPanel.'] ?? []; $active = (int)$GLOBALS['TSFE']->displayEditIcons === 1 || (int)$GLOBALS['TSFE']->displayFieldEditIcons === 1; if ($active && isset($config['enable.'])) { foreach ($config['enable.'] as $value) { diff --git a/typo3/sysext/filelist/Classes/Controller/FileListController.php b/typo3/sysext/filelist/Classes/Controller/FileListController.php index 67970f97906a7b7a2756866098e1679b23e55ac2..e95450cfe72f7b3f7dbb516bd5a46ebaae44af71 100644 --- a/typo3/sysext/filelist/Classes/Controller/FileListController.php +++ b/typo3/sysext/filelist/Classes/Controller/FileListController.php @@ -306,21 +306,22 @@ class FileListController extends ActionController // Apply predefined values for hidden checkboxes // Set predefined value for DisplayBigControlPanel: $backendUser = $this->getBackendUser(); - if ($backendUser->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'activated') { + $userTsConfig = $backendUser->getTSConfig(); + if ($userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] ?? '' === 'activated') { $this->MOD_SETTINGS['bigControlPanel'] = true; - } elseif ($backendUser->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'deactivated') { + } elseif ($userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] ?? '' === 'deactivated') { $this->MOD_SETTINGS['bigControlPanel'] = false; } // Set predefined value for DisplayThumbnails: - if ($backendUser->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'activated') { + if ($userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] ?? '' === 'activated') { $this->MOD_SETTINGS['displayThumbs'] = true; - } elseif ($backendUser->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'deactivated') { + } elseif ($userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] ?? '' === 'deactivated') { $this->MOD_SETTINGS['displayThumbs'] = false; } // Set predefined value for Clipboard: - if ($backendUser->getTSConfigVal('options.file_list.enableClipBoard') === 'activated') { + if ($userTsConfig['options.']['file_list.']['enableClipBoard'] ?? '' === 'activated') { $this->MOD_SETTINGS['clipBoard'] = true; - } elseif ($backendUser->getTSConfigVal('options.file_list.enableClipBoard') === 'deactivated') { + } elseif ($userTsConfig['options.']['file_list.']['enableClipBoard'] ?? '' === 'deactivated') { $this->MOD_SETTINGS['clipBoard'] = false; } // If user never opened the list module, set the value for displayThumbs @@ -343,6 +344,7 @@ class FileListController extends ActionController // There there was access to this file path, continue, make the list if ($this->folderObject) { + $userTsConfig = $this->getBackendUser()->getTSConfig(); // Create fileListing object $this->filelist = GeneralUtility::makeInstance(FileList::class, $this); $this->filelist->thumbs = $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $this->MOD_SETTINGS['displayThumbs']; @@ -433,7 +435,7 @@ class FileListController extends ActionController $this->view->assign('checkboxes', [ 'bigControlPanel' => [ - 'enabled' => $this->getBackendUser()->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'selectable', + 'enabled' => $userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] ?? '' === 'selectable', 'label' => htmlspecialchars($this->getLanguageService()->getLL('bigControlPanel')), 'html' => BackendUtility::getFuncCheck( $this->id, @@ -445,7 +447,7 @@ class FileListController extends ActionController ), ], 'displayThumbs' => [ - 'enabled' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $this->getBackendUser()->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'selectable', + 'enabled' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] ?? '' === 'selectable', 'label' => htmlspecialchars($this->getLanguageService()->getLL('displayThumbs')), 'html' => BackendUtility::getFuncCheck( $this->id, @@ -457,7 +459,7 @@ class FileListController extends ActionController ), ], 'enableClipBoard' => [ - 'enabled' => $this->getBackendUser()->getTSConfigVal('options.file_list.enableClipBoard') === 'selectable', + 'enabled' => $userTsConfig['options.']['file_list.']['enableClipBoard'] ?? '' === 'selectable', 'label' => htmlspecialchars($this->getLanguageService()->getLL('clipBoard')), 'html' => BackendUtility::getFuncCheck( $this->id, diff --git a/typo3/sysext/form/Classes/Controller/FormEditorController.php b/typo3/sysext/form/Classes/Controller/FormEditorController.php index ea3e7839382aa3a7960ab36fc5457c067e7b484b..1c3d1df131b9a6a3b44e62645d6087d7c7d237ce 100644 --- a/typo3/sysext/form/Classes/Controller/FormEditorController.php +++ b/typo3/sysext/form/Classes/Controller/FormEditorController.php @@ -15,6 +15,7 @@ namespace TYPO3\CMS\Form\Controller; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\View\BackendTemplateView; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; @@ -105,14 +106,11 @@ class FormEditorController extends AbstractBackendController $popupWindowWidth = 700; $popupWindowHeight = 750; - $popupWindowSize = $this->getBackendUser()->getTSConfigVal('options.popupWindowSize') - ? trim($this->getBackendUser()->getTSConfigVal('options.popupWindowSize')) - : null; + $popupWindowSize = \trim($this->getBackendUser()->getTSConfig()['options.']['popupWindowSize'] ?? ''); if (!empty($popupWindowSize)) { list($popupWindowWidth, $popupWindowHeight) = GeneralUtility::intExplode('x', $popupWindowSize); } - /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ - $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $addInlineSettings = [ 'FormEditor' => [ 'typo3WinBrowserUrl' => (string)$uriBuilder->buildUriFromRoute('wizard_element_browser'), @@ -321,8 +319,8 @@ class FormEditorController extends AbstractBackendController ->setValue('new-page') ->setClasses('t3-form-element-new-page-button hidden') ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-page-new', Icon::SIZE_SMALL)); - /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ - $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); + /** @var UriBuilder $uriBuilder */ + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $closeButton = $buttonBar->makeLinkButton() ->setDataAttributes(['identifier' => 'closeButton']) diff --git a/typo3/sysext/impexp/Classes/ContextMenu/ItemProvider.php b/typo3/sysext/impexp/Classes/ContextMenu/ItemProvider.php index e24a9f9349397b103badfadaef4dce27d4b4a09e..454ff7db6d9d93f175cae7097406f8b30e35f154 100644 --- a/typo3/sysext/impexp/Classes/ContextMenu/ItemProvider.php +++ b/typo3/sysext/impexp/Classes/ContextMenu/ItemProvider.php @@ -117,12 +117,7 @@ class ItemProvider extends AbstractProvider */ protected function isImportEnabled(): bool { - if (!$this->backendUser->isAdmin()) { - $isEnabledForNonAdmin = $this->backendUser->getTSConfig('options.impexp.enableImportForNonAdminUser'); - if (empty($isEnabledForNonAdmin['value'])) { - return false; - } - } - return true; + return $this->backendUser->isAdmin() + || !$this->backendUser->isAdmin() && (bool)($this->backendUser->getTSConfig()['options.']['impexp.']['enableImportForNonAdminUser'] ?? false); } } diff --git a/typo3/sysext/impexp/Classes/Controller/ImportExportController.php b/typo3/sysext/impexp/Classes/Controller/ImportExportController.php index 5eff184e4942827e7a3e4eb0fad9c87ed1f65a04..423d2137f7b9910ca84c28d9a92444b1f7bd0cf1 100644 --- a/typo3/sysext/impexp/Classes/Controller/ImportExportController.php +++ b/typo3/sysext/impexp/Classes/Controller/ImportExportController.php @@ -217,7 +217,6 @@ class ImportExportController extends BaseScriptClass // flag doesn't exist initially; state is on by default $inData['excludeDisabled'] = 1; } - /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); $this->standaloneView->assign('moduleUrl', (string)$uriBuilder->buildUriFromRoute('xMOD_tximpexp')); $this->standaloneView->assign('id', $this->id); @@ -232,8 +231,8 @@ class ImportExportController extends BaseScriptClass break; case 'import': $backendUser = $this->getBackendUser(); - $isEnabledForNonAdmin = $backendUser->getTSConfig('options.impexp.enableImportForNonAdminUser'); - if (!$backendUser->isAdmin() && empty($isEnabledForNonAdmin['value'])) { + $isEnabledForNonAdmin = (bool)($backendUser->getTSConfig()['options.']['impexp.']['enableImportForNonAdminUser'] ?? false); + if (!$backendUser->isAdmin() && $isEnabledForNonAdmin) { throw new \RuntimeException( 'Import module is disabled for non admin users and ' . 'userTsConfig options.impexp.enableImportForNonAdminUser is not enabled.', diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php index 6e79738cf3fc3ff8ca293330af0d3488bb250417..4dfdc79550e28ab7ca6559137e3956113f886bb1 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php @@ -2186,4 +2186,18 @@ return [ 'Deprecation-84981-BackendUserAuthentication-simplelogDeprecated.rst', ], ], + 'TYPO3\CMS\Core\Authentication\BackendUserAuthentication->getTSConfigVal' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Deprecation-84993-DeprecateSomeTSconfigRelatedMethods.rst', + ], + ], + 'TYPO3\CMS\Core\Authentication\BackendUserAuthentication->getTSConfigProp' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Deprecation-84993-DeprecateSomeTSconfigRelatedMethods.rst', + ], + ], ]; diff --git a/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php b/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php index 2db37a5b3bd4c46400413ac8f5a3521750796f38..095cd333eb021f095b9283eacd04e38e7729f468 100644 --- a/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php +++ b/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php @@ -53,11 +53,9 @@ class OpendocsToolbarItem implements ToolbarItemInterface * * @return bool TRUE if user has access, FALSE if not */ - public function checkAccess() + public function checkAccess(): bool { - $disabled = $this->getBackendUser()->getTSConfig('backendToolbarItem.tx_opendocs.disabled'); - - return (int)$disabled['value'] !== 1; + return !(bool)($this->getBackendUser()->getTSConfig()['backendToolbarItem.']['tx_opendocs.']['disabled'] ?? false); } /** diff --git a/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php b/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php index 0248faa07f418b375f23e7ebeea1c4095411e357..af858a2f26535f9579aa95bffac5970c78d9e91b 100644 --- a/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php +++ b/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php @@ -76,19 +76,18 @@ class DatabaseBrowser extends AbstractElementBrowser implements ElementBrowserIn */ public function render() { - $this->setTemporaryDbMounts(); + $userTsConfig = $this->getBackendUser()->getTSConfig(); + $this->setTemporaryDbMounts(); list(, , , $allowedTables) = explode('|', $this->bparams); - $backendUser = $this->getBackendUser(); // Making the browsable pagetree: - /** @var ElementBrowserPageTreeView $pageTree */ $pageTree = GeneralUtility::makeInstance(ElementBrowserPageTreeView::class); $pageTree->setLinkParameterProvider($this); $pageTree->ext_pArrPages = $allowedTables === 'pages'; - $pageTree->ext_showNavTitle = (bool)$backendUser->getTSConfigVal('options.pageTree.showNavTitle'); - $pageTree->ext_showPageId = (bool)$backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle'); - $pageTree->ext_showPathAboveMounts = (bool)$backendUser->getTSConfigVal('options.pageTree.showPathAboveMounts'); + $pageTree->ext_showNavTitle = (bool)($userTsConfig['options.']['pageTree.']['showNavTitle'] ?? false); + $pageTree->ext_showPageId = (bool)($userTsConfig['options.']['pageTree.']['showPageIdWithTitle'] ?? false); + $pageTree->ext_showPathAboveMounts = (bool)($userTsConfig['options.']['pageTree.']['showPathAboveMounts'] ?? false); $pageTree->addField('nav_title'); $tree = $pageTree->getBrowsableTree(); @@ -179,8 +178,8 @@ class DatabaseBrowser extends AbstractElementBrowser implements ElementBrowserIn $backendUser->setWebmounts($alternativeWebmountPoint); } else { // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only") - $alternativeWebmountPoints = trim($backendUser->getTSConfigVal('options.pageTree.altElementBrowserMountPoints')); - $appendAlternativeWebmountPoints = $backendUser->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append'); + $alternativeWebmountPoints = \trim($backendUser->getTSConfig()['options.']['pageTree.']['altElementBrowserMountPoints'] ?? ''); + $appendAlternativeWebmountPoints = $backendUser->getTSConfig()['options.']['pageTree.']['altElementBrowserMountPoints.']['append'] ?? ''; if ($alternativeWebmountPoints) { $alternativeWebmountPoints = GeneralUtility::intExplode(',', $alternativeWebmountPoints); $this->getBackendUser()->setWebmounts($alternativeWebmountPoints, $appendAlternativeWebmountPoints); diff --git a/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php b/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php index 8e797466617444987768596d3d056ae79074b258..68ccaf840d103f5df8d420354102226e913927b3 100644 --- a/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php +++ b/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php @@ -182,7 +182,7 @@ class FileBrowser extends AbstractElementBrowser implements ElementBrowserInterf } // Getting flag for showing/not showing thumbnails: - $noThumbs = $backendUser->getTSConfigVal('options.noThumbsInEB'); + $noThumbs = $backendUser->getTSConfig()['options.']['noThumbsInEB'] ?? false; $_MOD_SETTINGS = []; if (!$noThumbs) { // MENU-ITEMS, fetching the setting for thumbnails from File>List module: @@ -412,7 +412,7 @@ class FileBrowser extends AbstractElementBrowser implements ElementBrowserInterf $out = ''; // Getting flag for showing/not showing thumbnails: - $noThumbsInEB = $this->getBackendUser()->getTSConfigVal('options.noThumbsInEB'); + $noThumbsInEB = $this->getBackendUser()->getTSConfig()['options.']['noThumbsInEB'] ?? false; if (!$noThumbsInEB && $this->selectedFolder) { // MENU-ITEMS, fetching the setting for thumbnails from File>List module: $_MOD_MENU = ['displayThumbs' => '']; diff --git a/typo3/sysext/recordlist/Classes/Controller/AbstractLinkBrowserController.php b/typo3/sysext/recordlist/Classes/Controller/AbstractLinkBrowserController.php index 952edd27759e3659d78cfc0e128bccd8cbb0af19..e4dba740d56edbe8273f3ca83947f2ddd30f7015 100644 --- a/typo3/sysext/recordlist/Classes/Controller/AbstractLinkBrowserController.php +++ b/typo3/sysext/recordlist/Classes/Controller/AbstractLinkBrowserController.php @@ -265,10 +265,7 @@ abstract class AbstractLinkBrowserController */ protected function getLinkHandlers() { - $pageTSconfig = BackendUtility::getPagesTSconfig($this->getCurrentPageId()); - $pageTSconfig = $this->getBackendUser()->getTSConfig('TCEMAIN.linkHandler.', $pageTSconfig); - $linkHandlers = (array)$pageTSconfig['properties']; - + $linkHandlers = (array)(BackendUtility::getPagesTSconfig($this->getCurrentPageId())['TCEMAIN.']['linkHandler.'] ?? []); foreach ($this->hookObjects as $hookObject) { if (method_exists($hookObject, 'modifyLinkHandlers')) { $linkHandlers = $hookObject->modifyLinkHandlers($linkHandlers, $this->currentLinkParts); diff --git a/typo3/sysext/recordlist/Classes/LinkHandler/AbstractLinkHandler.php b/typo3/sysext/recordlist/Classes/LinkHandler/AbstractLinkHandler.php index 545b533a6d3ab9b1dc0847b97f78169f93d06287..564c68ff8f0ff3c7232a1fecdcd32b09e6a5d26c 100644 --- a/typo3/sysext/recordlist/Classes/LinkHandler/AbstractLinkHandler.php +++ b/typo3/sysext/recordlist/Classes/LinkHandler/AbstractLinkHandler.php @@ -129,8 +129,8 @@ abstract class AbstractLinkHandler $backendUser->setWebmounts($alternativeWebmountPoint); } else { // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only") - $alternativeWebmountPoints = trim($backendUser->getTSConfigVal('options.pageTree.altElementBrowserMountPoints')); - $appendAlternativeWebmountPoints = $backendUser->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append'); + $alternativeWebmountPoints = \trim($backendUser->getTSConfig()['options.']['pageTree.']['altElementBrowserMountPoints'] ?? ''); + $appendAlternativeWebmountPoints = $backendUser->getTSConfig()['options.']['pageTree.']['altElementBrowserMountPoints.']['append'] ?? ''; if ($alternativeWebmountPoints) { $alternativeWebmountPoints = GeneralUtility::intExplode(',', $alternativeWebmountPoints); $this->getBackendUser()->setWebmounts($alternativeWebmountPoints, $appendAlternativeWebmountPoints); diff --git a/typo3/sysext/recordlist/Classes/LinkHandler/FileLinkHandler.php b/typo3/sysext/recordlist/Classes/LinkHandler/FileLinkHandler.php index bd53f756bfe2dac9f49ff4b80b3e3a9f681ab7e0..68cc329c11839ec3845f6c0462bd06847fa824eb 100644 --- a/typo3/sysext/recordlist/Classes/LinkHandler/FileLinkHandler.php +++ b/typo3/sysext/recordlist/Classes/LinkHandler/FileLinkHandler.php @@ -124,7 +124,7 @@ class FileLinkHandler extends AbstractLinkHandler implements LinkHandlerInterfac $createFolder = $folderUtilityRenderer->createFolder($selectedFolder); // Insert the upload form on top, if so configured - $positionOfUploadFieldsOnTop = $this->getBackendUser()->getTSConfigVal('options.uploadFieldsInTopOfEB'); + $positionOfUploadFieldsOnTop = (bool)($this->getBackendUser()->getTSConfig()['options.']['uploadFieldsInTopOfEB'] ?? false); $this->view->assign('positionOfUploadFields', $positionOfUploadFieldsOnTop ? 'top' : 'bottom'); $this->view->assign('uploadFileForm', $uploadForm); $this->view->assign('createFolderForm', $createFolder); diff --git a/typo3/sysext/recordlist/Classes/LinkHandler/PageLinkHandler.php b/typo3/sysext/recordlist/Classes/LinkHandler/PageLinkHandler.php index 87497311068627059401fc62ed382c46272e2d90..5ed20b54893f2478305c39b52018d1be6e58c4ae 100644 --- a/typo3/sysext/recordlist/Classes/LinkHandler/PageLinkHandler.php +++ b/typo3/sysext/recordlist/Classes/LinkHandler/PageLinkHandler.php @@ -132,14 +132,13 @@ class PageLinkHandler extends AbstractLinkHandler implements LinkHandlerInterfac $this->expandPage = isset($request->getQueryParams()['expandPage']) ? (int)$request->getQueryParams()['expandPage'] : 0; $this->setTemporaryDbMounts(); - $backendUser = $this->getBackendUser(); + $userTsConfig = $this->getBackendUser()->getTSConfig(); - /** @var ElementBrowserPageTreeView $pageTree */ $pageTree = GeneralUtility::makeInstance(ElementBrowserPageTreeView::class); $pageTree->setLinkParameterProvider($this); - $pageTree->ext_showNavTitle = (bool)$backendUser->getTSConfigVal('options.pageTree.showNavTitle'); - $pageTree->ext_showPageId = (bool)$backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle'); - $pageTree->ext_showPathAboveMounts = (bool)$backendUser->getTSConfigVal('options.pageTree.showPathAboveMounts'); + $pageTree->ext_showNavTitle = (bool)($userTsConfig['options.']['pageTree.']['showNavTitle'] ?? false); + $pageTree->ext_showPageId = (bool)($userTsConfig['options.']['pageTree.']['showPageIdWithTitle'] ?? false); + $pageTree->ext_showPathAboveMounts = (bool)($userTsConfig['options.']['pageTree.']['showPathAboveMounts'] ?? false); $pageTree->addField('nav_title'); $this->view->assign('temporaryTreeMountCancelLink', $this->getTemporaryTreeMountCancelNotice()); diff --git a/typo3/sysext/recordlist/Classes/LinkHandler/RecordLinkHandler.php b/typo3/sysext/recordlist/Classes/LinkHandler/RecordLinkHandler.php index 7056bacaf01511010a4d023dcda4f73434df09e9..3e7807cebcb25ebca8f6bb01a1b5cecf7a0f60d9 100644 --- a/typo3/sysext/recordlist/Classes/LinkHandler/RecordLinkHandler.php +++ b/typo3/sysext/recordlist/Classes/LinkHandler/RecordLinkHandler.php @@ -165,14 +165,14 @@ class RecordLinkHandler extends AbstractLinkHandler implements LinkHandlerInterf */ protected function renderPageTree(): string { - $backendUser = $this->getBackendUser(); + $userTsConfig = $this->getBackendUser()->getTSConfig(); /** @var RecordBrowserPageTreeView $pageTree */ $pageTree = GeneralUtility::makeInstance(RecordBrowserPageTreeView::class); $pageTree->setLinkParameterProvider($this); - $pageTree->ext_showPageId = (bool)$backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle'); - $pageTree->ext_showNavTitle = (bool)$backendUser->getTSConfigVal('options.pageTree.showNavTitle'); - $pageTree->ext_showPathAboveMounts = (bool)$backendUser->getTSConfigVal('options.pageTree.showPathAboveMounts'); + $pageTree->ext_showPageId = (bool)($userTsConfig['options.']['pageTree.']['showPageIdWithTitle'] ?? false); + $pageTree->ext_showNavTitle = (bool)($userTsConfig['options.']['pageTree.']['showNavTitle'] ?? false); + $pageTree->ext_showPathAboveMounts = (bool)($userTsConfig['options.']['pageTree.']['showPathAboveMounts'] ?? false); $pageTree->addField('nav_title'); // Load the mount points, if any diff --git a/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php index 0ff9149d3b09aa6aa1af03a20f1d11ba434d646f..df2a5c022c06630ae97df6df06333ed2a95d7fdb 100644 --- a/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php +++ b/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php @@ -435,11 +435,9 @@ class AbstractDatabaseRecordList extends AbstractRecordList ->expr(); $permsClause = $expressionBuilder->andX($backendUser->getPagePermsClause(Permission::PAGE_SHOW)); // This will hide records from display - it has nothing to do with user rights!! - if ($pidList = $backendUser->getTSConfigVal('options.hideRecords.pages')) { - $pidList = GeneralUtility::intExplode(',', $pidList, true); - if (!empty($pidList)) { - $permsClause->add($expressionBuilder->notIn('pages.uid', $pidList)); - } + $pidList = GeneralUtility::intExplode(',', $backendUser->getTSConfig()['options.']['hideRecords.']['pages'] ?? '', true); + if (!empty($pidList)) { + $permsClause->add($expressionBuilder->notIn('pages.uid', $pidList)); } $this->perms_clause = (string)$permsClause; diff --git a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php index c1025812d06487c97dd62a8f5495a3942e991db8..ca26ba0eedd69915634c62e24576375cfb13e226 100644 --- a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php +++ b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php @@ -1920,6 +1920,8 @@ class DatabaseRecordList */ public function makeControl($table, $row) { + $backendUser = $this->getBackendUserAuthentication(); + $userTsConfig = $backendUser->getTSConfig(); $module = $this->getModule(); $rowUid = $row['uid']; if (ExtensionManagementUtility::isLoaded('workspaces') && isset($row['_ORIG_uid'])) { @@ -1935,14 +1937,14 @@ class DatabaseRecordList // If the listed table is 'pages' we have to request the permission settings for each page: $localCalcPerms = 0; if ($table === 'pages') { - $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid'])); + $localCalcPerms = $backendUser->calcPerms(BackendUtility::getRecord('pages', $row['uid'])); } $permsEdit = $table === 'pages' - && $this->getBackendUserAuthentication()->checkLanguageAccess(0) + && $backendUser->checkLanguageAccess(0) && $localCalcPerms & Permission::PAGE_EDIT || $table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT - && $this->getBackendUserAuthentication()->recordEditAccessInternals($table, $row); + && $backendUser->recordEditAccessInternals($table, $row); $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit); // "Show" link (only pages and tt_content elements) /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ @@ -1996,9 +1998,7 @@ class DatabaseRecordList // If the table is NOT a read-only table, then show these links: if ($this->isEditable($table)) { // "Revert" link (history/undo) - $showHistoryTS = $this->getBackendUserAuthentication()->getTSConfig('options.showHistory'); - $showHistory = (bool)trim($showHistoryTS['properties'][$table] ?? $showHistoryTS['value'] ?? '1'); - if ($showHistory) { + if ((bool)\trim($userTsConfig['options.']['showHistory.'][$table] ?? $userTsConfig['options.']['showHistory'] ?? '1')) { $moduleUrl = BackendUtility::getModuleUrl('record_history', ['element' => $table . ':' . $row['uid']]); $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($moduleUrl) . ',\'#latest\');'; $historyAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' @@ -2007,7 +2007,7 @@ class DatabaseRecordList $this->addActionToCellGroup($cells, $historyAction, 'history'); } // "Edit Perms" link: - if ($table === 'pages' && $this->getBackendUserAuthentication()->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) { + if ($table === 'pages' && $backendUser->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) { if ($isL10nOverlay) { $permsAction = $this->spaceIcon; } else { @@ -2070,7 +2070,7 @@ class DatabaseRecordList if ( !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]) && (empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude']) - || $this->getBackendUserAuthentication()->check('non_exclude_fields', $table . ':' . $hiddenField)) + || $backendUser->check('non_exclude_fields', $table . ':' . $hiddenField)) ) { if (!$permsEdit || $this->isRecordCurrentBackendUser($table, $row)) { $hideAction = $this->spaceIcon; @@ -2096,11 +2096,10 @@ class DatabaseRecordList $this->addActionToCellGroup($cells, $hideAction, 'hide'); } // "Delete" link: - $disableDeleteTS = $this->getBackendUserAuthentication()->getTSConfig('options.disableDelete'); - $disableDelete = (bool)trim($disableDeleteTS['properties'][$table] ?? $disableDeleteTS['value']); + $disableDelete = (bool)\trim($userTsConfig['options.']['disableDelete.'][$table] ?? $userTsConfig['options.']['disableDelete'] ?? '0'); if ($permsEdit && !$disableDelete && ($table === 'pages' && $localCalcPerms & Permission::PAGE_DELETE || $table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT)) { // Check if the record version is in "deleted" state, because that will switch the action to "restore" - if ($this->getBackendUserAuthentication()->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) { + if ($backendUser->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) { $actionName = 'restore'; $refCountMsg = ''; } else { @@ -2150,7 +2149,7 @@ class DatabaseRecordList } // Down (Paste as subpage to the page right above) if (!$isL10nOverlay && $this->currentTable['prevUid'][$row['uid']]) { - $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']])); + $localCalcPerms = $backendUser->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']])); if ($localCalcPerms & Permission::PAGE_NEW) { $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']]; $moveRightAction = '<a class="btn btn-default" href="#" onclick="' @@ -2946,11 +2945,9 @@ class DatabaseRecordList ->expr(); $permsClause = $expressionBuilder->andX($backendUser->getPagePermsClause(Permission::PAGE_SHOW)); // This will hide records from display - it has nothing to do with user rights!! - if ($pidList = $backendUser->getTSConfigVal('options.hideRecords.pages')) { - $pidList = GeneralUtility::intExplode(',', $pidList, true); - if (!empty($pidList)) { - $permsClause->add($expressionBuilder->notIn('pages.uid', $pidList)); - } + $pidList = GeneralUtility::intExplode(',', $backendUser->getTSConfig()['options.']['hideRecords.']['pages'] ?? '', true); + if (!empty($pidList)) { + $permsClause->add($expressionBuilder->notIn('pages.uid', $pidList)); } $this->perms_clause = (string)$permsClause; diff --git a/typo3/sysext/recordlist/Classes/View/FolderUtilityRenderer.php b/typo3/sysext/recordlist/Classes/View/FolderUtilityRenderer.php index 6013d0c5da3b38ad9a7773d903e39669ca4de874..9c8ff9532671b5896d99edc8a0bee513901a9129 100644 --- a/typo3/sysext/recordlist/Classes/View/FolderUtilityRenderer.php +++ b/typo3/sysext/recordlist/Classes/View/FolderUtilityRenderer.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Recordlist\View; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Resource\Folder; @@ -49,21 +50,19 @@ class FolderUtilityRenderer */ public function createFolder(Folder $folderObject) { - if (!$folderObject->checkActionPermission('write')) { - return ''; - } $backendUser = $this->getBackendUser(); - if (!$backendUser->isAdmin() && !$backendUser->getTSConfigVal('options.createFoldersInEB')) { - return ''; - } - // Don't show Folder-create form if it's denied - if ($backendUser->getTSConfigVal('options.folderTree.hideCreateFolder')) { + $userTsConfig = $backendUser->getTSConfig(); + $lang = $this->getLanguageService(); + + if (!$folderObject->checkActionPermission('write') + || !$backendUser->isAdmin() && !($userTsConfig['options.']['createFoldersInEB'] ?? false) + || $userTsConfig['options.']['folderTree.']['hideCreateFolder'] ?? false + ) { + // Do not show create folder form if it is denied return ''; } - $lang = $this->getLanguageService(); - /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ - $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $formAction = (string)$uriBuilder->buildUriFromRoute('tce_file'); $markup = []; $markup[] = '<form action="' . htmlspecialchars($formAction) @@ -113,13 +112,11 @@ class FolderUtilityRenderer return ''; } // Read configuration of upload field count - $userSetting = $this->getBackendUser()->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser'); - $count = isset($userSetting) ? (int)$userSetting : 1; + $count = (int)($this->getBackendUser()->getTSConfig()['options.']['folderTree.']['uploadFieldsInLinkBrowser'] ?? 1); if ($count === 0) { return ''; } - $count = (int)$count === 0 ? 1 : (int)$count; // Create header, showing upload path: $header = $folderObject->getIdentifier(); $lang = $this->getLanguageService(); @@ -131,8 +128,8 @@ class FolderUtilityRenderer . strtoupper(htmlspecialchars($fileExt)) . '</span>'; } } - /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ - $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); + /** @var UriBuilder $uriBuilder */ + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $formAction = (string)$uriBuilder->buildUriFromRoute('tce_file'); $combinedIdentifier = $folderObject->getCombinedIdentifier(); $markup = []; diff --git a/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php b/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php index 7a2759c1593c98c946dec2afb5707a64180414b1..4db21ad61bcbf0a86a89af95a480110a097320b2 100644 --- a/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php +++ b/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php @@ -19,6 +19,7 @@ use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Http\JsonResponse; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Recycler\Domain\Model\DeletedRecords; @@ -44,12 +45,10 @@ class RecyclerAjaxController // Configuration, variable assignment $this->conf['action'] = GeneralUtility::_GP('action'); $this->conf['table'] = GeneralUtility::_GP('table') ? GeneralUtility::_GP('table') : ''; - $modTS = $this->getBackendUser()->getTSConfig('mod.recycler'); - if (isset($modTS['properties']['recordsPageLimit']) && (int)$modTS['properties']['recordsPageLimit'] > 0) { - $this->conf['limit'] = (int)$modTS['properties']['recordsPageLimit']; - } else { - $this->conf['limit'] = 25; - } + $this->conf['limit'] = MathUtility::forceIntegerInRange( + (int)($this->getBackendUser()->getTSConfig()['mod.']['recycler.']['recordsPageLimit'] ?? 25), + 1 + ); $this->conf['start'] = GeneralUtility::_GP('start') ? (int)GeneralUtility::_GP('start') : 0; $this->conf['filterTxt'] = GeneralUtility::_GP('filterTxt') ? GeneralUtility::_GP('filterTxt') : ''; $this->conf['startUid'] = GeneralUtility::_GP('startUid') ? (int)GeneralUtility::_GP('startUid') : 0; diff --git a/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php b/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php index 051a8c8116b0b2956b30c49ece2e7a2a4e6348a2..bfc730ef6a6f0760fc313ab65bc2fe24f802e741 100644 --- a/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php +++ b/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php @@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Type\Bitmask\Permission; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Fluid\View\StandaloneView; /** @@ -89,16 +90,16 @@ class RecyclerModuleController } // read configuration - $modTS = $backendUser->getTSConfig('mod.recycler'); - if ($this->getBackendUser()->isAdmin()) { + if ($backendUser->isAdmin()) { $this->allowDelete = true; } else { - $this->allowDelete = (bool)$modTS['properties']['allowDelete']; + $this->allowDelete = (bool)($backendUser->getTSConfig()['mod.']['recycler.']['allowDelete'] ?? false); } - if (isset($modTS['properties']['recordsPageLimit']) && (int)$modTS['properties']['recordsPageLimit'] > 0) { - $this->recordsPageLimit = (int)$modTS['properties']['recordsPageLimit']; - } + $this->recordsPageLimit = MathUtility::forceIntegerInRange( + (int)($backendUser->getTSConfig()['mod.']['recycler.']['recordsPageLimit'] ?? 25), + 1 + ); $action = 'index'; $this->initializeView($action); diff --git a/typo3/sysext/setup/Classes/Controller/SetupModuleController.php b/typo3/sysext/setup/Classes/Controller/SetupModuleController.php index a4e91371d246954c78b86307cd31ee15a7be9f27..a78cbe433e8a6370a26a3e4641d5db565b2f2f15 100644 --- a/typo3/sysext/setup/Classes/Controller/SetupModuleController.php +++ b/typo3/sysext/setup/Classes/Controller/SetupModuleController.php @@ -345,9 +345,9 @@ class SetupModuleController $this->isAdmin = $scriptUser->isAdmin(); // Getting the 'override' values as set might be set in User TSconfig - $this->overrideConf = $this->beUser->getTSConfigProp('setup.override'); + $this->overrideConf = $this->beUser->getTSConfig()['setup.']['override.'] ?? null; // Getting the disabled fields might be set in User TSconfig (eg setup.fields.password.disabled=1) - $this->tsFieldConf = $this->beUser->getTSConfigProp('setup.fields'); + $this->tsFieldConf = $this->beUser->getTSConfig()['setup.']['fields.'] ?? null; // id password is disabled, disable repeat of password too (password2) if (isset($this->tsFieldConf['password.']) && $this->tsFieldConf['password.']['disabled']) { $this->tsFieldConf['password2.']['disabled'] = 1; diff --git a/typo3/sysext/taskcenter/Classes/Controller/TaskModuleController.php b/typo3/sysext/taskcenter/Classes/Controller/TaskModuleController.php index 3c5d5db095a3b2dc0cc7d4d1d86a8c4177c0c17e..5a1b5ee01bc14ba8f008caa82f1907f7be1db897 100644 --- a/typo3/sysext/taskcenter/Classes/Controller/TaskModuleController.php +++ b/typo3/sysext/taskcenter/Classes/Controller/TaskModuleController.php @@ -422,22 +422,19 @@ class TaskModuleController extends BaseScriptClass * @param string $taskClass Name of the task * @return bool Access to the task allowed or not */ - protected function checkAccess($extKey, $taskClass) + protected function checkAccess($extKey, $taskClass): bool { - // Check if task is blinded with TsConfig (taskcenter.<extkey>.<taskName> - $tsConfig = $this->getBackendUser()->getTSConfig('taskcenter.' . $extKey . '.' . $taskClass); - if (isset($tsConfig['value']) && (int)$tsConfig['value'] === 0) { - return false; - } + $backendUser = $this->getBackendUser(); // Admins are always allowed - if ($this->getBackendUser()->isAdmin()) { + if ($backendUser->isAdmin()) { return true; } // Check if task is restricted to admins if ((int)$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter'][$extKey][$taskClass]['admin'] === 1) { return false; } - return true; + // Check if task is blinded with TsConfig (taskcenter.<extkey>.<taskName> + return (bool)($backendUser->getTSConfig()['taskcenter.'][$extKey . '.'][$taskClass] ?? true); } /** diff --git a/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php b/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php index 407af6e539b13f8abf447b3e71fd902537955fcb..534a00b1524a19297e207d1cc916562da7945dbd 100644 --- a/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php +++ b/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php @@ -279,13 +279,8 @@ class ViewModuleController */ protected function getDomainName(int $pageId) { - $previewDomainConfig = $this->getBackendUser()->getTSConfig('TCEMAIN.previewDomain', BackendUtility::getPagesTSconfig($pageId)); - if ($previewDomainConfig['value']) { - $domain = $previewDomainConfig['value']; - } else { - $domain = BackendUtility::firstDomainRecord(BackendUtility::BEgetRootLine($pageId)); - } - return $domain; + $previewDomainConfig = BackendUtility::getPagesTSconfig($pageId)['TCEMAIN.']['previewDomain'] ?? ''; + return $previewDomainConfig ?: BackendUtility::firstDomainRecord(BackendUtility::BEgetRootLine($pageId)); } /** diff --git a/typo3/sysext/workspaces/Classes/Controller/PreviewController.php b/typo3/sysext/workspaces/Classes/Controller/PreviewController.php index 8072db2d7a2148cdf912d948b20358408f5fbf34..17a2478db565cdc2994e104e9a5e90465a2a6bda 100644 --- a/typo3/sysext/workspaces/Classes/Controller/PreviewController.php +++ b/typo3/sysext/workspaces/Classes/Controller/PreviewController.php @@ -202,7 +202,7 @@ class PreviewController protected function generateJavascript(): string { // If another page module was specified, replace the default Page module with the new one - $pageModule = trim($this->getBackendUser()->getTSConfigVal('options.overridePageModule') ?? ''); + $pageModule = \trim($this->getBackendUser()->getTSConfig()['options.']['overridePageModule'] ?? ''); $pageModule = BackendUtility::isModuleSetInTBE_MODULES($pageModule) ? $pageModule : 'web_layout'; if (!$this->getBackendUser()->check('modules', $pageModule)) { $pageModule = ''; diff --git a/typo3/sysext/workspaces/Classes/Controller/Remote/MassActionHandler.php b/typo3/sysext/workspaces/Classes/Controller/Remote/MassActionHandler.php index c767c53aab6aa3c48de2158065e1c16843c44a28..8147ccaadfbe0d46d0bde04deb8a430bd8161183 100644 --- a/typo3/sysext/workspaces/Classes/Controller/Remote/MassActionHandler.php +++ b/typo3/sysext/workspaces/Classes/Controller/Remote/MassActionHandler.php @@ -54,13 +54,14 @@ class MassActionHandler { $actions = []; $currentWorkspace = $this->getCurrentWorkspace(); - $massActionsEnabled = $this->getBackendUser()->getTSConfigVal('options.workspaces.enableMassActions') !== '0'; + $backendUser = $this->getBackendUser(); + $massActionsEnabled = (bool)($backendUser->getTSConfig()['options.']['workspaces.']['enableMassActions'] ?? true); // in case we're working within "All Workspaces" we can't provide Mass Actions if ($currentWorkspace != WorkspaceService::SELECT_ALL_WORKSPACES && $massActionsEnabled) { - $publishAccess = $this->getBackendUser()->workspacePublishAccess($currentWorkspace); - if ($publishAccess && !($this->getBackendUser()->workspaceRec['publish_access'] & 1)) { + $publishAccess = $backendUser->workspacePublishAccess($currentWorkspace); + if ($publishAccess && !($backendUser->workspaceRec['publish_access'] & 1)) { $actions[] = ['action' => 'publish', 'title' => $this->getLanguageService()->sL($this->pathToLocallang . ':label_doaction_publish')]; - if ($this->getBackendUser()->workspaceSwapAccess()) { + if ($backendUser->workspaceSwapAccess()) { $actions[] = ['action' => 'swap', 'title' => $this->getLanguageService()->sL($this->pathToLocallang . ':label_doaction_swap')]; } } diff --git a/typo3/sysext/workspaces/Classes/DataHandler/CommandMap.php b/typo3/sysext/workspaces/Classes/DataHandler/CommandMap.php index b608ed4d3a5e5265019b6a6a04baa9bcf3fab4b8..ddbab2ee2160b847bf9365556ff60f881c64c674 100644 --- a/typo3/sysext/workspaces/Classes/DataHandler/CommandMap.php +++ b/typo3/sysext/workspaces/Classes/DataHandler/CommandMap.php @@ -96,8 +96,8 @@ class CommandMap $this->setTceMain($tceMain); $this->set($commandMap); $this->setWorkspace($workspace); - $this->setWorkspacesSwapMode($this->getTceMain()->BE_USER->getTSConfigVal('options.workspaces.swapMode')); - $this->setWorkspacesChangeStageMode($this->getTceMain()->BE_USER->getTSConfigVal('options.workspaces.changeStageMode')); + $this->setWorkspacesSwapMode($this->getTceMain()->BE_USER->getTSConfig()['options.']['workspaces.']['swapMode'] ?? ''); + $this->setWorkspacesChangeStageMode($this->getTceMain()->BE_USER->getTSConfig()['options.']['workspaces.']['changeStageMode'] ?? ''); $this->constructScopes(); } diff --git a/typo3/sysext/workspaces/Classes/Preview/PreviewUriBuilder.php b/typo3/sysext/workspaces/Classes/Preview/PreviewUriBuilder.php index e7b141a4ba61de6d167cdd225f6f175fd6d46bc2..dd67341249814411a8e864c59d1eaade567c7f01 100644 --- a/typo3/sysext/workspaces/Classes/Preview/PreviewUriBuilder.php +++ b/typo3/sysext/workspaces/Classes/Preview/PreviewUriBuilder.php @@ -221,7 +221,7 @@ class PreviewUriBuilder */ protected function getPreviewLinkLifetime(): int { - $ttlHours = (int)$this->getBackendUser()->getTSConfigVal('options.workspaces.previewLinkTTLHours'); + $ttlHours = (int)($this->getBackendUser()->getTSConfig()['options.']['workspaces.']['previewLinkTTLHours'] ?? 0); return $ttlHours ?: 24 * 2; }