Project

General

Profile

Bug #21629 » 0012688-4.4-trunk-rev6683.patch

Administrator Admin, 2009-12-19 12:59

View differences:

t3lib/class.t3lib_tcemain.php (working copy)
);
break;
case 'db':
$valueArray = $this->checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,'group', $table);
$valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, 'group', $table, $field);
break;
}
}
......
$this->remapStackRecords[$table][$id] = array('remapStackIndex' => count($this->remapStack));
$this->remapStack[] = array(
'func' => 'checkValue_group_select_processDBdata',
'args' => array($valueArray,$tcaFieldConf,$id,$status,'select',$table),
'args' => array($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field),
'pos' => array('valueArray' => 0, 'tcaFieldConf' => 1, 'id' => 2, 'table' => 5),
'field' => $field
);
$unsetResult = true;
} else {
$valueArray = $this->checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,'select', $table);
$valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field);
}
}
......
} else {
$theFileValues=t3lib_div::trimExplode(',',$curValue,1);
}
$currentFilesForHistory = implode(',', $theFileValues);
// DELETE files: If existing files were found, traverse those and register files for deletion which has been removed:
if (count($theFileValues)) {
......
}
if ($status=='update') {
$dbAnalysis->writeMM($tcaFieldConf['MM'],$id,0);
$newFiles = implode(',', $dbAnalysis->getValueArray());
list(,,$recFieldName) = explode(':', $recFID);
if ($currentFilesForHistory != $newFiles) {
$this->mmHistoryRecords[$currentTable . ':' . $id]['oldRecord'][$recFieldName] = $currentFilesForHistory;
$this->mmHistoryRecords[$currentTable . ':' . $id]['newRecord'][$recFieldName] = $newFiles;
} else {
$this->mmHistoryRecords[$currentTable . ':' . $id]['oldRecord'][$currentField] = '';
$this->mmHistoryRecords[$currentTable . ':' . $id]['newRecord'][$currentField] = '';
}
} else {
$this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, 0); // This will be traversed later to execute the actions
}
......
* @param string Status string ('update' or 'new')
* @param string The type, either 'select', 'group' or 'inline'
* @param string Table name, needs to be passed to t3lib_loadDBGroup
* @param string field name, needs to be set for writing to sys_history
* @return array Modified value array
*/
function checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,$type,$currentTable) {
function checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, $type, $currentTable, $currentField) {
$tables = $type=='group'?$tcaFieldConf['allowed']:$tcaFieldConf['foreign_table'].','.$tcaFieldConf['neg_foreign_table'];
$prep = $type=='group'?$tcaFieldConf['prepend_tname']:$tcaFieldConf['neg_foreign_table'];
$newRelations = implode(',', $valueArray);
$dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
/* @var $dbAnalysis t3lib_loadDBGroup */
$dbAnalysis->registerNonTableValues=$tcaFieldConf['allowNonIdValues'] ? 1 : 0;
$dbAnalysis->start(implode(',',$valueArray),$tables, '', 0, $currentTable, $tcaFieldConf);
$dbAnalysis->start($newRelations, $tables, '', 0, $currentTable, $tcaFieldConf);
if ($tcaFieldConf['MM']) {
if ($status=='update') {
$oldRelations_dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
/* @var $oldRelations_dbAnalysis t3lib_loadDBGroup */
$oldRelations_dbAnalysis->registerNonTableValues=$tcaFieldConf['allowNonIdValues'] ? 1 : 0;
// db analysis with $id will initialize with the existing relations
$oldRelations_dbAnalysis->start('', $tables, $tcaFieldConf['MM'], $id, $currentTable, $tcaFieldConf);
$oldRelations = implode(',', $oldRelations_dbAnalysis->getValueArray());
$dbAnalysis->writeMM($tcaFieldConf['MM'],$id,$prep);
if ($oldRelations != $newRelations) {
$this->mmHistoryRecords[$currentTable . ':' . $id]['oldRecord'][$currentField] = $oldRelations;
$this->mmHistoryRecords[$currentTable . ':' . $id]['newRecord'][$currentField] = $newRelations;
} else {
$this->mmHistoryRecords[$currentTable . ':' . $id]['oldRecord'][$currentField] = '';
$this->mmHistoryRecords[$currentTable . ':' . $id]['newRecord'][$currentField] = '';
}
} else {
$this->dbAnalysisStore[] = array($dbAnalysis,$tcaFieldConf['MM'],$id,$prep,$currentTable); // This will be traversed later to execute the actions
}
......
// Unset the fields which are similar:
foreach($fieldArray as $col => $val) {
if (
!strcmp($val,$currentRecord[$col]) || // Unset fields which matched exactly.
($cRecTypes[$col]=='int' && $currentRecord[$col]==0 && !strcmp($val,'')) // Now, a situation where TYPO3 tries to put an empty string into an integer field, we should not strcmp the integer-zero and '', but rather accept them to be similar.
) {
!$GLOBALS['TCA'][$table]['columns'][$col]['config']['MM'] && // Do not unset MM relation fields, since equality of the MM count doesn't always mean that relations haven't changed.
( !strcmp($val,$currentRecord[$col]) || // Unset fields which matched exactly.
($cRecTypes[$col]=='int' && $currentRecord[$col]==0 && !strcmp($val,'')) // Now, a situation where TYPO3 tries to put an empty string into an integer field, we should not strcmp the integer-zero and '', but rather accept them to be similar.
)
) {
unset($fieldArray[$col]);
} else {
$this->historyRecords[$table.':'.$id]['oldRecord'][$col] = $currentRecord[$col];
$this->historyRecords[$table.':'.$id]['newRecord'][$col] = $fieldArray[$col];
if (!isset($this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$col])) {
$this->historyRecords[$table . ':' . $id]['oldRecord'][$col] = $currentRecord[$col];
} elseif ($this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$col] != $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$col]) {
$this->historyRecords[$table . ':' . $id]['oldRecord'][$col] = $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$col];
}
if (!isset($this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$col])) {
$this->historyRecords[$table . ':' . $id]['newRecord'][$col] = $fieldArray[$col];
} elseif ($this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$col] != $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$col]) {
$this->historyRecords[$table . ':' . $id]['newRecord'][$col] = $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$col];
}
}
}
} else { // If the current record does not exist this is an error anyways and we just return an empty array here.
(2-2/2)