[BUGFIX] tcaTree: make own record unselectable
authorSteffen Ritter <info@rs-websystems.de>
Wed, 2 Mar 2011 14:50:40 +0000 (15:50 +0100)
committerJigal van Hemert <jigal@xs4all.nl>
Wed, 6 Apr 2011 17:37:42 +0000 (19:37 +0200)
Relations to an own record is not useful. You could exclude is via tca "andWhere"
This is not nice, because you wouldn't  see the whole tree.
Just make the own record unselectable.

Change-Id: I90a40df315055c116bf4d2b688694120606b62b9
Resolves: #M16726
Reviewed-on: http://review.typo3.org/977
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Kay Strobach
Reviewed-by: Tolleiv Nietsch
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
t3lib/tree/tca/class.t3lib_tree_tca_abstracttcatreedataprovider.php
t3lib/tree/tca/class.t3lib_tree_tca_databasetreedataprovider.php
t3lib/tree/tca/class.t3lib_tree_tca_dataproviderfactory.php

index 71824dd..013e8c2 100644 (file)
@@ -71,6 +71,11 @@ abstract class t3lib_tree_Tca_AbstractTcaTreeDataProvider extends t3lib_tree_Abs
         */
        protected $itemWhiteList = array();
 
+       /**
+        * Contains all ids which are not allowed to be selected
+        */
+       protected $itemUnselectableList = array();
+
        /**
         * Sets the id of the tree
         *
@@ -223,6 +228,25 @@ abstract class t3lib_tree_Tca_AbstractTcaTreeDataProvider extends t3lib_tree_Abs
        public function getItemWhiteList() {
                return $this->itemWhiteList;
        }
+
+       /**
+        * Setter for $itemUnselectableList
+        *
+        * @param array $itemUnselectableList
+        * @return void
+        */
+       public function setItemUnselectableList(array $itemUnselectableList) {
+               $this->itemUnselectableList = $itemUnselectableList;
+       }
+
+       /**
+        * Getter for $itemUnselectableList
+        *
+        * @return array
+        */
+       public function getItemUnselectableList() {
+               return $this->itemUnselectableList;
+       }
 }
 
 ?>
\ No newline at end of file
index fa524c7..c790abb 100644 (file)
@@ -260,7 +260,10 @@ class t3lib_tree_Tca_DatabaseTreeDataProvider extends t3lib_tree_Tca_AbstractTca
                }
                $node->setId($basicNode->getId());
 
-               $node->setSelectable(!t3lib_div::inList($this->getNonSelectableLevelList(), $level));
+               $node->setSelectable(
+                       !t3lib_div::inList($this->getNonSelectableLevelList(), $level)
+                       && !in_array($basicNode->getId(), $this->getItemUnselectableList())
+               );
                $node->setSortValue($this->nodeSortValues[$basicNode->getId()]);
 
                $node->setIcon(t3lib_iconWorks::mapRecordTypeToSpriteIconClass($this->tableName, $row));
@@ -481,4 +484,4 @@ class t3lib_tree_Tca_DatabaseTreeDataProvider extends t3lib_tree_Tca_AbstractTca
        }
 }
 
-?>
\ No newline at end of file
+?>
index bb11d15..df17e44 100644 (file)
@@ -50,6 +50,8 @@ class t3lib_tree_Tca_DataProviderFactory {
                }
 
                if ($tcaConfiguration['internal_type'] == 'db') {
+                       $unselectableUids = array();
+
                        /**
                         * @var $dataProvider t3lib_tree_Tca_DatabaseTreeDataProvider
                         */
@@ -59,6 +61,10 @@ class t3lib_tree_Tca_DataProviderFactory {
                                $tableName = $tcaConfiguration['foreign_table'];
                                $dataProvider->setTableName($tableName);
 
+                               if ($tableName == $table) {
+                                       $unselectableUids[] = $currentValue['uid'];
+                               }
+
                                t3lib_div::loadTCA($tableName);
                        } else {
                                throw new InvalidArgumentException(
@@ -107,6 +113,8 @@ class t3lib_tree_Tca_DataProviderFactory {
                                                1288215889
                                        );
                                }
+
+                               $dataProvider->setItemUnselectableList($unselectableUids);
                        } else {
                                throw new InvalidArgumentException(
                                        'TCA Tree configuration is invalid: "treeConfig" array is missing',
@@ -133,4 +141,4 @@ class t3lib_tree_Tca_DataProviderFactory {
        }
 }
 
-?>
\ No newline at end of file
+?>