[BUGFIX] Do not load ContextHelp JS if no BE user is there 89/45089/2
authorMarkus Klein <markus.klein@typo3.org>
Wed, 2 Dec 2015 14:41:37 +0000 (15:41 +0100)
committerFrank Nägler <frank.naegler@typo3.org>
Wed, 2 Dec 2015 14:54:51 +0000 (15:54 +0100)
This avoids to load the JS for the BE login for instance.

Resolves: #72026
Releases: master
Change-Id: I12827386e1e6d97b6c0dda5a6ddd0cd393659781
Reviewed-on: https://review.typo3.org/45089
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
typo3/sysext/cshmanual/Classes/Service/JavaScriptService.php

index 19e4784..9717fc9 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Cshmanual\Service;
  * The TYPO3 project - inspiring people to share!
  */
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -30,7 +31,11 @@ class JavaScriptService
      */
     public function addJavaScript($title, $documentTemplateObject)
     {
-        if (TYPO3_MODE === 'BE' && is_object($GLOBALS['BE_USER'])) {
+        if (TYPO3_MODE !== 'BE') {
+            return;
+        }
+        $beUser = $this->getBeUser();
+        if ($beUser && !empty($beUser->user)) {
             $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
             $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextHelp');
             $pageRenderer->addInlineSetting('ContextHelp', 'moduleUrl', BackendUtility::getModuleUrl('help_CshmanualCshmanual', array(
@@ -41,4 +46,12 @@ class JavaScriptService
             )));
         }
     }
+
+    /**
+     * @return BackendUserAuthentication
+     */
+    protected function getBeUser()
+    {
+        return isset($GLOBALS['BE_USER']) ? $GLOBALS['BE_USER'] : null;
+    }
 }