Index: branches/5.2.x/units/currencies/currencies_event_handler.php =================================================================== diff -u -N -r14258 -r14625 --- branches/5.2.x/units/currencies/currencies_event_handler.php (.../currencies_event_handler.php) (revision 14258) +++ branches/5.2.x/units/currencies/currencies_event_handler.php (.../currencies_event_handler.php) (revision 14625) @@ -1,6 +1,6 @@ getObject(); - if($object->GetDBField('IsPrimary') && $object->Validate()) - { - $sql = 'UPDATE '.$this->Application->getUnitOption($this->Prefix, 'TableName').' + /* @var $object kDBItem */ + + if ( $object->GetDBField('IsPrimary') && $object->Validate() ) { + $sql = 'UPDATE ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . ' SET IsPrimary = 0 - WHERE CurrencyId <> '.$object->GetDBField('CurrencyId'); + WHERE CurrencyId <> ' . $object->GetDBField('CurrencyId'); $this->Conn->Query($sql); + $object->SetDBField('Status', 1); } - $object->SetDBField('Modified_date', adodb_mktime() ); - $object->SetDBField('Modified_time', adodb_mktime() ); - if($object->GetDBField('Status') == 0) - { - $sql = 'DELETE FROM '.$this->Application->getUnitOption('ptc', 'TableName'). - ' WHERE CurrencyId='.$object->GetDBField('CurrencyId'); + $object->SetDBField('Modified_date', adodb_mktime()); + $object->SetDBField('Modified_time', adodb_mktime()); + + if ( $object->GetDBField('Status') == 0 ) { + $sql = 'DELETE FROM ' . $this->Application->getUnitOption('ptc', 'TableName') . ' + WHERE CurrencyId = ' . $object->GetDBField('CurrencyId'); $this->Conn->Query($sql); } } /** - * Enter description here... + * Apply any custom changes to list's sql query * * @param kEvent $event + * @return void + * @access protected + * @see kDBEventHandler::OnListBuild() */ - function SetCustomQuery(&$event) + protected function SetCustomQuery(&$event) { $object =& $event->getObject(); @@ -115,17 +124,20 @@ } /** - * Enter description here... + * Saves content of temp table into live and + * redirects to event' default redirect (normally grid template) * * @param kEvent $event + * @return void + * @access protected */ - function OnSave(&$event) + protected function OnSave(&$event) { - $this->Application->StoreVar( 'saved_curr_ids', $this->Application->RecallVar($event->Prefix.'_selected_ids') ); + $this->Application->StoreVar('saved_curr_ids', $this->Application->RecallVar($event->Prefix . '_selected_ids')); + parent::OnSave($event); } - /** * Enter description here... *