Index: t3lib/tceforms/class.t3lib_tceforms_tree.php =================================================================== --- t3lib/tceforms/class.t3lib_tceforms_tree.php (revision 9259) +++ t3lib/tceforms/class.t3lib_tceforms_tree.php (revision ) @@ -61,6 +61,7 @@ ); $treeDataProvider->setSelectedList(implode(',', $selectedNodes)); $treeDataProvider->initializeTreeData(); + $treeDataProvider->setGeneratedTSConfig($tceForms->setTSconfig($table, $row)); $treeRenderer = t3lib_div::makeInstance('t3lib_tree_Tca_ExtJsArrayRenderer'); $tree = t3lib_div::makeInstance('t3lib_tree_Tca_TcaTree'); Index: t3lib/tree/tca/class.t3lib_tree_tca_databasetreedataprovider.php =================================================================== --- t3lib/tree/tca/class.t3lib_tree_tca_databasetreedataprovider.php (revision 9400) +++ t3lib/tree/tca/class.t3lib_tree_tca_databasetreedataprovider.php (revision ) @@ -80,6 +80,24 @@ protected $idCache = array(); /** + * uidWhiteList contains all Uids which may be allowed to display according to + * beUser Rights and foreign_table_where + * @var array $uidWhiteList + */ + protected $uidWhiteList = array(); + + /** + * node sort values (the orderings from foreign_Table_where evaluation) + * @var array + */ + protected $nodeSortValues = array(); + + /** + * @var array TCEforms compiled TSConfig array + */ + protected $generatedTSConfig = array(); + + /** * Sets the label field * * @param string $labelField @@ -239,13 +257,14 @@ $node->setExpanded($this->isExpanded($basicNode)); } $node->setSelectable(!t3lib_div::inList($this->getNonSelectableLevelList(), $level)); + $node->setSortValue($this->nodeSortValues[$node->getId()]); $node->setIcon(t3lib_iconWorks::mapRecordTypeToSpriteIconClass($this->tableName, $row)); $node->setId($basicNode->getId()); $node->setParentNode($parent); if ($basicNode->hasChildNodes()) { $node->setHasChildren(TRUE); - $childNodes = t3lib_div::makeInstance('t3lib_tree_NodeCollection'); + $childNodes = t3lib_div::makeInstance('t3lib_tree_SortedNodeCollection'); foreach ($basicNode->getChildNodes() as $child) { $childNodes->append($this->buildRepresentationForNode($child, $node, $level + 1)); } @@ -261,6 +280,7 @@ */ public function initializeTreeData() { parent::initializeTreeData(); + $this->generateUidWhitelist(); $this->treeData = t3lib_div::makeInstance('t3lib_tree_Node'); $this->treeData->setId($this->getRootUid()); @@ -327,7 +347,7 @@ $allowedArray = array(); foreach ($children as $child) { - if (!in_array($child, $this->idCache)) { + if (!in_array($child, $this->idCache) && in_array($child, $this->uidWhiteList)) { $allowedArray[] = $child; } } @@ -338,6 +358,21 @@ } /** + * + */ + protected function generateUidWhitelist() { + $res = t3lib_BEfunc::exec_foreign_table_where_query( + $GLOBALS['TCA'][$this->getTableName()]['columns'][$this->getLookupField()], + $this->getLookupField(), + $this->getGeneratedTSConfig(), + '' + ); + while ($tempRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { + $this->uidWhiteList[] = $tempRow['uid']; + } + $this->nodeSortValues = array_flip($this->uidWhiteList); + } + /** * Gets related records depending on TCA configuration * * @param $row @@ -371,7 +406,7 @@ $columnConfiguration['foreign_table'], " (CONCAT(','," . $columnConfiguration['foreign_field'] . ",',') LIKE '%," . intval($uid) . ",%' " . (intval($uid) == 0 ? (" OR " . $columnConfiguration['foreign_field'] . " = ''") : '' ) - . ") " . t3lib_BEfunc::deleteClause( $columnConfiguration['foreign_table']) + . ") " ); foreach ($records as $record) { $relatedUids[] = $record['uid']; @@ -382,7 +417,7 @@ $columnConfiguration['foreign_table'], " (CONCAT(','," . $this->getLookupField() . ",',') LIKE '%," . intval($uid) . ",%' " . (intval($uid) == 0 ? (" OR " . $this->getLookupField() . " = ''") : '' ) - . ") " . t3lib_BEfunc::deleteClause( $columnConfiguration['foreign_table']) + . ") " ); foreach ($records as $record) { $relatedUids[] = $record['uid']; @@ -395,7 +430,7 @@ $columnConfiguration['foreign_table'], " (CONCAT(','," . $this->getLookupField() . ",',') LIKE '%," . intval($uid) . ",%' " . (intval($uid) == 0 ? (" OR " . $this->getLookupField() . " = ''") : '' ) - . ") " . t3lib_BEfunc::deleteClause( $columnConfiguration['foreign_table']) + . ") " ); foreach ($records as $record) { $relatedUids[] = $record['uid']; @@ -435,7 +470,7 @@ $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 'uid', $columnConfiguration['foreign_table'], - $columnConfiguration['foreign_field'] . '=' . intval($uid) . ' ' . t3lib_BEfunc::deleteClause($columnConfiguration['foreign_table']) + $columnConfiguration['foreign_field'] . '=' . intval($uid) . ' ' ); foreach ($records as $record) { $relatedUids[] = $record['uid']; @@ -451,6 +486,24 @@ return $relatedUids; } + /** + * setter for the TSConfig from TCEforms + * used to evalualate and replace markers in foreign_table_where + * @param array $generatedTSConfig + * @return void + */ + public function setGeneratedTSConfig(array $generatedTSConfig) { + $this->generatedTSConfig = $generatedTSConfig; -} + } + /** + * getter for the TSConfig from TCEforms + * @return array + */ + public function getGeneratedTSConfig() { + return $this->generatedTSConfig; + } + +} + ?> \ No newline at end of file