[TASK] Introduce early returns in DataHandler::canDeletePage() 96/42296/3
authorAndreas Wolf <andreas.wolf@typo3.org>
Sun, 7 Jun 2015 09:31:31 +0000 (11:31 +0200)
committerAndreas Wolf <andreas.wolf@typo3.org>
Wed, 5 Aug 2015 21:59:54 +0000 (23:59 +0200)
Change-Id: Ib73136e767ee1fa8b97684a3cf03f763db8d907e
Resolves: #68775
Releases: master
Reviewed-on: http://review.typo3.org/42296
Reviewed-by: Daniel Maier <dani-maier@gmx.de>
Tested-by: Daniel Maier <dani-maier@gmx.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
typo3/sysext/core/Classes/DataHandling/DataHandler.php

index c3f9adf..9c7f4bf 100644 (file)
@@ -5018,46 +5018,46 @@ class DataHandler {
         */
        public function canDeletePage($uid) {
                // If we may at all delete this page
-               if ($this->doesRecordExist('pages', $uid, 'delete')) {
-                       if ($this->deleteTree) {
-                               // Returns the branch
-                               $brExist = $this->doesBranchExist('', $uid, $this->pMap['delete'], 1);
-                               // Checks if we had permissions
-                               if ($brExist != -1) {
-                                       if ($this->noRecordsFromUnallowedTables($brExist . $uid)) {
-                                               $pagesInBranch = GeneralUtility::trimExplode(',', $brExist . $uid, TRUE);
-                                               foreach ($pagesInBranch as $pageInBranch) {
-                                                       if (!$this->BE_USER->recordEditAccessInternals('pages', $pageInBranch, FALSE, FALSE, TRUE)) {
-                                                               return 'Attempt to delete page which has prohibited localizations.';
-                                                       }
-                                               }
-                                               return $pagesInBranch;
-                                       } else {
-                                               return 'Attempt to delete records from disallowed tables';
-                                       }
-                               } else {
-                                       return 'Attempt to delete pages in branch without permissions';
-                               }
-                       } else {
-                               // returns the branch
-                               $brExist = $this->doesBranchExist('', $uid, $this->pMap['delete'], 1);
-                               // Checks if branch exists
-                               if ($brExist == '') {
-                                       if ($this->noRecordsFromUnallowedTables($uid)) {
-                                               if ($this->BE_USER->recordEditAccessInternals('pages', $uid, FALSE, FALSE, TRUE)) {
-                                                       return array($uid);
-                                               } else {
-                                                       return 'Attempt to delete page which has prohibited localizations.';
-                                               }
-                                       } else {
-                                               return 'Attempt to delete records from disallowed tables';
-                                       }
-                               } else {
-                                       return 'Attempt to delete page which has subpages';
+               if (!$this->doesRecordExist('pages', $uid, 'delete')) {
+                       return 'Attempt to delete page without permissions';
+               }
+
+               if ($this->deleteTree) {
+                       // Returns the branch
+                       $brExist = $this->doesBranchExist('', $uid, $this->pMap['delete'], 1);
+                       // Checks if we had permissions
+                       if ($brExist == -1) {
+                               return 'Attempt to delete pages in branch without permissions';
+                       }
+
+                       if (!$this->noRecordsFromUnallowedTables($brExist . $uid)) {
+                               return 'Attempt to delete records from disallowed tables';
+                       }
+
+                       $pagesInBranch = GeneralUtility::trimExplode(',', $brExist . $uid, TRUE);
+                       foreach ($pagesInBranch as $pageInBranch) {
+                               if (!$this->BE_USER->recordEditAccessInternals('pages', $pageInBranch, FALSE, FALSE, TRUE)) {
+                                       return 'Attempt to delete page which has prohibited localizations.';
                                }
                        }
+                       return $pagesInBranch;
                } else {
-                       return 'Attempt to delete page without permissions';
+                       // returns the branch
+                       $brExist = $this->doesBranchExist('', $uid, $this->pMap['delete'], 1);
+                       // Checks if branch exists
+                       if ($brExist != '') {
+                               return 'Attempt to delete page which has subpages';
+                       }
+
+                       if (!$this->noRecordsFromUnallowedTables($uid)) {
+                               return 'Attempt to delete records from disallowed tables';
+                       }
+
+                       if ($this->BE_USER->recordEditAccessInternals('pages', $uid, FALSE, FALSE, TRUE)) {
+                               return array($uid);
+                       } else {
+                               return 'Attempt to delete page which has prohibited localizations.';
+                       }
                }
        }