[TASK] Use BE_USER->isAdmin() 14/54414/2
authorBenni Mack <benni@typo3.org>
Tue, 17 Oct 2017 11:02:48 +0000 (13:02 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 17 Oct 2017 11:46:30 +0000 (13:46 +0200)
TYPO3 Core does not use isAdmin() API of BackendUsers
consistently, as there are some places where a direct
access to $BE_USER->[admin].

Resolves: #82783
Releases: master
Change-Id: I5ae42a79826a3512be8755aabb32b910f4f6c826
Reviewed-on: https://review.typo3.org/54414
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/core/Classes/Integrity/DatabaseIntegrityCheck.php
typo3/sysext/fluid/Classes/ViewHelpers/Be/PageInfoViewHelper.php
typo3/sysext/impexp/Classes/Controller/ImportExportController.php
typo3/sysext/info/Classes/Controller/InfoModuleController.php
typo3/sysext/info/Classes/Controller/TranslationStatusController.php
typo3/sysext/recycler/Classes/Utility/RecyclerUtility.php

index 1051c3c..d07753a 100644 (file)
@@ -936,7 +936,7 @@ function jumpToUrl(URL) {
             // On root-level of page tree
             // Make Icon
             $iconImg = '<span title="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '">' . $this->iconFactory->getIcon('apps-pagetree-root', Icon::SIZE_SMALL)->render() . '</span>';
-            if ($GLOBALS['BE_USER']->user['admin']) {
+            if ($GLOBALS['BE_USER']->isAdmin()) {
                 $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages', 0);
             } else {
                 $theIcon = $iconImg;
index 9e7d7ae..02faf4a 100644 (file)
@@ -2660,7 +2660,7 @@ class BackendUtility
             $suffix = '';
             // Find allowed languages (if none, all are allowed!)
             $allowedLanguages = null;
-            if (!$beUser->user['admin'] && $beUser->groupData['allowed_languages'] !== '') {
+            if (!$beUser->isAdmin() && $beUser->groupData['allowed_languages'] !== '') {
                 $allowedLanguages = array_flip(explode(',', $beUser->groupData['allowed_languages']));
             }
             // Traverse the view order, match first occurrence:
index 71890a3..8a54801 100644 (file)
@@ -2057,7 +2057,7 @@ class PageLayoutView implements LoggerAwareInterface
      */
     protected function isDragAndDropAllowed(array $row)
     {
-        if ($this->getBackendUser()->user['admin']
+        if ($this->getBackendUser()->isAdmin()
             || ((int)$row['editlock'] === 0 && (int)$this->pageinfo['editlock'] === 0)
             && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)
             && $this->getBackendUser()->checkAuthMode('tt_content', 'CType', $row['CType'], $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'])
@@ -2546,7 +2546,7 @@ class PageLayoutView implements LoggerAwareInterface
             }
             // Remove disallowed languages
             if (!empty($availableTranslations)
-                && !$this->getBackendUser()->user['admin']
+                && !$this->getBackendUser()->isAdmin()
                 && $this->getBackendUser()->groupData['allowed_languages'] !== ''
             ) {
                 $allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData['allowed_languages']));
index 9c6aa0e..1dfdd08 100644 (file)
@@ -264,7 +264,7 @@ class DatabaseIntegrityCheck
      */
     public function fixLostRecord($table, $uid)
     {
-        if ($table && $GLOBALS['TCA'][$table] && $uid && is_array($this->lRecords[$table][$uid]) && $GLOBALS['BE_USER']->user['admin']) {
+        if ($table && $GLOBALS['TCA'][$table] && $uid && is_array($this->lRecords[$table][$uid]) && $GLOBALS['BE_USER']->isAdmin()) {
             $updateFields = [
                 'pid' => 0
             ];
index 3157b21..3aaa007 100644 (file)
@@ -85,7 +85,7 @@ class PageInfoViewHelper extends AbstractBackendViewHelper
             // On root-level of page tree
             // Make Icon
             $theIcon = '<span title="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '">' . $iconFactory->getIcon('apps-pagetree-page-domain', Icon::SIZE_SMALL)->render() . '</span>';
-            if ($GLOBALS['BE_USER']->user['admin']) {
+            if ($GLOBALS['BE_USER']->isAdmin()) {
                 $theIcon = BackendUtility::wrapClickMenuOnIcon($theIcon, 'pages', 0);
             }
         }
index e0fa3d3..7977649 100644 (file)
@@ -330,7 +330,7 @@ class ImportExportController extends BaseScriptClass
         // Input data grabbed:
         $inData = GeneralUtility::_GP('tx_impexp');
         if ((string)$inData['action'] === 'import') {
-            if ($this->id && is_array($this->pageinfo) || $this->getBackendUser()->user['admin'] && !$this->id) {
+            if ($this->id && is_array($this->pageinfo) || $this->getBackendUser()->isAdmin() && !$this->id) {
                 if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
                     // View
                     $onClick = BackendUtility::viewOnClick(
@@ -824,8 +824,8 @@ class ImportExportController extends BaseScriptClass
     {
         $access = is_array($this->pageinfo) ? 1 : 0;
         $beUser = $this->getBackendUser();
-        if ($this->id && $access || $beUser->user['admin'] && !$this->id) {
-            if ($beUser->user['admin'] && !$this->id) {
+        if ($this->id && $access || $beUser->isAdmin() && !$this->id) {
+            if ($beUser->isAdmin() && !$this->id) {
                 $this->pageinfo = ['title' => '[root-level]', 'uid' => 0, 'pid' => 0];
             }
             if ($inData['new_import']) {
index 24426a3..e89111a 100644 (file)
@@ -95,8 +95,8 @@ class InfoModuleController extends BaseScriptClass
             $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
         }
         $access = is_array($this->pageinfo);
-        if ($this->id && $access || $this->backendUser->user['admin'] && !$this->id) {
-            if ($this->backendUser->user['admin'] && !$this->id) {
+        if ($this->id && $access || $this->backendUser->isAdmin() && !$this->id) {
+            if ($this->backendUser->isAdmin() && !$this->id) {
                 $this->pageinfo = ['title' => '[root-level]', 'uid' => 0, 'pid' => 0];
             }
             // JavaScript
index 28922a9..7ab5735 100644 (file)
@@ -356,7 +356,7 @@ class TranslationStatusController extends \TYPO3\CMS\Backend\Module\AbstractFunc
      */
     public function getSystemLanguages()
     {
-        if (!$this->getBackendUser()->user['admin'] && $this->getBackendUser()->groupData['allowed_languages'] !== '') {
+        if (!$this->getBackendUser()->isAdmin() && $this->getBackendUser()->groupData['allowed_languages'] !== '') {
             $allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData['allowed_languages']));
         }
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
index eba315d..02d6278 100644 (file)
@@ -213,7 +213,7 @@ class RecyclerUtility
      */
     public static function getModifyableTables()
     {
-        if ((bool)$GLOBALS['BE_USER']->user['admin']) {
+        if ($GLOBALS['BE_USER']->isAdmin()) {
             $tables = array_keys($GLOBALS['TCA']);
         } else {
             $tables = explode(',', $GLOBALS['BE_USER']->groupData['tables_modify']);