3 declare(strict_types
=1);
6 * This file is part of the TYPO3 CMS project.
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
15 * The TYPO3 project - inspiring people to share!
18 namespace TYPO3\CMS\Adminpanel\Utility
;
20 use TYPO3\CMS\Backend\FrontendBackendUserAuthentication
;
23 * Helper class to check if the admin panel is enabled and active from outside
25 * Useful for initialization, checks in early hooks or middleware implementations
30 * Checks if adminPanel was configured to be shown
34 public static function isActivatedForUser(): bool
36 $beUser = $GLOBALS['BE_USER'] ??
null;
37 if ($beUser instanceof FrontendBackendUserAuthentication
) {
38 $adminPanelConfiguration = $beUser->getTSConfig()['admPanel.'] ??
[];
39 if (isset($adminPanelConfiguration['enable.'])) {
40 // only enabled if at least one module is enabled.
41 return (bool)array_filter($adminPanelConfiguration['enable.']);
48 * Returns true if admin panel was activated
49 * (switched "on" via GUI)
53 public static function isOpen(): bool
55 $beUser = $GLOBALS['BE_USER'] ??
null;
56 return (bool)($beUser->uc
['AdminPanel']['display_top'] ??
false);
59 public static function isActivatedInTypoScript(): bool
61 return (bool)($GLOBALS['TSFE']->config
['config']['admPanel'] ??
false);
64 public static function isHiddenForUser(): bool
66 $beUser = $GLOBALS['BE_USER'] ??
null;
67 return $beUser ?
(bool)($beUser->getTSConfig()['admPanel.']['hide'] ??
false) : false;