[BUGFIX] Fix evaluation of rootLevel configuration in NewRecordController 55/50055/2
authorGeorg Ringer <georg.ringer@gmail.com>
Wed, 28 Sep 2016 06:44:38 +0000 (08:44 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Wed, 28 Sep 2016 12:46:46 +0000 (14:46 +0200)
If the rootLevel is set to true, it should behave like 1 and the record
is only available at the root page.

Resolves: #78085
Releases: master, 7.6
Change-Id: Iefcc7ce8b16a04fa288ab23c9116b8181de113a8
Reviewed-on: https://review.typo3.org/50055
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Controller/NewRecordController.php

index 3b188db..3f243b2 100644 (file)
@@ -483,11 +483,12 @@ class NewRecordController extends AbstractModule
             if (is_array($GLOBALS['TCA'])) {
                 $groupName = '';
                 foreach ($GLOBALS['TCA'] as $table => $v) {
+                    $rootLevelConfiguration = isset($v['ctrl']['rootLevel']) ? (int)$v['ctrl']['rootLevel'] : -1;
                     if ($table != 'pages'
                         && $this->showNewRecLink($table)
                         && $this->isTableAllowedForThisPage($this->pageinfo, $table)
                         && $this->getBackendUserAuthentication()->check('tables_modify', $table)
-                        && (($v['ctrl']['rootLevel'] xor $this->id) || $v['ctrl']['rootLevel'] == -1)
+                        && ($rootLevelConfiguration === -1 || ($this->id xor $rootLevelConfiguration))
                         && $this->getBackendUserAuthentication()->workspaceCreateNewRecord(($this->pageinfo['_ORIG_uid'] ? $this->pageinfo['_ORIG_uid'] : $this->id), $table)
                     ) {
                         $newRecordIcon = $this->moduleTemplate->getIconFactory()->getIconForRecord($table, [], Icon::SIZE_SMALL)->render();