Index: branches/unlabeled/unlabeled-1.25.2/core/kernel/utility/temp_handler.php =================================================================== diff -u -r5774 -r5858 --- branches/unlabeled/unlabeled-1.25.2/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 5774) +++ branches/unlabeled/unlabeled-1.25.2/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 5858) @@ -188,7 +188,7 @@ $tables['SubTables'][] = $tmp; } - function CloneItems($prefix, $special, $ids, $master=null, $foreign_key=null, $parent_prefix = null) + function CloneItems($prefix, $special, $ids, $master = null, $foreign_key = null, $parent_prefix = null, $skip_filenames = false) { if (!isset($master)) $master = $this->Tables; @@ -213,7 +213,13 @@ $object->Load($id); $original_values = $object->FieldValues; - $object->NameCopy($master, $foreign_key); + if (!$skip_filenames) { + $object->NameCopy($master, $foreign_key); + } + elseif ($master['TableName'] == $this->MasterTable) { + // kCatDBItem class only has this attribute + $object->useFilenames = false; + } if (isset($foreign_key)) { $master_foreign_key_field = is_array($master['ForeignKey']) ? $master['ForeignKey'][$parent_prefix] : $master['ForeignKey']; @@ -232,7 +238,9 @@ // remember original => clone mapping for dual ForeignKey updating $this->AlreadyProcessed[$master['TableName']][$id] = $object->GetId(); } - if($object->mode == 't') $object->setTempID(); + if ($object->mode == 't') { + $object->setTempID(); + } if ($mode == 'create') { $this->RaiseEvent('OnAfterClone', $master['Prefix'], $special, Array($object->GetId()), $foreign_key, array('original_id' => $id) ); $this->saveID($master['Prefix'], $special, $object->GetID()); @@ -421,6 +429,7 @@ $live_foreign_key = $this->Conn->GetCol($query); if (isset($temp_id)) { + // if id < 0, then it is 0 by now => substitute it (in progress, by Alex) $query = 'SELECT '.$parent_key_field.' FROM '.$this->GetTempName($master['TableName']).' WHERE '.$master['IdField'].' IN ('.join(',', $temp_id).')'; $temp_foreign_key = $this->Conn->GetCol($query); @@ -493,6 +502,7 @@ $this->Conn->Query($query); $insert_id = $id_to_copy == 0 ? $this->Conn->getInsertID() : $id_to_copy; + $this->saveID($master['Prefix'], '', $insert_id); $this->RaiseEvent( 'OnAfterCopyToLive', $master['Prefix'], '', Array($insert_id), null, array('temp_id' => $id) ); $this->UpdateForeignKeys($master, $insert_id, $id); @@ -550,6 +560,12 @@ } }*/ $this->DropTempTable($master['TableName']); + + if (!isset($this->savedIDs[ $master['Prefix'] ])) { + $this->savedIDs[ $master['Prefix'] ] = Array(); + } + + return $this->savedIDs[ $master['Prefix'] ]; } function UpdateForeignKeys($master, $live_id, $temp_id) { @@ -641,7 +657,7 @@ function SaveEdit($master_ids = Array()) { - $this->DoCopyTempToOriginal($this->Tables, null, $master_ids); + return $this->DoCopyTempToOriginal($this->Tables, null, $master_ids); } function CancelEdit($master=null)