1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace TYPO3\CMS\Adminpanel\Utility; |
5
|
|
|
|
6
|
|
|
/* |
7
|
|
|
* This file is part of the TYPO3 CMS project. |
8
|
|
|
* |
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. |
12
|
|
|
* |
13
|
|
|
* For the full copyright and license information, please read the |
14
|
|
|
* LICENSE.txt file that was distributed with this source code. |
15
|
|
|
* |
16
|
|
|
* The TYPO3 project - inspiring people to share! |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use TYPO3\CMS\Backend\FrontendBackendUserAuthentication; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Helper class to check if the admin panel is enabled and active from outside |
23
|
|
|
* |
24
|
|
|
* Useful for initialization, checks in early hooks or middleware implementations |
25
|
|
|
*/ |
26
|
|
|
class StateUtility |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Checks if adminPanel was configured to be shown |
30
|
|
|
* |
31
|
|
|
* @return bool |
32
|
|
|
*/ |
33
|
|
|
public static function isActivatedForUser(): bool |
34
|
|
|
{ |
35
|
|
|
$beUser = $GLOBALS['BE_USER'] ?? null; |
36
|
|
|
if ($beUser instanceof FrontendBackendUserAuthentication) { |
37
|
|
|
$adminPanelConfiguration = $beUser->getTSConfig()['admPanel.'] ?? []; |
38
|
|
|
// set legacy config |
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.']); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
return false; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Returns true if admin panel was activated |
50
|
|
|
* (switched "on" via GUI) |
51
|
|
|
* |
52
|
|
|
* @return bool |
53
|
|
|
*/ |
54
|
|
|
public static function isOpen(): bool |
55
|
|
|
{ |
56
|
|
|
$beUser = $GLOBALS['BE_USER'] ?? null; |
57
|
|
|
return (bool)($beUser->uc['AdminPanel']['display_top'] ?? false); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public static function isActivatedInTypoScript(): bool |
61
|
|
|
{ |
62
|
|
|
return (bool)($GLOBALS['TSFE']->config['config']['admPanel'] ?? false); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public static function isHiddenForUser(): bool |
66
|
|
|
{ |
67
|
|
|
return (bool)($GLOBALS['BE_USER']->extAdminConfig['hide'] ?? false); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|