Index: trunk/core/kernel/utility/temp_handler.php =================================================================== diff -u -r3073 -r3654 --- trunk/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 3073) +++ trunk/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 3654) @@ -144,14 +144,14 @@ ); $this->FinalRefs[ $tmp['TableName'] ] = $tmp['TableId']; - + $constrain = $this->Application->getUnitOption($prefix,'Constrain'); if ($constrain) { $tmp['Constrain'] = $constrain; $this->FinalRefs[ $tmp['TableName'].$tmp['Constrain'] ] = $tmp['TableId']; } - + $SubItems = $this->Application->getUnitOption($prefix,'SubItems'); $same_sub_counter = 1; if( is_array($SubItems) ) @@ -218,7 +218,7 @@ } if($object->mode == 't') $object->setTempID(); if ($mode == 'create') { - $this->RaiseEvent('OnAfterClone', $master['Prefix'], Array($object->GetId()), $foreign_key ); + $this->RaiseEvent('OnAfterClone', $master['Prefix'], Array($object->GetId()), $foreign_key, array('original_id' => $id) ); } if ( is_array(getArrayValue($master, 'SubTables')) ) { @@ -232,7 +232,7 @@ $query = 'SELECT '.$sub_table['IdField'].' FROM '.$sub_TableName.' WHERE '.$foreign_key_field.' = '.$original_values[$parent_key_field]; if (isset($sub_table['Constrain'])) $query .= ' AND '.$sub_table['Constrain']; - + $sub_ids = $this->Conn->GetCol($query); if ( is_array(getArrayValue($sub_table, 'ForeignKey')) ) { @@ -293,7 +293,7 @@ } } - + function DoCopyLiveToTemp($master, $ids, $parent_prefix=null) { // when two tables refers the same table as sub-sub-table, and ForeignKey and ParentTableKey are arrays @@ -426,7 +426,7 @@ $current_ids = $this->Conn->GetCol($query); $table_sig = $master['TableName'].(isset($master['Constrain']) ? $master['Constrain'] : ''); - + if ($current_ids) { // delete all ids from live table - for MasterTable ONLY! // because items from Sub Tables get deteleted in CopySubTablesToLive !BY ForeignKey! @@ -439,7 +439,7 @@ if ( getArrayValue($master, 'SubTables') ) { if( in_array($table_sig, $this->CopiedTables) || $this->FinalRefs[$table_sig] != $master['TableId'] ) return; - + foreach($current_ids AS $id) { $this->RaiseEvent( 'OnBeforeCopyToLive', $master['Prefix'], Array($id) ); @@ -466,7 +466,7 @@ $this->Conn->Query($query); $insert_id = $id_to_copy == 0 ? $this->Conn->getInsertID() : $id_to_copy; - $this->RaiseEvent( 'OnAfterCopyToLive', $master['Prefix'], Array($insert_id) ); + $this->RaiseEvent( 'OnAfterCopyToLive', $master['Prefix'], Array($insert_id), null, array('temp_id' => $id) ); $this->UpdateForeignKeys($master, $insert_id, $id); @@ -476,9 +476,9 @@ if (isset($master['Constrain'])) $query .= ' AND '.$master['Constrain']; $this->Conn->Query($query); } - + $this->CopiedTables[] = $table_sig; - + // when all of ids in current master has been processed, copy all sub-tables data $this->CopySubTablesToLive($master, $current_ids); } @@ -499,7 +499,7 @@ SELECT * FROM '.$this->GetTempName($master['TableName']); if (isset($master['Constrain'])) $query .= ' WHERE '.$master['Constrain']; $this->Conn->Query($query); - + $this->CopiedTables[] = $table_sig; /* @@ -546,7 +546,7 @@ foreach ($master['SubTables'] as $sub_table) { $table_sig = $sub_table['TableName'].(isset($sub_table['Constrain']) ? $sub_table['Constrain'] : ''); - + // delete records from live table by foreign key, so that records deleted from temp table // get deleted from live if (count($current_ids) > 0 && !in_array($table_sig, $this->CopiedTables) ) { @@ -570,14 +570,19 @@ } } - function RaiseEvent($name, $prefix, $ids, $foreign_key = null) + function RaiseEvent($name, $prefix, $ids, $foreign_key = null, $add_params = null) { if ( !is_array($ids) ) return; $event = new kEvent( Array('name'=>$name, 'prefix'=>$prefix, 'special'=>'') ); if( isset($foreign_key) ) $event->setEventParam('foreign_key', $foreign_key); foreach($ids as $id) { $event->setEventParam('id', $id); + if (is_array($add_params)) { + foreach ($add_params as $name => $val) { + $event->setEventParam($name, $val); + } + } $this->Application->HandleEvent($event); } } Index: trunk/core/kernel/utility/factory.php =================================================================== diff -u -r3330 -r3654 --- trunk/core/kernel/utility/factory.php (.../factory.php) (revision 3330) +++ trunk/core/kernel/utility/factory.php (.../factory.php) (revision 3654) @@ -92,6 +92,12 @@ return $false; } + if ($this->Application->isDebugMode() && dbg_ConstOn('DBG_FACTORY')) { + global $debugger; + $debugger->appendHTML('Creating object: Pseudo class: '.$pseudo_class.' Prefix: '.$name); + $debugger->appendTrace(); + } + $funs_args = func_get_args(); array_splice($funs_args, 0, 3, Array($pseudo_class) );