[BUGFIX] Disable restricted users to handle page records in pagetree 54/21154/2
authorFrank Frewer <info@frankfrewer.de>
Thu, 11 Apr 2013 17:53:39 +0000 (19:53 +0200)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Wed, 29 May 2013 17:04:06 +0000 (19:04 +0200)
This patch hides the context menu entries 'disable'/'enable', 'edit',
'new', 'cut', 'copy', 'paste into', 'paste after' and 'delete' in
case an user is restricted to only non default languages.
Additionally it throws an error message if the user is trying to edit
a page title directly in the pagetree via double click.

Resolves: #47126
Releases: 6.2,6.1, 6.0, 4.7, 4.5
Change-Id: I13537529d4b72763c3a2ff5c75b5ae53a9e3fec1
Reviewed-on: https://review.typo3.org/21154
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
typo3/sysext/backend/Classes/Tree/Pagetree/Commands.php
typo3/sysext/backend/Classes/Tree/Pagetree/PagetreeNode.php

index 051c69b..53faeb4 100644 (file)
@@ -114,8 +114,12 @@ class Commands {
         * @return void
         */
        static public function updateNodeLabel(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode $node, $updatedLabel) {
-               $data['pages'][$node->getWorkspaceId()][$node->getTextSourceField()] = $updatedLabel;
-               self::processTceCmdAndDataMap(array(), $data);
+               if ($GLOBALS['BE_USER']->checkLanguageAccess(0)) {
+                       $data['pages'][$node->getWorkspaceId()][$node->getTextSourceField()] = $updatedLabel;
+                       self::processTceCmdAndDataMap(array(), $data);
+               } else {
+                       throw new \RuntimeException(implode(chr(10), array('Editing title of page id \'' . $node->getWorkspaceId() .  '\' failed. Editing default language is not allowed.')), 1365513336);
+               }
        }
 
        /**
index 7f59e34..82ca765 100644 (file)
@@ -215,7 +215,7 @@ class PagetreeNode extends \TYPO3\CMS\Backend\Tree\ExtDirectNode {
         * @return boolean
         */
        public function canBeDisabledAndEnabled() {
-               return $this->canEdit($this->record);
+               return $this->canEdit($this->record) && $GLOBALS['BE_USER']->checkLanguageAccess(0);
        }
 
        /**
@@ -224,7 +224,7 @@ class PagetreeNode extends \TYPO3\CMS\Backend\Tree\ExtDirectNode {
         * @return boolean
         */
        public function canBeCut() {
-               return $this->canEdit($this->record) && intval($this->record['t3ver_state']) !== 2;
+               return $this->canEdit($this->record) && intval($this->record['t3ver_state']) !== 2 && $GLOBALS['BE_USER']->checkLanguageAccess(0);
        }
 
        /**
@@ -233,7 +233,7 @@ class PagetreeNode extends \TYPO3\CMS\Backend\Tree\ExtDirectNode {
         * @return boolean
         */
        public function canBeEdited() {
-               return $this->canEdit($this->record);
+               return $this->canEdit($this->record) && $GLOBALS['BE_USER']->checkLanguageAccess(0);
        }
 
        /**
@@ -242,7 +242,7 @@ class PagetreeNode extends \TYPO3\CMS\Backend\Tree\ExtDirectNode {
         * @return boolean
         */
        public function canBeCopied() {
-               return $this->canCreate($this->record) && intval($this->record['t3ver_state']) !== 2;
+               return $this->canCreate($this->record) && intval($this->record['t3ver_state']) !== 2 && $GLOBALS['BE_USER']->checkLanguageAccess(0);
        }
 
        /**
@@ -251,7 +251,7 @@ class PagetreeNode extends \TYPO3\CMS\Backend\Tree\ExtDirectNode {
         * @return boolean
         */
        public function canCreateNewPages() {
-               return $this->canCreate($this->record);
+               return $this->canCreate($this->record) && $GLOBALS['BE_USER']->checkLanguageAccess(0);
        }
 
        /**
@@ -260,7 +260,7 @@ class PagetreeNode extends \TYPO3\CMS\Backend\Tree\ExtDirectNode {
         * @return boolean
         */
        public function canBeRemoved() {
-               return $this->canRemove($this->record) && intval($this->record['t3ver_state']) !== 2;
+               return $this->canRemove($this->record) && intval($this->record['t3ver_state']) !== 2 && $GLOBALS['BE_USER']->checkLanguageAccess(0);
        }
 
        /**
@@ -269,7 +269,7 @@ class PagetreeNode extends \TYPO3\CMS\Backend\Tree\ExtDirectNode {
         * @return boolean
         */
        public function canBePastedInto() {
-               return $this->canCreate($this->record) && intval($this->record['t3ver_state']) !== 2;
+               return $this->canCreate($this->record) && intval($this->record['t3ver_state']) !== 2 && $GLOBALS['BE_USER']->checkLanguageAccess(0);
        }
 
        /**
@@ -278,7 +278,7 @@ class PagetreeNode extends \TYPO3\CMS\Backend\Tree\ExtDirectNode {
         * @return boolean
         */
        public function canBePastedAfter() {
-               return $this->canCreate($this->record) && intval($this->record['t3ver_state']) !== 2;
+               return $this->canCreate($this->record) && intval($this->record['t3ver_state']) !== 2 && $GLOBALS['BE_USER']->checkLanguageAccess(0);
        }
 
        /**
@@ -287,7 +287,7 @@ class PagetreeNode extends \TYPO3\CMS\Backend\Tree\ExtDirectNode {
         * @return boolean
         */
        public function canShowHistory() {
-               return TRUE;
+               return $GLOBALS['BE_USER']->checkLanguageAccess(0);
        }
 
        /**