doesRecordExist($table,$uid,'show')) { // Set up fields which should not be processed. They are still written - just passed through no-questions-asked! $nonFields = array('uid','pid','t3ver_id','t3ver_oid','t3ver_wsid','t3ver_label','t3ver_state','t3ver_swapmode','t3ver_count','t3ver_stage','t3ver_tstamp','perms_userid','perms_groupid','perms_user','perms_group','perms_everybody'); // Select main record: $row = $this->recordInfo($table,$uid,'*'); if (is_array($row)) { // Merge in override array. $row = array_merge($row,$overrideArray); // Traverse ALL fields of the selected record: foreach($row as $field => $value) { if (!in_array($field,$nonFields)) { // Get TCA configuration for the field: $conf = $TCA[$table]['columns'][$field]['config']; if (is_array($conf)) { // Processing based on the TCA config field type (files, references, flexforms...) $value = $this->copyRecord_procBasedOnFieldType($table,$uid,$field,$value,$row,$conf); } // Add value to array. $row[$field] = $value; } } // Force versioning related fields: $row['pid'] = $pid; // Setting original UID: if ($TCA[$table]['ctrl']['origUid']) { $row[$TCA[$table]['ctrl']['origUid']] = $uid; } // Do the copy by internal function $theNewSQLID = $this->insertNewCopyVersion($table,$row,$pid); if ($theNewSQLID) { $this->dbAnalysisStoreExec(); $this->dbAnalysisStore=array(); return $this->copyMappingArray[$table][$uid] = $theNewSQLID; } } else $this->log($table,$uid,3,0,1,'Attempt to rawcopy/versionize record that did not exist!'); } else $this->log($table,$uid,3,0,1,'Attempt to rawcopy/versionize record without copy permission'); } } /** * Modifying a field value for any situation regarding files/references: * For attached files: take current filenames and prepend absolute paths so they get copied. * For DB references: Nothing done. * * @param array TCE field config * @param integer Record UID * @param string Field value (eg. list of files) * @return string The (possibly modified) value * @see copyRecord(), copyRecord_flexFormCallBack() */ function copyRecord_procFilesRefs($conf, $uid, $value) { // Prepend absolute paths to files: if ($conf['type']=='group' && $conf['internal_type']=='file') { // Get an array with files as values: if ($conf['MM']) { $theFileValues = array(); $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup'); $dbAnalysis->start('', 'files', $conf['MM'], $uid); foreach($dbAnalysis->itemArray as $somekey => $someval) { if ($someval['id']) { $theFileValues[] = $someval['id']; } } } else { $theFileValues = t3lib_div::trimExplode(',',$value,1); } // Traverse this array of files: $uploadFolder = $conf['uploadfolder']; $dest = $this->destPathFromUploadFolder($uploadFolder); $newValue = array(); foreach($theFileValues as $file) { if (trim($file)) { $realFile = $dest.'/'.trim($file); if (@is_file($realFile)) { $newValue[] = $realFile; } } } // Implode the new filelist into the new value (all files have absolute paths now which means they will get copied when entering TCEmain as new values...) $value = implode(',',$newValue); }else if($conf['type']=='group' && $conf['MM'] && $conf['MM_foreign_select']){ $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup'); $dbAnalysis->start('',$conf['allowed'],$conf['MM'],$uid,'tt_content',$conf['MM_ident'],$conf['MM_foreign_select']); $value = implode(',',$dbAnalysis->getValueArray(1)); } // Return the new value: return $value; } /** * Processing/Preparing content for copyRecord() function * * @param string Table name * @param integer Record uid * @param string Field name being processed * @param string Input value to be processed. * @param array Record array * @param array TCA field configuration * @return mixed Processed value. Normally a string/integer, but can be an array for flexforms! * @access private * @see copyRecord() */ function copyRecord_procBasedOnFieldType($table,$uid,$field,$value,$row,$conf) { global $TCA; // Process references and files, currently that means only the files, prepending absolute paths (so the TCEmain engine will detect the file as new and one that should be made into a copy) $value = $this->copyRecord_procFilesRefs($conf, $uid, $value); // Register if there are references to take care of (no change to value): if ($this->isReferenceField($conf)) { $allowedTables = $conf['type']=='group' ? $conf['allowed'] : $conf['foreign_table'].','.$conf['neg_foreign_table']; $prependName = $conf['type']=='group' ? $conf['prepend_tname'] : $conf['neg_foreign_table']; if ($conf['MM']) { $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup'); #$dbAnalysis->start('',$allowedTables,$conf['MM'],$uid); if($prependName){ $MMmatchTablenames=$table; } $dbAnalysis->start('',$allowedTables,$conf['MM'],$uid,$MMmatchTablenames,$conf['MM_ident'],$conf['MM_foreign_select']); $value = implode(',',$dbAnalysis->getValueArray($prependName)); } if ($value) { // Setting the value in this array will notify the remapListedDBRecords() function that this field MAY need references to be corrected $this->registerDBList[$table][$uid][$field] = $value; } } // For "flex" fieldtypes we need to traverse the structure for two reasons: If there are file references they have to be prepended with absolute paths and if there are database reference they MIGHT need to be remapped (still done in remapListedDBRecords()) if ($conf['type']=='flex') { // Get current value array: $dataStructArray = t3lib_BEfunc::getFlexFormDS($conf, $row, $table); $currentValueArray = t3lib_div::xml2array($value); // Traversing the XML structure, processing files: if (is_array($currentValueArray)) { $currentValueArray['data'] = $this->checkValue_flex_procInData( $currentValueArray['data'], array(), // Not used. array(), // Not used. $dataStructArray, array($table,$uid,$field), // Parameters. 'copyRecord_flexFormCallBack' ); $value = $currentValueArray; // Setting value as an array! -> which means the input will be processed according to the 'flex' type when the new copy is created. } } return $value; } /** * Returns data for group/db and select fields * * @param array Current value array * @param array TCA field config * @param integer Record id, used for look-up of MM relations (local_uid) * @param string Status string ('update' or 'new') * @param string The type, either 'select' or 'group' * @return array Modified value array */ function checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,$type) { $tables = $type=='group'?$tcaFieldConf['allowed']:$tcaFieldConf['foreign_table'].','.$tcaFieldConf['neg_foreign_table']; $prep = $type=='group'?$tcaFieldConf['prepend_tname']:$tcaFieldConf['neg_foreign_table']; $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup'); $dbAnalysis->registerNonTableValues = $tcaFieldConf['allowNonIdValues'] ? 1 : 0; $dbAnalysis->start(implode(',',$valueArray),$tables); if ($tcaFieldConf['MM']) { if ($tcaFieldConf['prepend_tname']) { if ($tcaFieldConf['MM_foreign_select']) { foreach ($dbAnalysis->itemArray as $key => $val) { $dbAnalysis->itemArray[$key]['table'] = $tcaFieldConf['MM_foreign_select']; // is the current table } } } if ($status=='update') { $dbAnalysis->writeMM($tcaFieldConf['MM'], $id, $prep, $tcaFieldConf['MM_ident'], $tcaFieldConf['MM_foreign_select']); } else { //fix for dam/compat/class.ux_t3lib_tcemain.php (ident and travers $swapLocalForeign needed for new records) #$this->dbAnalysisStore[] = array($dbAnalysis,$tcaFieldConf['MM'],$id,$prep); // This will be traversed later to execute the actions $this->dbAnalysisStore[] = array($dbAnalysis,$tcaFieldConf['MM'],$id,$prep,$tcaFieldConf['MM_ident'],$tcaFieldConf['MM_foreign_select']); // This will be traversed later to execute the actions } $cc=count($dbAnalysis->itemArray); $valueArray = array($cc); } else { $valueArray = $dbAnalysis->getValueArray($prep); if ($type=='select' && $prep) { $valueArray = $dbAnalysis->convertPosNeg($valueArray,$tcaFieldConf['foreign_table'],$tcaFieldConf['neg_foreign_table']); } } // Here we should se if 1) the records exist anymore, 2) which are new and check if the BE_USER has read-access to the new ones. return $valueArray; } /** * Executing dbAnalysisStore * bugfix for dam/compat/class.ux_t3lib_tcemain.php ($v[4]=$ident and $v[5]=$swapLocalForeign needed for new records - * see checkValue_group_select_processDBdata() above) * @return [type] ... */ function dbAnalysisStoreExec() { reset($this->dbAnalysisStore); while(list($k,$v)=each($this->dbAnalysisStore)) { $id = $this->substNEWwithIDs[$v[2]]; if ($id) { #debug($v,'ux_ux_t3lib_tcemain->dbAnalysisStoreExec',__LINE__,__FILE__); #exit; $v[2] = $id; $v[0]->writeMM($v[1],$v[2],$v[3],$v[4],$v[5]); } } } } ?>