‪TYPO3CMS  9.5
EidUtility.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
23 
36 {
44  public static function ‪initFeUser()
45  {
46  trigger_error('EidUtility::initFeUser() will be removed in TYPO3 v10.0. Use a PSR-15 middleware instead.', E_USER_DEPRECATED);
47  // Get TSFE instance. It knows how to initialize the user.
48  $tsfe = ‪self::getTSFE();
49  $tsfe->fe_user = GeneralUtility::makeInstance(FrontendUserAuthentication::class);
50  // List of pid's acceptable
51  $pid = GeneralUtility::_GP('pid');
52  $tsfe->fe_user->checkPid_value = $pid ? implode(',', GeneralUtility::intExplode(',', $pid)) : 0;
53  // Check if a session is transferred:
54  if (GeneralUtility::_GP('FE_SESSION_KEY')) {
55  $fe_sParts = explode('-', GeneralUtility::_GP('FE_SESSION_KEY'));
56  // If the session key hash check is OK:
57  if (md5($fe_sParts[0] . '/' . ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) === (string)$fe_sParts[1]) {
59  $_COOKIE[$cookieName] = $fe_sParts[0];
60  if (isset($_SERVER['HTTP_COOKIE'])) {
61  // See http://forge.typo3.org/issues/27740
62  $_SERVER['HTTP_COOKIE'] .= ';' . $cookieName . '=' . $fe_sParts[0];
63  }
64  $tsfe->fe_user->forceSetCookie = true;
65  $tsfe->fe_user->dontSetCookie = false;
66  unset($cookieName);
67  }
68  }
69  $tsfe->fe_user->start();
70  $tsfe->fe_user->unpack_uc();
71 
72  // Call hook for possible manipulation of frontend user object
73  $_params = ['pObj' => &$tsfe];
74  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] ?? [] as $_funcRef) {
75  GeneralUtility::callUserFunction($_funcRef, $_params, $tsfe);
76  }
77  // Return FE user object:
78  return $tsfe->fe_user;
79  }
80 
87  public static function ‪initLanguage($language = 'default')
88  {
89  trigger_error('EidUtility::initLanguage() will be removed in TYPO3 v10.0. Ensure to intantiate the LanguageService by yourself.', E_USER_DEPRECATED);
90  if (!is_object(‪$GLOBALS['LANG'])) {
91  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
92  ‪$GLOBALS['LANG']->init($language);
93  }
94  }
95 
100  public static function ‪initTCA()
101  {
102  trigger_error('EidUtility::initTCA() will be removed in TYPO3 v10.0. Is not needed anymore within eID scripts as TCA is now available at any time.', E_USER_DEPRECATED);
103  // Some badly made extensions attempt to manipulate TCA in a wrong way
104  // (inside ext_localconf.php). Therefore $GLOBALS['TCA'] may become an array
105  // but in fact it is not loaded. The check below ensure that
106  // TCA is still loaded if such bad extensions are installed
107  if (!is_array(‪$GLOBALS['TCA']) || !isset(‪$GLOBALS['TCA']['pages'])) {
109  }
110  }
111 
119  public static function ‪initExtensionTCA($extensionKey)
120  {
121  trigger_error('EidUtility::initExtensionTCA() will be removed in TYPO3 v10.0 as it is discouraged to only load ext_tables.php of one extension. Use ExtensionManagementUtility instead.', E_USER_DEPRECATED);
122  $extTablesPath = ‪ExtensionManagementUtility::extPath($extensionKey, 'ext_tables.php');
123  if (file_exists($extTablesPath)) {
124  ‪$GLOBALS['_EXTKEY'] = $extensionKey;
125  require_once $extTablesPath;
126  // We do not need to save restore the value of $GLOBALS['_EXTKEY']
127  // because it is not defined to anything real outside of
128  // ext_tables.php or ext_localconf.php scope.
129  unset(‪$GLOBALS['_EXTKEY']);
130  }
131  }
132 
138  private static function ‪getTSFE(): ‪TypoScriptFrontendController
139  {
140  $runtimeCache = GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_runtime');
141  $tsfe = $runtimeCache->get('eidUtilityTsfe') ?: null;
142  if ($tsfe === null) {
143  $tsfe = GeneralUtility::makeInstance(TypoScriptFrontendController::class, null, 0, 0);
144  $runtimeCache->set('eidUtilityTsfe', $tsfe);
145  }
146  return $tsfe;
147  }
148 }
‪TYPO3\CMS\Frontend\Utility\EidUtility\initFeUser
‪static FrontendUserAuthentication initFeUser()
Definition: EidUtility.php:44
‪TYPO3\CMS\Frontend\Utility
Definition: CanonicalizationUtility.php:4
‪TYPO3\CMS\Frontend\Utility\EidUtility\getTSFE
‪static TypoScriptFrontendController getTSFE()
Definition: EidUtility.php:138
‪TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication\getCookieName
‪static string getCookieName()
Definition: FrontendUserAuthentication.php:137
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:36
‪TYPO3\CMS\Frontend\Utility\EidUtility\initLanguage
‪static initLanguage($language='default')
Definition: EidUtility.php:87
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:34
‪TYPO3\CMS\Frontend\Utility\EidUtility
Definition: EidUtility.php:36
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:97
‪TYPO3\CMS\Frontend\Utility\EidUtility\initExtensionTCA
‪static initExtensionTCA($extensionKey)
Definition: EidUtility.php:119
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\extPath
‪static string extPath($key, $script='')
Definition: ExtensionManagementUtility.php:149
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\loadBaseTca
‪static loadBaseTca($allowCaching=true, FrontendInterface $codeCache=null)
Definition: ExtensionManagementUtility.php:1646
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication
Definition: FrontendUserAuthentication.php:28
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Frontend\Utility\EidUtility\initTCA
‪static initTCA()
Definition: EidUtility.php:100