diff -rupN typo3_src-6.1.1//typo3/sysext/backend/Classes/Form/ElementConditionMatcher.php typo3_src-6.1.1-patched//typo3/sysext/backend/Classes/Form/ElementConditionMatcher.php --- typo3_src-6.1.1//typo3/sysext/backend/Classes/Form/ElementConditionMatcher.php 2013-05-24 16:57:41.000000000 +0200 +++ typo3_src-6.1.1-patched//typo3/sysext/backend/Classes/Form/ElementConditionMatcher.php 2013-07-02 14:49:22.000000000 +0200 @@ -42,6 +42,11 @@ class ElementConditionMatcher { * @var array */ protected $record = array(); + + /** + * @var string + */ + protected $recordTable = ''; /** * Evaluates the provided condition and returns TRUE if the form @@ -113,6 +118,17 @@ class ElementConditionMatcher { } return $result; } + + /** + * @param string $recordTable + * @return ElementConditionMatcher + */ + public function setRecordTable($recordTable) + { + $this->recordTable = $recordTable; + + return $this; + } /** * Evaluates the provided condition and returns TRUE if the form @@ -176,6 +192,73 @@ class ElementConditionMatcher { } return $result; } + + /** + * @param string $fieldName + * @param array $record + * @return string + */ + protected function getRecordFieldValue($fieldName, $record, $recordTable = '') + { + if (strpos($fieldName, '.') !== false) { + $fieldValue = null; + + $fieldNameParts = explode('.', $fieldName, 2); + $parentFieldName = $fieldNameParts[0]; + $subFieldName = $fieldNameParts[1]; + + if (array_key_exists($parentFieldName, $record) && $record[$parentFieldName]) { + $recordFieldValue = $record[$parentFieldName]; + + if ($recordTable) { + $fieldTCA = $GLOBALS['TCA'][$recordTable]['columns'][$parentFieldName]; + + $subRecordTable = ''; + $subRecordUid = 0; + switch ($fieldTCA['config']['type']) { + case 'select': + break; + case 'group': + if ($fieldTCA['config']['internal_type'] == 'db') { + $recordFieldValues = explode(',', $recordFieldValue); + $allowedTables = array_map('trim', explode(',', $fieldTCA['config']['allowed'])); + + if (count($allowedTables) === 1 || is_numeric($recordFieldValues)) { + $subRecordTable = array_shift($allowedTables); + } else { + foreach ($allowedTables as $table) { + if (strpos($recordFieldValues[0], $table) === 0) { + $subRecordTable = $table; + break; + } + } + } + + $subRecordUid = (int)array_shift(explode('|', str_replace($subRecordTable . '_', '', $recordFieldValue))); + } + break; + case 'inline': + break; + } + + if ($subRecordTable && $subRecordUid) { + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $subRecordTable, 'uid=' . $subRecordUid . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($subRecordTable)); + $subRecord = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); + $GLOBALS['TYPO3_DB']->sql_free_result($res); + + if ($subRecord) { + \TYPO3\CMS\Backend\Utility\BackendUtility::fixVersioningPid($subRecordTable, $subRecord); + $fieldValue = $this->getRecordFieldValue($subFieldName, $subRecord, $subRecordTable); + } + } + } + } + } else { + $fieldValue = $record[$fieldName]; + } + + return $fieldValue; + } /** * Evaluates conditions concerning a field of the current record. @@ -197,7 +280,7 @@ class ElementConditionMatcher { $fieldValue = $this->record[$fieldName][$this->flexformValueKey]; } } else { - $fieldValue = $this->record[$fieldName]; + $fieldValue = $this->getRecordFieldValue($fieldName, $this->record, $this->recordTable); } $result = FALSE; diff -rupN typo3_src-6.1.1//typo3/sysext/backend/Classes/Form/FormEngine.php typo3_src-6.1.1-patched//typo3/sysext/backend/Classes/Form/FormEngine.php --- typo3_src-6.1.1//typo3/sysext/backend/Classes/Form/FormEngine.php 2013-05-24 16:57:41.000000000 +0200 +++ typo3_src-6.1.1-patched//typo3/sysext/backend/Classes/Form/FormEngine.php 2013-07-02 13:53:07.000000000 +0200 @@ -1007,6 +1007,7 @@ class FormEngine { if (is_array($PA['fieldConf']) && $PA['fieldConf']['displayCond'] && is_array($row)) { /** @var $elementConditionMatcher \TYPO3\CMS\Backend\Form\ElementConditionMatcher */ $elementConditionMatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\ElementConditionMatcher'); + $elementConditionMatcher->setRecordTable($table); $displayConditionResult = $elementConditionMatcher->match($PA['fieldConf']['displayCond'], $row); } @@ -2934,6 +2935,7 @@ function ' . $evalData . '(value) { /** @var $elementConditionMatcher \TYPO3\CMS\Backend\Form\ElementConditionMatcher */ $elementConditionMatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\ElementConditionMatcher'); + $elementConditionMatcher->setRecordTable($table); foreach ($rotateLang as $vDEFkey) { $vDEFkey = 'v' . $vDEFkey;