Index: t3lib/tceforms/class.t3lib_tceforms_suggest.php =================================================================== --- t3lib/tceforms/class.t3lib_tceforms_suggest.php (revision 6965) +++ t3lib/tceforms/class.t3lib_tceforms_suggest.php (working copy) @@ -129,9 +129,17 @@ } $TSconfig = t3lib_BEfunc::getPagesTSconfig($pageId); - + $queryTables = array(); + $foreign_table_where = ''; $wizardConfig = $GLOBALS['TCA'][$table]['columns'][$field]['config']['wizards']['suggest']; + if (isset($GLOBALS['TCA'][$table]['columns'][$field]['config']['allowed'])) { $queryTables = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['allowed']); + } elseif (isset($GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table'])) { + $queryTables = array($GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table']); + $foreign_table_where = $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table_where']; + // strip ORDER BY clause + $foreign_table_where = trim(preg_replace('/ORDER[[:space:]]+BY.*/i', '', $foreign_table_where)); + } $resultRows = array(); // fetch the records for each query table. A query table is a table from which records are allowed to @@ -168,6 +176,17 @@ if (is_array($TSconfig['TCEFORM.'][$table.'.'][$field.'.']['suggest.'][$queryTable.'.'])) { $config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.'][$table.'.'][$field.'.']['suggest.'][$queryTable.'.']); } + + //process addWhere + if (!isset($config['addWhere']) && $foreign_table_where) { + $config['addWhere'] = $foreign_table_where; + } + if (isset($config['addWhere'])) { + $config['addWhere'] = strtr(' ' . $config['addWhere'], array( + '###THIS_UID###' => intval($uid), + '###CURRENT_PID###' => intval($pageId), + )); + } // instantiate the class that should fetch the records for this $queryTable $receiverClassName = $config['receiverClass']; if (!class_exists($receiverClassName)) { Index: t3lib/tceforms/class.t3lib_tceforms_suggest_defaultreceiver.php =================================================================== --- t3lib/tceforms/class.t3lib_tceforms_suggest_defaultreceiver.php (revision 6965) +++ t3lib/tceforms/class.t3lib_tceforms_suggest_defaultreceiver.php (working copy) @@ -131,6 +131,10 @@ if ($GLOBALS['TCA'][$this->table]['ctrl']['versioningWS'] == true) { $this->addWhere .= ' AND t3ver_wsid = 0'; } + + if (isset($config['addWhere'])) { + $this->addWhere .= ' ' . $config['addWhere']; + } } /** @@ -161,7 +165,6 @@ $this->orderByStatement, $start . ', 50'); - $allRowsCount = $GLOBALS['TYPO3_DB']->sql_num_rows($res); if ($allRowsCount) {