2 declare(strict_types
= 1);
4 namespace TYPO3\CMS\Adminpanel\Utility
;
7 * This file is part of the TYPO3 CMS project.
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
16 * The TYPO3 project - inspiring people to share!
19 use TYPO3\CMS\Backend\FrontendBackendUserAuthentication
;
22 * Helper class to check if the admin panel is enabled and active from outside
24 * Useful for initialization, checks in early hooks or middleware implementations
29 * Checks if adminPanel was configured to be shown
33 public static function isActivatedForUser(): bool
35 $beUser = $GLOBALS['BE_USER'] ??
null;
36 if ($beUser instanceof FrontendBackendUserAuthentication
) {
37 $adminPanelConfiguration = $beUser->getTSConfig()['admPanel.'] ??
[];
39 $beUser->extAdminConfig
= $adminPanelConfiguration;
40 if (isset($adminPanelConfiguration['enable.'])) {
41 // only enabled if at least one module is enabled.
42 return (bool)array_filter($adminPanelConfiguration['enable.']);
49 * Returns true if admin panel was activated
50 * (switched "on" via GUI)
54 public static function isOpen(): bool
56 $beUser = $GLOBALS['BE_USER'] ??
null;
57 return (bool)($beUser->uc
['AdminPanel']['display_top'] ??
false);
60 public static function isActivatedInTypoScript(): bool
62 return (bool)($GLOBALS['TSFE']->config
['config']['admPanel'] ??
false);
65 public static function isHiddenForUser(): bool
67 $beUser = $GLOBALS['BE_USER'] ??
null;
68 return $beUser->getTSConfig()['admPanel.']['hide'] ??
false;