Index: trunk/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r5098 -r5185 --- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 5098) +++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 5185) @@ -1672,18 +1672,38 @@ $object =& $event->getObject(); $this->RemoveRequiredFields($object); $event->CallSubEvent('OnPreSave'); + if ($event->status == erSUCCESS) { + + $resource_id = $this->Application->GetVar('translator_resource_id'); + if ($resource_id) { + $t_prefixes = explode(',', $this->Application->GetVar('translator_prefixes')); + + $cdata =& $this->Application->recallObject($t_prefixes[1], null, Array('skip_autoload' => true)); + $cdata->Load($resource_id, 'ResourceId'); + if (!$cdata->isLoaded()) { + $cdata->SetDBField('ResourceId', $resource_id); + $cdata->Create(); + } + $this->Application->SetVar($cdata->getPrefixSpecial().'_id', $cdata->GetID()); + } + $event->redirect = $this->Application->GetVar('translator_t'); $event->redirect_params = Array('pass'=>'all,trans,'.$this->Application->GetVar('translator_prefixes'), - $event->getPrefixSpecial(true).'_id' => $object->GetId(), - 'trans_event'=>'OnLoad', - 'trans_prefix'=> $this->Application->GetVar('translator_prefixes'), - 'trans_field'=>$this->Application->GetVar('translator_field'), - 'trans_multi_line'=>$this->Application->GetVar('translator_multi_line'), + $event->getPrefixSpecial(true).'_id' => $object->GetID(), + 'trans_event' => 'OnLoad', + 'trans_prefix' => $this->Application->GetVar('translator_prefixes'), + 'trans_field' => $this->Application->GetVar('translator_field'), + 'trans_multi_line' => $this->Application->GetVar('translator_multi_line'), ); + + // 1. SAVE LAST TEMPLATE TO SESSION (really needed here, because of tweaky redirect) + $last_template = $this->Application->RecallVar('last_template'); + preg_match('/index4\.php\|'.$this->Application->GetSID().'-(.*):/U', $last_template, $rets); + $this->Application->StoreVar('return_template', $this->Application->GetVar('t')); } } - + function RemoveRequiredFields(&$object) { // making all field non-required to achieve successful presave