Index: branches/5.2.x/units/products/products_event_handler.php =================================================================== diff -u -N -r14089 -r14099 --- branches/5.2.x/units/products/products_event_handler.php (.../products_event_handler.php) (revision 14089) +++ branches/5.2.x/units/products/products_event_handler.php (.../products_event_handler.php) (revision 14099) @@ -1,6 +1,6 @@ getObject(); + /* @var $object kDBItem */ $object->SetFieldsFromHash( $this->getSubmittedFields($event) ); @@ -107,7 +108,8 @@ $object->Validate(); - if (!isset($object->FieldErrors['Qty']['pseudo'])){ + if ( !$object->GetErrorPseudo('Qty') ){ + // only update, when no error on that field $this->modifyInventory($event->Name, $object, $object->GetDBField('Qty'), $combination_id); } @@ -276,7 +278,7 @@ //reserve what's possible in any case $this->Application->HandleEvent( $event, 'ord:OnReserveItems' ); - if ($event->status == erSUCCESS) { // + if ($event->status == kEvent::erSUCCESS) { // //in case the order is ready to process - process it $this->Application->HandleEvent( $event, 'ord:OnOrderProcess' ); } @@ -287,14 +289,18 @@ { $id = $event->getEventParam('id'); $product =& $this->Application->recallObject($event->Prefix.'.itemlive', null, Array('skip_autoload' => true)); + /* @var $product kCatDBItem */ + $product->SwitchToLive(); if (!$product->Load($id)) return ; // this will make sure New product will not be overwritten with empty data $temp =& $this->Application->recallObject($event->Prefix.'.itemtemp', null, Array('skip_autoload' => true)); + /* @var $temp kCatDBItem */ + $temp->SwitchToTemp(); $temp->Load($id); - $temp->SetDBFieldsFromHash($product->FieldValues, Array('QtyInStock','QtyReserved','QtyBackOrdered','QtyOnOrder')); + $temp->SetDBFieldsFromHash($product->GetFieldValues(), Array('QtyInStock','QtyReserved','QtyBackOrdered','QtyOnOrder')); $temp->Update(); } @@ -308,7 +314,7 @@ function OnSave(&$event) { $res = parent::OnSave($event); - if ($event->status == erSUCCESS) { + if ($event->status == kEvent::erSUCCESS) { $this->RunScheduledInventoryActions($event); } return $res; @@ -322,14 +328,19 @@ } + /** + * Enter description here... + * + * @param kEvent $event + */ function OnPreSaveAndGo(&$event) { $event->CallSubEvent('OnPreSave'); $this->LoadItem($event); $object =& $event->getObject(); $from_type = $object->GetDBField('Type'); - if ($event->status==erSUCCESS) { - $this->Application->SetVar($event->Prefix_Special.'_id', $this->Application->GetVar($event->getPrefixSpecial(true).'_GoId')); + if ($event->status==kEvent::erSUCCESS) { + $this->Application->SetVar($event->getPrefixSpecial().'_id', $this->Application->GetVar($event->getPrefixSpecial(true).'_GoId')); $this->LoadItem($event); $to_type = $object->GetDBField('Type'); @@ -554,10 +565,12 @@ */ function OnRateProduct(&$event) { - $event->redirect_params = Array('pass' => 'all,p'); + $event->setRedirectParams(Array('pass' => 'all,p'), true); $event->redirect = $this->Application->GetVar('success_template'); $object =& $event->getObject(); + /* @var $object kDBItem */ + $user_id = $this->Application->RecallVar('user_id'); $sql = ' SELECT * FROM '.TABLE_PREFIX.'SpamControl @@ -603,23 +616,33 @@ } else { - $event->status == erFAIL; + $event->status == kEvent::erFAIL; $event->redirect=false; - $object->FieldErrors['CachedRating']['pseudo'] = 'too_frequent'; - $object->ErrorMsgs['too_frequent'] = $this->Application->Phrase('lu_ferror_rate_duplicate'); + $object->SetError('CachedRating', 'too_frequent', 'lu_ferror_rate_duplicate'); } } + /** + * Enter description here... + * + * @param kEvent $event + */ function OnCancelAction(&$event) { - $event->redirect_params = Array('pass' => 'all,p'); + $event->setRedirectParams(Array('pass' => 'all,p'), true); $event->redirect = $this->Application->GetVar('cancel_template'); } + /** + * Enter description here... + * + * @param kEvent $event + */ function OnRecommendProduct(&$event) { // used for error reporting only -> rewrite code + theme (by Alex) $object =& $this->Application->recallObject('u', null, Array('skip_autoload' => true)); // TODO: change theme too + /* @var $object kDBItem */ $friend_email = $this->Application->GetVar('friend_email'); $friend_name = $this->Application->GetVar('friend_name'); @@ -639,23 +662,21 @@ $email_event = &$this->Application->EmailEventUser('PRODUCT.SUGGEST', $user_id, $send_params); $email_event = &$this->Application->EmailEventAdmin('PRODUCT.SUGGEST'); - if ($email_event->status == erSUCCESS){ - $event->redirect_params = array('opener' => 's', 'pass' => 'all'); + if ($email_event->status == kEvent::erSUCCESS){ + $event->setRedirectParams(Array('opener' => 's', 'pass' => 'all'), true); $event->redirect = $this->Application->GetVar('template_success'); } else { -// $event->redirect_params = array('opener' => 's', 'pass' => 'all'); +// $event->setRedirectParams(Array('opener' => 's', 'pass' => 'all'), true); // $event->redirect = $this->Application->GetVar('template_fail'); - $object->ErrorMsgs['send_error'] = $this->Application->Phrase('lu_email_send_error'); - $object->FieldErrors['Email']['pseudo'] = 'send_error'; - $event->status = erFAIL; + $object->SetError('Email', 'send_error', 'lu_email_send_error'); + $event->status = kEvent::erFAIL; } } else { - $object->ErrorMsgs['invalid_email'] = $this->Application->Phrase('lu_InvalidEmail'); - $object->FieldErrors['Email']['pseudo'] = 'invalid_email'; - $event->status = erFAIL; + $object->SetError('Email', 'invalid_email', 'lu_InvalidEmail'); + $event->status = kEvent::erFAIL; } } @@ -1119,9 +1140,7 @@ { //$event->CallSubEvent('OnUpdate'); $event->redirect = false; - //$event->redirect_params = Array('opener'=>'s','pass'=>'all,p'); - - + //$event->setRedirectParams(Array('opener'=>'s','pass'=>'all,p'), true); } /** @@ -1168,7 +1187,7 @@ $product_includes_in = $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Products WHERE PackageContent LIKE "%|'.$object->GetID().'%"'); if ($product_includes_in > 0){ - $event->status=erFAIL; + $event->status=kEvent::erFAIL; } } @@ -1185,7 +1204,7 @@ '__VIRTUAL__Price' => 'Price', '__VIRTUAL__Cost' => 'Cost', ); - return array_merge_recursive2($columns, $new_columns); + return array_merge($columns, $new_columns); } /** @@ -1209,10 +1228,10 @@ $event->redirect = $this->Application->GetVar('t'); // pass ID too, in case if product is created by OnPreSave call to ensure proper editing - $event->redirect_params = Array( + $event->setRedirectParams( Array( 'pass' => 'all', $event->getPrefixSpecial(true).'_id' => $object->GetID(), - ); + ), true); }