Index: branches/5.2.x/units/coupons/coupons_event_handler.php =================================================================== diff -u -N -r15047 -r15061 --- branches/5.2.x/units/coupons/coupons_event_handler.php (.../coupons_event_handler.php) (revision 15047) +++ branches/5.2.x/units/coupons/coupons_event_handler.php (.../coupons_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ getObject( Array('skip_autoload' => true) ); + $object =& $event->getObject(Array ('skip_autoload' => true)); /* @var $object kDBItem */ // creates multiple db records from single request (OnCreate event only creates 1 record) @@ -57,20 +59,25 @@ * @return void * @access protected */ - protected function customProcessing(&$event, $type) + protected function customProcessing(kEvent &$event, $type) { - if($type != 'before') return ; + if ( $type != 'before' ) { + return; + } $object =& $event->getObject(); + /* @var $object kDBItem */ + $events = $this->Application->GetVar('events'); - if($events['z'] == 'OnUpdate') - { + + if ( $events['z'] == 'OnUpdate' ) { $object->SetDBField('ShippingZoneId', $this->Application->GetVar('z_id')); } $zone_object =& $this->Application->recallObject('z'); - if($zone_object->GetDBField('Type') == 3) - { + /* @var $zone_object kDBItem */ + + if ( $zone_object->GetDBField('Type') == 3 ) { $object->SetDBField('StdDestId', $this->Application->GetVar('ZIPCountry')); } } Index: branches/5.2.x/units/affiliate_payment_types/affiliate_payment_types_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/affiliate_payment_types/affiliate_payment_types_event_handler.php (.../affiliate_payment_types_event_handler.php) (revision 14986) +++ branches/5.2.x/units/affiliate_payment_types/affiliate_payment_types_event_handler.php (.../affiliate_payment_types_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Name == 'OnMassDelete' && $type == 'before' ) { $ids = $event->getEventParam('ids'); Index: branches/5.2.x/units/product_options/product_options_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/product_options/product_options_event_handler.php (.../product_options_event_handler.php) (revision 14986) +++ branches/5.2.x/units/product_options/product_options_event_handler.php (.../product_options_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ getEventParam('id'); $temp_id = $event->getEventParam('temp_id'); - if ($id == $temp_id) return; + if ( $id == $temp_id ) { + return; + } - $poc_table = $this->Application->GetTempName(TABLE_PREFIX.'ProductOptionCombinations', 'prefix:p'); - $query = 'SELECT * FROM '.$poc_table; - $combs = $this->Conn->Query($query); + $poc_table = $this->Application->GetTempName(TABLE_PREFIX . 'ProductOptionCombinations', 'prefix:p'); + + $sql = 'SELECT * + FROM ' . $poc_table; + $combs = $this->Conn->Query($sql); + foreach ($combs as $a_comb) { $comb_data = unserialize($a_comb['Combination']); - $n_combs = array(); - foreach ($comb_data as $key => $val) - { + $n_combs = array (); + foreach ($comb_data as $key => $val) { $n_key = $key == $temp_id ? $id : $key; $n_combs[$n_key] = $val; } ksort($n_combs); $n_combs = serialize($n_combs); $n_crc = crc32($n_combs); - $query = 'UPDATE '.$poc_table.' SET - Combination = '.$this->Conn->qstr($n_combs).', CombinationCRC = '.$n_crc.' WHERE CombinationId = '.$a_comb['CombinationId']; - $this->Conn->Query($query); + $sql = 'UPDATE ' . $poc_table . ' + SET + Combination = ' . $this->Conn->qstr($n_combs) . ', + CombinationCRC = ' . $n_crc . ' + WHERE CombinationId = ' . $a_comb['CombinationId']; + $this->Conn->Query($sql); } } - function OnAfterClone(&$event) + /** + * Occurs after an item has been cloned + * Id of newly created item is passed as event' 'id' param + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnAfterClone(kEvent &$event) { + parent::OnAfterClone($event); + $id = $event->getEventParam('id'); $org_id = $event->getEventParam('original_id'); // storing original to new ids mapping to use in poc:OnBeforeClone $options_mapping = $this->Application->GetVar('poc_mapping'); - if (!$options_mapping) $options_mapping = array(); + if ( !$options_mapping ) { + $options_mapping = array (); + } + $options_mapping[$org_id] = $id; $this->Application->SetVar('poc_mapping', $options_mapping); } Index: branches/5.2.x/units/product_option_combinations/product_option_combinations_event_handler.php =================================================================== diff -u -N -r15047 -r15061 --- branches/5.2.x/units/product_option_combinations/product_option_combinations_event_handler.php (.../product_option_combinations_event_handler.php) (revision 15047) +++ branches/5.2.x/units/product_option_combinations/product_option_combinations_event_handler.php (.../product_option_combinations_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Name) { @@ -43,10 +43,13 @@ case 'OnMassDelete': // delete only option combinations that has no associated inventory $object =& $event->getObject(); + /* @var $object kDBItem */ + $ids = $event->getEventParam('ids'); - $sql = 'SELECT '.$object->IDField.' - FROM '.$object->TableName.' - WHERE ('.$object->IDField.' IN ('.implode(',', $ids).')) AND + + $sql = 'SELECT ' . $object->IDField . ' + FROM ' . $object->TableName . ' + WHERE (' . $object->IDField . ' IN (' . implode(',', $ids) . ')) AND (QtyInStock = 0) AND (QtyReserved = 0) AND (QtyBackOrdered = 0) AND (QtyOnOrder = 0)'; $event->setEventParam('ids', $this->Conn->GetCol($sql)); break; @@ -155,32 +158,37 @@ } /** - * Enter description here... + * Creates new kDBItem * * @param kEvent $event + * @return void + * @access protected */ - function OnCreate(&$event) + protected function OnCreate(kEvent &$event) { - $object =& $event->getObject( Array('skip_autoload' => true) ); + $object =& $event->getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - if($items_info) - { - list($id,$field_values) = each($items_info); - $object->SetFieldsFromHash($field_values, $this->getRequestProtectedFields($field_values)); - if (!$object->Validate()) { - $event->status = kEvent::erFAIL; - $event->redirect = false; - $this->Application->SetVar($event->getPrefixSpecial().'_SaveEvent','OnCreate'); - $object->setID($id); - return; - } + $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); - $this->CreateCombinations($event, $field_values); + if ( !$items_info ) { + return; } - } + list($id, $field_values) = each($items_info); + $object->SetFieldsFromHash($field_values, $this->getRequestProtectedFields($field_values)); + if ( !$object->Validate() ) { + $event->status = kEvent::erFAIL; + $event->redirect = false; + $this->Application->SetVar($event->getPrefixSpecial() . '_SaveEvent', 'OnCreate'); + $object->setID($id); + return; + } + + $this->CreateCombinations($event, $field_values); + } + /** * Updates kDBItem * @@ -317,7 +325,7 @@ * @return void * @access protected */ - protected function OnBeforeClone(&$event) + protected function OnBeforeClone(kEvent &$event) { parent::OnBeforeClone($event); @@ -355,7 +363,7 @@ * @return void * @access protected */ - protected function OnBeforeDeleteFromLive(&$event) + protected function OnBeforeDeleteFromLive(kEvent &$event) { parent::OnBeforeDeleteFromLive($event); @@ -394,9 +402,10 @@ * Create search filters based on search query * * @param kEvent $event + * @return void * @access protected */ - function OnSearch(&$event) + protected function OnSearch(kEvent &$event) { parent::OnSearch($event); @@ -407,9 +416,10 @@ * Clear search keywords * * @param kEvent $event + * @return void * @access protected */ - function OnSearchReset(&$event) + protected function OnSearchReset(kEvent &$event) { parent::OnSearchReset($event); Index: branches/5.2.x/units/taxesdestinations/taxes_dst_event_handler.php =================================================================== diff -u -N -r14625 -r15061 --- branches/5.2.x/units/taxesdestinations/taxes_dst_event_handler.php (.../taxes_dst_event_handler.php) (revision 14625) +++ branches/5.2.x/units/taxesdestinations/taxes_dst_event_handler.php (.../taxes_dst_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ - $object =& $event->getObject( Array('skip_autoload' => true) ); - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); + $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); $tax_object =& $this->Application->recallObject('tax'); + /* @var $tax_object kDBItem */ - $std_dest_id=$this->Application->GetVar('StatesCountry'); + $std_dest_id = $this->Application->GetVar('StatesCountry'); - if($items_info) - { + if ( $items_info ) { $taxdest =& $this->Application->recallObject($event->getPrefixSpecial(true), null); - $parent_info=&$object->GetLinkedInfo(); + /* @var $taxdest kDBItem */ - $queryDel="DELETE FROM ".$object->TableName." WHERE TaxZoneId=".$parent_info['ParentId']; + $parent_info =& $object->GetLinkedInfo(); + + $queryDel = "DELETE FROM " . $object->TableName . " WHERE TaxZoneId=" . $parent_info['ParentId']; $this->Conn->Query($queryDel); - foreach($items_info as $id => $field_values) - { - if($tax_object->GetDBField('Type') == 3 && (!$field_values['DestValue'] || $field_values['DestValue']=='')){ + foreach ($items_info as $field_values) { + if ( $tax_object->GetDBField('Type') == 3 && (!$field_values['DestValue'] || $field_values['DestValue'] == '') ) { continue; } - if (!$field_values['StdDestId']){ - $field_values['StdDestId']=$std_dest_id; + if ( !$field_values['StdDestId'] ) { + $field_values['StdDestId'] = $std_dest_id; } - $field_values['TaxZoneId']=$parent_info['ParentId']; + $field_values['TaxZoneId'] = $parent_info['ParentId']; - if ($taxdest->Load($field_values['TaxZoneDestId'], "TaxZoneDestId")){ + if ( $taxdest->Load($field_values['TaxZoneDestId'], "TaxZoneDestId") ) { $taxdest->SetFieldsFromHash($field_values); $taxdest->Update($field_values['TaxZoneDestId']); - }else{ + } + else { $taxdest->SetFieldsFromHash($field_values); $taxdest->Create($field_values['TaxZoneDestId']); } - } - } - - } /** - * Creates item from submit data + * Creates new kDBItem * * @param kEvent $event + * @return void + * @access protected */ - - function OnCreate(&$event) + protected function OnCreate(kEvent &$event) { - $object =& $event->getObject( Array('skip_autoload' => true) ); + $object =& $event->getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - if($items_info) - { - foreach($items_info as $id => $field_values) - { - $object->SetFieldsFromHash($field_values); - $this->customProcessing($event,'before'); + $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); + if ( !$items_info ) { + return; + } - if ( $object->Create() ) { - $this->customProcessing($event,'after'); - } - else { - $event->status = kEvent::erFAIL; - $event->redirect = false; - $this->Application->SetVar($event->getPrefixSpecial().'_SaveEvent','OnCreate'); - $object->setID(0); - } + foreach ($items_info as $field_values) { + $object->SetFieldsFromHash($field_values); + $this->customProcessing($event, 'before'); + + if ( $object->Create() ) { + $this->customProcessing($event, 'after'); } + else { + $event->status = kEvent::erFAIL; + $event->redirect = false; + $this->Application->SetVar($event->getPrefixSpecial() . '_SaveEvent', 'OnCreate'); + $object->setID(0); + } } } @@ -103,24 +105,26 @@ * @return void * @access protected */ - protected function customProcessing(&$event, $type) + protected function customProcessing(kEvent &$event, $type) { - switch($type) - { + switch ($type) { case 'before': $object =& $event->getObject(); + /* @var $object kDBItem */ + $events = $this->Application->GetVar('events'); - if($events['tax'] == 'OnUpdate') - { + + if ( $events['tax'] == 'OnUpdate' ) { $object->SetDBField('TaxZoneId', $this->Application->GetVar('tax_id')); } + $tax_object =& $this->Application->recallObject('tax'); - if($tax_object->GetDBField('Type') == 3) - { + /* @var $tax_object kDBItem */ + + if ( $tax_object->GetDBField('Type') == 3 ) { $tax_object->SetDBField('StdDestId', $this->Application->GetVar('StatesCountry')); } break; - default: } } Index: branches/5.2.x/units/coupon_items/coupon_items_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/coupon_items/coupon_items_event_handler.php (.../coupon_items_event_handler.php) (revision 14986) +++ branches/5.2.x/units/coupon_items/coupon_items_event_handler.php (.../coupon_items_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Create() ) { $this->customProcessing($event, 'after'); $event->status = kEvent::erSUCCESS; - $event->setRedirectParams(Array('opener' => 's'), true); //stay! + $event->SetRedirectParam('opener', 's'); //stay! } else { $event->status = kEvent::erFAIL; Index: branches/5.2.x/units/affiliate_payments/affiliate_payments_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/affiliate_payments/affiliate_payments_event_handler.php (.../affiliate_payments_event_handler.php) (revision 14986) +++ branches/5.2.x/units/affiliate_payments/affiliate_payments_event_handler.php (.../affiliate_payments_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Application->recallObject('affil'); - $object =& $event->getObject( Array('skip_autoload'=>true) ); - $object->SetDBField('Amount', $affiliate->GetDBField('AmountToPay') ); - $object->SetDBField('AffiliateId', $affiliate->GetID() ); + /* @var $affiliate kDBItem */ + + $object =& $event->getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ + + $object->SetDBField('Amount', $affiliate->GetDBField('AmountToPay')); + $object->SetDBField('AffiliateId', $affiliate->GetID()); } /** @@ -72,7 +78,7 @@ * @return void * @access protected */ - protected function OnAfterItemCreate(&$event) + protected function OnAfterItemCreate(kEvent &$event) { parent::OnAfterItemCreate($event); Index: branches/5.2.x/units/affiliates/affiliates_event_handler.php =================================================================== diff -u -N -r15047 -r15061 --- branches/5.2.x/units/affiliates/affiliates_event_handler.php (.../affiliates_event_handler.php) (revision 15047) +++ branches/5.2.x/units/affiliates/affiliates_event_handler.php (.../affiliates_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + if ( $this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) { $event->status = kEvent::erFAIL; return; } - $object =& $event->getObject( Array('skip_autoload' => true) ); + $object =& $event->getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ + $ids = $this->StoreSelectedIDs($event); - if($ids) - { - $status_field = array_shift( $this->Application->getUnitOption($event->Prefix,'StatusField') ); + if ( $ids ) { + $status_field = array_shift($this->Application->getUnitOption($event->Prefix, 'StatusField')); - foreach($ids as $id) - { + foreach ($ids as $id) { $object->Load($id); - switch ($event->Name) - { + switch ($event->Name) { case 'OnMassApprove': $object->SetDBField($status_field, 1); break; @@ -600,26 +606,23 @@ break; } - if( $object->Update() ) - { - switch ($event->Name) - { + if ( $object->Update() ) { + switch ($event->Name) { case 'OnMassApprove': - $email_event_user =& $this->Application->EmailEventUser('AFFILIATE.REGISTRATION.APPROVED', $object->GetDBField('PortalUserId')); - $email_event_admin =& $this->Application->EmailEventAdmin('AFFILIATE.REGISTRATION.APPROVED'); + $this->Application->EmailEventUser('AFFILIATE.REGISTRATION.APPROVED', $object->GetDBField('PortalUserId')); + $this->Application->EmailEventAdmin('AFFILIATE.REGISTRATION.APPROVED'); break; case 'OnMassDecline': - $email_event_user =& $this->Application->EmailEventUser('AFFILIATE.REGISTRATION.DENIED', $object->GetDBField('PortalUserId')); - $email_event_admin =& $this->Application->EmailEventAdmin('AFFILIATE.REGISTRATION.DENIED'); + $this->Application->EmailEventUser('AFFILIATE.REGISTRATION.DENIED', $object->GetDBField('PortalUserId')); + $this->Application->EmailEventAdmin('AFFILIATE.REGISTRATION.DENIED'); break; } - $event->status=kEvent::erSUCCESS; - $event->setRedirectParams(Array('opener' => 's'), true); //stay! + $event->status = kEvent::erSUCCESS; + $event->SetRedirectParam('opener', 's'); //stay! } - else - { - $event->status=kEvent::erFAIL; - $event->redirect=false; + else { + $event->status = kEvent::erFAIL; + $event->redirect = false; break; } } Index: branches/5.2.x/units/discount_items/discount_items_event_handler.php =================================================================== diff -u -N -r15009 -r15061 --- branches/5.2.x/units/discount_items/discount_items_event_handler.php (.../discount_items_event_handler.php) (revision 15009) +++ branches/5.2.x/units/discount_items/discount_items_event_handler.php (.../discount_items_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Create() ) { $this->customProcessing($event,'after'); $event->status = kEvent::erSUCCESS; - $event->setRedirectParams(Array('opener' => 's'), true); + $event->SetRedirectParam('opener', 's'); } else { $event->status = kEvent::erFAIL; Index: branches/5.2.x/units/order_items/order_items_event_handler.php =================================================================== diff -u -N -r15047 -r15061 --- branches/5.2.x/units/order_items/order_items_event_handler.php (.../order_items_event_handler.php) (revision 15047) +++ branches/5.2.x/units/order_items/order_items_event_handler.php (.../order_items_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Application->isAdmin ) { - return ; + return; } $object =& $event->getObject(); @@ -174,7 +176,7 @@ if ( $changed_fields ) { $table_info = $object->getLinkedInfo(); - $main_object =& $this->Application->recallObject( $table_info['ParentPrefix'] ); + $main_object =& $this->Application->recallObject($table_info['ParentPrefix']); /* @var $main_object OrdersItem */ $oi_string = $object->GetDBField('ProductId') . ':' . $object->GetDBField('OptionsSalt') . ':' . $object->GetDBField('BackOrderFlag'); @@ -183,8 +185,8 @@ $error_code = OrderCheckoutError::FIELD_UPDATE_SUCCESS; if ( $changed_field == 'ItemData' ) { - $item_data_old = unserialize( $change_info['old'] ); - $item_data_new = unserialize( $change_info['new'] ); + $item_data_old = unserialize($change_info['old']); + $item_data_new = unserialize($change_info['new']); if ( $item_data_old['DiscountId'] != $item_data_new['DiscountId'] || $item_data_old['DiscountType'] != $item_data_new['DiscountType'] ) { if ( $item_data_new['DiscountId'] > 0 ) { @@ -258,22 +260,31 @@ function OnSaveItems(&$event) { $event->CallSubEvent('OnUpdate'); + $event->redirect = false; - $event->setRedirectParams(Array('opener'=>'s','pass'=>'all'), true); + $event->SetRedirectParam('opener', 's'); + $event->SetRedirectParam('pass', 'all'); } /** - * Occures after an item has been cloned + * Occurs after an item has been cloned * Id of newly created item is passed as event' 'id' param * * @param kEvent $event + * @return void + * @access protected */ - function OnAfterClone(&$event) + protected function OnAfterClone(kEvent &$event) { + parent::OnAfterClone($event); + $id = $event->getEventParam('id'); - $table = $this->Application->getUnitOption($event->Prefix,'TableName'); - $id_field = $this->Application->getUnitOption($event->Prefix,'IDField'); - $sql = 'UPDATE '.$table.' SET QuantityReserved = NULL WHERE '.$id_field.' = '.$id; + $table = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); + + $sql = 'UPDATE ' . $table . ' + SET QuantityReserved = NULL + WHERE ' . $id_field . ' = ' . $id; $this->Conn->Query($sql); } @@ -285,7 +296,7 @@ * @return void * @access protected */ - protected function OnAfterItemLoad(&$event) + protected function OnAfterItemLoad(kEvent &$event) { parent::OnAfterItemLoad($event); Index: branches/5.2.x/units/shipping_costs/shipping_costs_event_handler.php =================================================================== diff -u -N -r15047 -r15061 --- branches/5.2.x/units/shipping_costs/shipping_costs_event_handler.php (.../shipping_costs_event_handler.php) (revision 15047) +++ branches/5.2.x/units/shipping_costs/shipping_costs_event_handler.php (.../shipping_costs_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ getObject(Array ('skip_autoload' => true)); /* @var $object kDBItem */ @@ -170,15 +172,22 @@ */ function OnClearAll(&$event) { - $object =& $event->getObject( Array('skip_autoload' => true) ); + $object =& $event->getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ + $zones_object =& $this->Application->recallObject('z'); + /* @var $zones_object kDBItem */ - $sql = 'SELECT ZoneID FROM '.$zones_object->TableName.' WHERE ShippingTypeID='.$this->Application->GetVar('s_id'); + $sql = 'SELECT ZoneID + FROM ' . $zones_object->TableName . ' + WHERE ShippingTypeID = ' . $this->Application->GetVar('s_id'); $res = $this->Conn->GetCol($sql); - $sql = 'DELETE FROM '.$object->TableName.' WHERE ZoneID IN ('.implode(',', $res).')'; + + $sql = 'DELETE FROM ' . $object->TableName . ' + WHERE ZoneID IN (' . implode(',', $res) . ')'; $this->Conn->Query($sql); - $event->setRedirectParams(Array('opener' => 's', 'pass_events' => false), true); + $event->setRedirectParams(Array ('opener' => 's', 'pass_events' => false)); $event->status = kEvent::erSUCCESS; } @@ -190,7 +199,7 @@ * @return void * @access protected */ - protected function customProcessing(&$event, $type) + protected function customProcessing(kEvent &$event, $type) { if ( $type == 'before' && $this->Application->GetVar('sc') ) { $shipping_obj =& $this->Application->recallObject('s'); @@ -221,35 +230,70 @@ { $event->CallSubEvent('OnCreate'); $event->redirect = false; - $event->setRedirectParams(Array('opener'=>'s','pass'=>'all'), true); + $event->setRedirectParams(Array ('opener' => 's', 'pass' => 'all')); } - function OnAfterCopyToTemp(&$event) + /** + * Occurs after an item has been copied to temp + * Id of copied item is passed as event' 'id' param + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnAfterCopyToTemp(kEvent &$event) { + parent::OnAfterCopyToTemp($event); + $id = $event->getEventParam('id'); - $object =& $this->Application->recallObject($event->Prefix.'.-item', $event->Prefix); + + $object =& $this->Application->recallObject($event->Prefix . '.-item', $event->Prefix); + /* @var $object kDBItem */ + $object->SwitchToTemp(); $object->Load($id); + $shipping_obj =& $this->Application->recallObject('s'); + /* @var $shipping_obj kDBItem */ + $lang_object =& $this->Application->recallObject('lang.current'); + /* @var $lang_object LanguagesItem */ + // by weight and US/UK system - we need to store recalculated price per Kg cause shipping calculation is done per Kg! - if ($shipping_obj->GetDBField('Type') == 1 && $lang_object->GetDBField('UnitSystem') == 2) { + if ( $shipping_obj->GetDBField('Type') == 1 && $lang_object->GetDBField('UnitSystem') == 2 ) { $object->SetDBField('PerUnit', $object->GetDBField('PerUnit') * kUtil::POUND_TO_KG); $object->Update(null, true); } } - function OnBeforeCopyToLive(&$event) + /** + * Occurs before an item is copied to live table (after all foreign keys have been updated) + * Id of item being copied is passed as event' 'id' param + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnBeforeCopyToLive(kEvent &$event) { + parent::OnBeforeCopyToLive($event); + $id = $event->getEventParam('id'); - $object =& $this->Application->recallObject($event->Prefix.'.-item', $event->Prefix); + + $object =& $this->Application->recallObject($event->Prefix . '.-item', $event->Prefix); + /* @var $object kDBItem */ + $object->SwitchToTemp(); $object->Load($id); $shipping_obj =& $this->Application->recallObject('s'); + /* @var $shipping_obj kDBItem */ + $lang_object =& $this->Application->recallObject('lang.current'); + /* @var $lang_object LanguagesItem */ + // by weight and US/UK system - we need to store recalculated price per Kg cause shipping calculation is done per Kg! - if ($shipping_obj->GetDBField('Type') == 1 && $lang_object->GetDBField('UnitSystem') == 2) { + if ( $shipping_obj->GetDBField('Type') == 1 && $lang_object->GetDBField('UnitSystem') == 2 ) { $object->SetDBField('PerUnit', $object->GetDBField('PerUnit') / kUtil::POUND_TO_KG); $object->Update(null, true); } Index: branches/5.2.x/units/payment_type/payment_type_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/payment_type/payment_type_event_handler.php (.../payment_type_event_handler.php) (revision 14986) +++ branches/5.2.x/units/payment_type/payment_type_event_handler.php (.../payment_type_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Conn->Query('UPDATE '.$object->TableName.' SET IsPrimary = 0 '); $this->Conn->Query('UPDATE '.$object->TableName.' SET IsPrimary = 1, Status = 1 WHERE PaymentTypeId = '.$id.' '); } - $event->setRedirectParams(Array('opener' => 's'), true); + $event->SetRedirectParam('opener', 's'); } function OnMassDecline(&$event) { - $object =& $event->getObject( Array('skip_autoload' => true) ); + $object =& $event->getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ + $this->StoreSelectedIDs($event); - $ids=$this->getSelectedIDs($event); + $ids = $this->getSelectedIDs($event); - if($ids) - { - $status_field = array_shift( $this->Application->getUnitOption($event->Prefix,'StatusField') ); + if ( $ids ) { + $status_field = array_shift($this->Application->getUnitOption($event->Prefix, 'StatusField')); - foreach($ids as $id) - { + foreach ($ids as $id) { $object->Load($id); - if (!$object->GetDBField("IsPrimary")){ + if ( !$object->GetDBField("IsPrimary") ) { $object->SetDBField($status_field, 0); } - if( $object->Update() ) - { + if ( $object->Update() ) { $event->status = kEvent::erSUCCESS; - $event->setRedirectParams(Array('opener' => 's'), true); + $event->SetRedirectParam('opener', 's'); } - else - { + else { $event->status = kEvent::erFAIL; $event->redirect = false; break; @@ -115,7 +113,7 @@ * @return void * @access protected */ - protected function OnBeforeItemUpdate(&$event) + protected function OnBeforeItemUpdate(kEvent &$event) { parent::OnBeforeItemUpdate($event); @@ -138,7 +136,7 @@ * @return void * @access protected */ - protected function OnBeforeItemCreate(&$event) + protected function OnBeforeItemCreate(kEvent &$event) { parent::OnBeforeItemCreate($event); @@ -153,24 +151,27 @@ * @return void * @access protected */ - protected function customProcessing(&$event, $type) + protected function customProcessing(kEvent &$event, $type) { - if ($event->Name == 'OnMassDelete' && $type == 'before'){ - $object = &$event->getObject(); + if ( $event->Name == 'OnMassDelete' && $type == 'before' ) { + $object =& $event->getObject(); + /* @var $object kDBItem */ + $ids_ok = Array (); $ids = $event->getEventParam('ids'); - $ids_ok=array(); - foreach ($ids as $key => $id){ + + foreach ($ids as $id) { $object->Load($id); - if ($object->GetDBField('IsPrimary')){ + + if ( $object->GetDBField('IsPrimary') ) { $this->Application->StoreVar('pt_delete_error', '1'); - }else{ - $ids_ok[]=$id; } + else { + $ids_ok[] = $id; + } } $event->setEventParam('ids', $ids_ok); - } } @@ -182,7 +183,7 @@ * @return void * @access protected */ - protected function OnSave(&$event) + protected function OnSave(kEvent &$event) { $this->Application->StoreVar('check_unused_currencies', 1); Index: branches/5.2.x/units/orders/orders_event_handler.php =================================================================== diff -u -N -r15047 -r15061 --- branches/5.2.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 15047) +++ branches/5.2.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ setRedirectParams(Array('opener' => 's'), true); + $event->SetRedirectParam('opener', 's'); } if ($event->status == kEvent::erSUCCESS) { @@ -1598,7 +1600,7 @@ * @return void * @access protected */ - protected function OnPreCreate(&$event) + protected function OnPreCreate(kEvent &$event) { parent::OnPreCreate($event); @@ -1620,13 +1622,14 @@ * @return void * @access protected */ - protected function OnBeforeClone(&$event) + protected function OnBeforeClone(kEvent &$event) { parent::OnBeforeClone($event); $object =& $event->getObject(); + /* @var $object OrdersItem */ - if (substr($event->Special, 0, 9) == 'recurring') { + if ( substr($event->Special, 0, 9) == 'recurring' ) { $object->SetDBField('SubNumber', $object->getNextSubNumber()); $object->SetDBField('OriginalAmount', 0); // needed in this case ? } @@ -1710,7 +1713,7 @@ function OnOrderPrint(&$event) { - $event->setRedirectParams(Array('opener'=>'s'), true); + $event->SetRedirectParam('opener', 's'); } /** @@ -2288,15 +2291,21 @@ * Set's status incomplete to all cloned orders * * @param kEvent $event + * @return void + * @access protected */ - function OnAfterClone(&$event) + protected function OnAfterClone(kEvent &$event) { + parent::OnAfterClone($event); + $id = $event->getEventParam('id'); - $table = $this->Application->getUnitOption($event->Prefix,'TableName'); - $id_field = $this->Application->getUnitOption($event->Prefix,'IDField'); + $table = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); // set cloned order status to Incomplete - $sql = 'UPDATE '.$table.' SET Status = 0 WHERE '.$id_field.' = '.$id; + $sql = 'UPDATE ' . $table . ' + SET Status = 0 + WHERE ' . $id_field . ' = ' . $id; $this->Conn->Query($sql); } @@ -2310,7 +2319,7 @@ * @return void * @access protected */ - protected function OnAfterItemLoad(&$event) + protected function OnAfterItemLoad(kEvent &$event) { parent::OnAfterItemLoad($event); @@ -2358,7 +2367,7 @@ * @return void * @access protected */ - protected function OnBeforeItemCreate(&$event) + protected function OnBeforeItemCreate(kEvent &$event) { parent::OnBeforeItemCreate($event); @@ -2376,7 +2385,7 @@ * @return void * @access protected */ - protected function OnBeforeItemUpdate(&$event) + protected function OnBeforeItemUpdate(kEvent &$event) { parent::OnBeforeItemUpdate($event); @@ -3688,23 +3697,30 @@ * Allows configuring export options * * @param kEvent $event + * @return void + * @access protected */ - function OnBeforeExportBegin(&$event) + protected function OnBeforeExportBegin(kEvent &$event) { - $options = $event->getEventParam('options') ; + parent::OnBeforeExportBegin($event); - $items_list =& $this->Application->recallObject($event->Prefix.'.'.$this->Application->RecallVar('export_oroginal_special'), $event->Prefix.'_List'); + $options = $event->getEventParam('options'); + + $items_list =& $this->Application->recallObject($event->Prefix . '.' . $this->Application->RecallVar('export_oroginal_special'), $event->Prefix . '_List'); + /* @var $items_list kDBList */ + $items_list->SetPerPage(-1); - if ($options['export_ids'] != '') { - $items_list->AddFilter('export_ids', $items_list->TableName.'.'.$items_list->IDField.' IN ('.implode(',',$options['export_ids']).')'); + + if ( $options['export_ids'] != '' ) { + $items_list->AddFilter('export_ids', $items_list->TableName . '.' . $items_list->IDField . ' IN (' . implode(',', $options['export_ids']) . ')'); } - $options['ForceCountSQL'] = $items_list->getCountSQL( $items_list->GetSelectSQL(true,false) ); + $options['ForceCountSQL'] = $items_list->getCountSQL($items_list->GetSelectSQL(true, false)); $options['ForceSelectSQL'] = $items_list->GetSelectSQL(); - $event->setEventParam('options',$options); + $event->setEventParam('options', $options); - $object =& $this->Application->recallObject($event->Prefix.'.export'); + $object =& $this->Application->recallObject($event->Prefix . '.export'); /* @var $object kDBItem */ $object->SetField('Number', 999999); @@ -3716,18 +3732,20 @@ * * @param kEvent $event * @return Array + * @access protected */ - function getCustomExportColumns(&$event) + public function getCustomExportColumns(kEvent &$event) { $columns = parent::getCustomExportColumns($event); - $new_columns = Array( + + $new_columns = Array ( '__VIRTUAL__CustomerName' => 'CustomerName', '__VIRTUAL__TotalAmount' => 'TotalAmount', '__VIRTUAL__AmountWithoutVAT' => 'AmountWithoutVAT', '__VIRTUAL__SubtotalWithDiscount' => 'SubtotalWithDiscount', '__VIRTUAL__SubtotalWithoutDiscount' => 'SubtotalWithoutDiscount', '__VIRTUAL__OrderNumber' => 'OrderNumber', - ); + ); return array_merge($columns, $new_columns); } @@ -3740,7 +3758,7 @@ * @return void * @access protected */ - protected function OnSave(&$event) + protected function OnSave(kEvent &$event) { parent::OnSave($event); @@ -3759,18 +3777,22 @@ } /** - * Occures before an item is copied to live table (after all foreign keys have been updated) + * Occurs before an item is copied to live table (after all foreign keys have been updated) * Id of item being copied is passed as event' 'id' param * * @param kEvent $event + * @return void + * @access protected */ - function OnBeforeCopyToLive(&$event) + protected function OnBeforeCopyToLive(kEvent &$event) { + parent::OnBeforeCopyToLive($event); + $id = $event->getEventParam('id'); - $copied_ids = unserialize($this->Application->RecallVar($event->Prefix.'_copied_ids'.$this->Application->GetVar('wid'), serialize(array()))); + $copied_ids = unserialize($this->Application->RecallVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize(array ()))); array_push($copied_ids, $id); - $this->Application->StoreVar($event->Prefix.'_copied_ids'.$this->Application->GetVar('wid'), serialize($copied_ids) ); + $this->Application->StoreVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize($copied_ids)); } /** Index: branches/5.2.x/units/brackets/brackets_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/brackets/brackets_event_handler.php (.../brackets_event_handler.php) (revision 14986) +++ branches/5.2.x/units/brackets/brackets_event_handler.php (.../brackets_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ OnAfterItemLoad($event); @@ -178,20 +178,39 @@ * @return void * @access protected */ - protected function OnAfterItemCreate(&$event) + protected function OnAfterItemCreate(kEvent &$event) { parent::OnAfterItemCreate($event); $event->CallSubEvent('OnAnyChange'); } - function OnAfterItemUpdate(&$event) + /** + * Occurs after updating item + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnAfterItemUpdate(kEvent &$event) { + parent::OnAfterItemUpdate($event); + $event->CallSubEvent('OnAnyChange'); } - function OnAfterItemDelete(&$event) + /** + * Occurs after deleting item, id of deleted item + * is stored as 'id' param of event + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnAfterItemDelete(kEvent &$event) { + parent::OnAfterItemDelete($event); + $event->CallSubEvent('OnAnyChange'); } @@ -210,7 +229,7 @@ * @return void * @access protected */ - protected function OnPreSaveCreated(&$event) + protected function OnPreSaveCreated(kEvent &$event) { parent::OnPreSaveCreated($event); @@ -220,20 +239,22 @@ $object->SetDBField('PortalGroups', ',' . $this->Application->ConfigValue('User_LoggedInGroup') . ','); } - function UpdateGroups(&$event){ - $object = &$event->getObject(); + function UpdateGroups(&$event) + { + $object =& $event->getObject(); + /* @var $object kDBItem */ - if ($event->Name == 'OnPreSaveCreated') { + if ( $event->Name == 'OnPreSaveCreated' ) { $default_group = $this->Application->ConfigValue('User_LoggedInGroup'); $selected_groups = $default_group; } else { $selected_groups = $object->GetDBField('PortalGroups'); } - if ($selected_groups && $selected_groups!='') { + if ( $selected_groups && $selected_groups != '' ) { $selected_groups = str_replace('|', ',', $selected_groups); - $selected_groups = ','.trim($selected_groups, ',').','; + $selected_groups = ',' . trim($selected_groups, ',') . ','; $object->SetDBField('PortalGroups', $selected_groups); } } @@ -246,7 +267,7 @@ * @return void * @access protected */ - protected function customProcessing(&$event, $type) + protected function customProcessing(kEvent &$event, $type) { $this->UpdateGroups($event); } Index: branches/5.2.x/units/currencies/currencies_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/currencies/currencies_event_handler.php (.../currencies_event_handler.php) (revision 14986) +++ branches/5.2.x/units/currencies/currencies_event_handler.php (.../currencies_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Application->StoreVar('saved_curr_ids', $this->Application->RecallVar($event->Prefix . '_selected_ids')); Index: branches/5.2.x/units/products/products_event_handler.php =================================================================== diff -u -N -r15053 -r15061 --- branches/5.2.x/units/products/products_event_handler.php (.../products_event_handler.php) (revision 15053) +++ branches/5.2.x/units/products/products_event_handler.php (.../products_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ CallSubEvent('OnPreSave'); $this->LoadItem($event); @@ -676,36 +680,34 @@ */ function OnRateProduct(&$event) { - $event->setRedirectParams(Array('pass' => 'all,p'), true); + $event->SetRedirectParam('pass', 'all,p'); $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 - WHERE ItemResourceId='.$object->GetDBField('ResourceId').' - AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'" - AND PortalUserId='.$user_id.' + $sql = ' SELECT * FROM ' . TABLE_PREFIX . 'SpamControl + WHERE ItemResourceId=' . $object->GetDBField('ResourceId') . ' + AND IPaddress="' . $_SERVER['REMOTE_ADDR'] . '" + AND PortalUserId=' . $user_id . ' AND DataType="Rating"'; $res = $this->Conn->GetRow($sql); - if( $res && $res['Expire'] < adodb_mktime() ) - { - $sql = ' DELETE FROM '.TABLE_PREFIX.'SpamControl - WHERE ItemResourceId='.$object->GetDBField('ResourceId').' - AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'" - AND PortalUserId='.$user_id.' + if ( $res && $res['Expire'] < adodb_mktime() ) { + $sql = ' DELETE FROM ' . TABLE_PREFIX . 'SpamControl + WHERE ItemResourceId=' . $object->GetDBField('ResourceId') . ' + AND IPaddress="' . $_SERVER['REMOTE_ADDR'] . '" + AND PortalUserId=' . $user_id . ' AND DataType="Rating"'; $this->Conn->Query($sql); unset($res); } $new_rating = $this->Application->GetVar('rating'); - if($new_rating !== false && !$res) - { + if ( $new_rating !== false && !$res ) { $rating = $object->GetDBField('CachedRating'); $votes = $object->GetDBField('CachedVotesQty'); $new_votes = $votes + 1; @@ -716,19 +718,18 @@ $object->Update(); $expire = adodb_mktime() + $this->Application->ConfigValue('product_ReviewDelay_Value') * $this->Application->ConfigValue('product_ReviewDelay_Interval'); - $sql = ' INSERT INTO '.TABLE_PREFIX.'SpamControl + $sql = ' INSERT INTO ' . TABLE_PREFIX . 'SpamControl (ItemResourceId, IPaddress, PortalUserId, DataType, Expire) - VALUES ('.$object->GetDBField('ResourceId').', - "'.$_SERVER['REMOTE_ADDR'].'", - '.$user_id.', + VALUES (' . $object->GetDBField('ResourceId') . ', + "' . $_SERVER['REMOTE_ADDR'] . '", + ' . $user_id . ', "Rating", - '.$expire.')'; + ' . $expire . ')'; $this->Conn->Query($sql); } - else - { + else { $event->status == kEvent::erFAIL; - $event->redirect=false; + $event->redirect = false; $object->SetError('CachedRating', 'too_frequent', 'lu_ferror_rate_duplicate'); } } @@ -740,7 +741,7 @@ */ function OnCancelAction(&$event) { - $event->setRedirectParams(Array('pass' => 'all,p'), true); + $event->SetRedirectParam('pass', 'all,p'); $event->redirect = $this->Application->GetVar('cancel_template'); } @@ -774,12 +775,12 @@ $email_event = &$this->Application->EmailEventAdmin('PRODUCT.SUGGEST'); if ($email_event->status == kEvent::erSUCCESS){ - $event->setRedirectParams(Array('opener' => 's', 'pass' => 'all'), true); + $event->setRedirectParams(Array('opener' => 's', 'pass' => 'all')); $event->redirect = $this->Application->GetVar('template_success'); } else { -// $event->setRedirectParams(Array('opener' => 's', 'pass' => 'all'), true); -// $event->redirect = $this->Application->GetVar('template_fail'); +// $event->setRedirectParams(Array('opener' => 's', 'pass' => 'all')); +// $event->redirect = $this->Application->GetVar('template_fail'); $object->SetError('Email', 'send_error', 'lu_email_send_error'); $event->status = kEvent::erFAIL; @@ -985,7 +986,7 @@ * @return void * @access protected */ - protected function OnPreSave(&$event) + protected function OnPreSave(kEvent &$event) { $this->CheckRequiredOptions($event); @@ -999,7 +1000,7 @@ * @return void * @access protected */ - protected function OnAfterItemCreate(&$event) + protected function OnAfterItemCreate(kEvent &$event) { parent::OnAfterItemCreate($event); @@ -1010,8 +1011,10 @@ * Set new price to ProductsPricing * * @param kEvent $event + * @return void + * @access protected */ - function OnAfterItemUpdate(&$event) + protected function OnAfterItemUpdate(kEvent &$event) { parent::OnAfterItemUpdate($event); @@ -1093,19 +1096,24 @@ } /** - * Enter description here... + * Occurs after deleting item, id of deleted item + * is stored as 'id' param of event * * @param kEvent $event + * @return void + * @access protected */ - function OnAfterItemDelete(&$event) + protected function OnAfterItemDelete(kEvent &$event) { + parent::OnAfterItemDelete($event); + $product_id = $event->getEventParam('id'); - if(!$product_id) - { + if ( !$product_id ) { return; } - $sql = 'DELETE FROM '.TABLE_PREFIX.'UserFileAccess - WHERE ProductId = '.$product_id; + + $sql = 'DELETE FROM ' . TABLE_PREFIX . 'UserFileAccess + WHERE ProductId = ' . $product_id; $this->Conn->Query($sql); } @@ -1122,7 +1130,7 @@ * @return void * @access protected */ - protected function OnAfterItemLoad(&$event) + protected function OnAfterItemLoad(kEvent &$event) { parent::OnAfterItemLoad($event); @@ -1267,7 +1275,7 @@ { //$event->CallSubEvent('OnUpdate'); $event->redirect = false; - //$event->setRedirectParams(Array('opener'=>'s','pass'=>'all,p'), true); + //$event->setRedirectParams(Array ('opener' => 's', 'pass' => 'all,p')); } /** @@ -1303,18 +1311,27 @@ } /** - * Enter description here... + * Occurs before deleting item, id of item being + * deleted is stored as 'id' event param * * @param kEvent $event + * @return void + * @access protected */ + protected function OnBeforeItemDelete(kEvent &$event) + { + parent::OnBeforeItemDelete($event); + + $object =& $event->getObject(); + /* @var $object kDBItem */ - function OnBeforeItemDelete(&$event){ + $sql = 'SELECT COUNT(*) + FROM ' . TABLE_PREFIX . 'Products + WHERE PackageContent LIKE "%|' . $object->GetID() . '%"'; + $product_includes_in = $this->Conn->GetOne($sql); - $object = &$event->getObject(); - - $product_includes_in = $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Products WHERE PackageContent LIKE "%|'.$object->GetID().'%"'); - if ($product_includes_in > 0){ - $event->status=kEvent::erFAIL; + if ( $product_includes_in > 0 ) { + $event->status = kEvent::erFAIL; } } @@ -1323,14 +1340,17 @@ * * @param kEvent $event * @return Array + * @access protected */ - function getCustomExportColumns(&$event) + public function getCustomExportColumns(kEvent &$event) { $columns = parent::getCustomExportColumns($event); - $new_columns = Array( + + $new_columns = Array ( '__VIRTUAL__Price' => 'Price', '__VIRTUAL__Cost' => 'Cost', ); + return array_merge($columns, $new_columns); } @@ -1352,15 +1372,15 @@ function OnPreSaveAndOpenPopup(&$event) { $object =& $event->getObject(); + /* @var $object kDBItem */ + $this->RemoveRequiredFields($object); $event->CallSubEvent('OnPreSave'); $event->redirect = $this->Application->GetVar('t'); // pass ID too, in case if product is created by OnPreSave call to ensure proper editing - $event->setRedirectParams( Array( - 'pass' => 'all', - $event->getPrefixSpecial(true).'_id' => $object->GetID(), - ), true); + $event->SetRedirectParam('pass', 'all'); + $event->SetRedirectParam($event->getPrefixSpecial(true) . '_id', $object->GetID()); } @@ -1438,10 +1458,13 @@ * Starts product editing, remove any pending inventory actions * * @param kEvent $event + * @return void + * @access protected */ - function OnEdit(&$event) + protected function OnEdit(kEvent &$event) { $this->Application->RemoveVar('inventory_actions'); + parent::OnEdit($event); } @@ -1461,12 +1484,14 @@ * [HOOK] Allows to add cloned subitem to given prefix * * @param kEvent $event + * @return void + * @access protected */ - function OnCloneSubItem(&$event) + protected function OnCloneSubItem(kEvent &$event) { parent::OnCloneSubItem($event); - if ($event->MasterEvent->Prefix == 'rev') { + if ( $event->MasterEvent->Prefix == 'rev' ) { $clones = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Clones'); $subitem_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix; Index: branches/5.2.x/units/shipping_quote_engines/shipping_quote_engine_event_handler.php =================================================================== diff -u -N -r15009 -r15061 --- branches/5.2.x/units/shipping_quote_engines/shipping_quote_engine_event_handler.php (.../shipping_quote_engine_event_handler.php) (revision 15009) +++ branches/5.2.x/units/shipping_quote_engines/shipping_quote_engine_event_handler.php (.../shipping_quote_engine_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ setNextTemplate($event); } /** - * Enter description here... + * Sets next template to be shown after address is added/updated * * @param kEvent $event + * @return void + * @access protected */ - function setNextTemplate(&$event) + protected function setNextTemplate(kEvent &$event) { if ( $this->Application->isAdminUser ) { return; @@ -158,7 +162,7 @@ $event->SetRedirectParam('opener', 's'); $next_template = $this->Application->GetVar('next_template'); - if ($next_template) { + if ( $next_template ) { $event->redirect = $next_template; } } @@ -170,7 +174,7 @@ * @return void * @access protected */ - protected function OnAfterItemLoad(&$event) + protected function OnAfterItemLoad(kEvent &$event) { parent::OnAfterItemLoad($event); @@ -353,7 +357,7 @@ * @return void * @access protected */ - protected function OnBeforeItemCreate(&$event) + protected function OnBeforeItemCreate(kEvent &$event) { parent::OnBeforeItemCreate($event); @@ -384,10 +388,13 @@ * deleted is stored as 'id' event param * * @param kEvent $event - * @access public + * @return void + * @access protected */ - function OnBeforeItemDelete(&$event) + protected function OnBeforeItemDelete(kEvent &$event) { + parent::OnBeforeItemDelete($event); + $object =& $event->getObject(); /* @var $object kDBItem */ Index: branches/5.2.x/units/manufacturers/manufacturers_event_handler.php =================================================================== diff -u -N -r15017 -r15061 --- branches/5.2.x/units/manufacturers/manufacturers_event_handler.php (.../manufacturers_event_handler.php) (revision 15017) +++ branches/5.2.x/units/manufacturers/manufacturers_event_handler.php (.../manufacturers_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ getObject(); - switch ($type) - { + /* @var $bracket kDBItem */ + + switch ($type) { case 'before': $bracket->SetDBField('ProductId', $this->Application->GetVar('p_id')); - if( $bracket->GetDBField('MaxQty') == '∞' || $bracket->GetDBField('MaxQty') == '∞' ) - { + + if ( $bracket->GetDBField('MaxQty') == '∞' || $bracket->GetDBField('MaxQty') == '∞' ) { $bracket->SetDBField('MaxQty', -1); } break; - case 'after': - - break; - default: } } @@ -391,7 +388,7 @@ $this->Conn->Query('UPDATE '.$object->TableName.' SET IsPrimary = 0 WHERE '.$table_info['ForeignKey'].' = '.$table_info['ParentId']); $this->Conn->Query('UPDATE '.$object->TableName.' SET IsPrimary = 1 WHERE ('.$table_info['ForeignKey'].' = '.$table_info['ParentId'].') AND (PriceId = '.$id.')'); } - $event->setRedirectParams(Array('opener' => 's'), true); + $event->SetRedirectParam('opener', 's'); } /** @@ -401,7 +398,7 @@ * @return void * @access protected */ - protected function OnBeforeItemUpdate(&$event) + protected function OnBeforeItemUpdate(kEvent &$event) { parent::OnBeforeItemUpdate($event); @@ -424,7 +421,7 @@ * @return void * @access protected */ - protected function OnBeforeItemCreate(&$event) + protected function OnBeforeItemCreate(kEvent &$event) { parent::OnBeforeItemCreate($event); Index: branches/5.2.x/units/zones/zones_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/zones/zones_event_handler.php (.../zones_event_handler.php) (revision 14986) +++ branches/5.2.x/units/zones/zones_event_handler.php (.../zones_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ getObject(); /* @var $zone_object kDBItem */ - switch ( $type ) { + switch ($type) { case 'before': if ( $event->Name == 'OnCreate' ) { $zone_object->SetDBField('ShippingTypeID', $this->Application->GetVar('s_id')); @@ -239,16 +239,16 @@ * @return void * @access protected */ - function OnCancel(&$event) + protected function OnCancel(kEvent &$event) { parent::OnCancel($event); $dst_object = &$this->Application->recallObject('dst'); /* @var $dst_object kDBItem */ - $delete_zones_sql = ' DELETE FROM ' . $dst_object->TableName . ' - WHERE ShippingZoneId = 0'; - $this->Conn->Query($delete_zones_sql); + $sql = 'DELETE FROM ' . $dst_object->TableName . ' + WHERE ShippingZoneId = 0'; + $this->Conn->Query($sql); // if cancelling after create if ( $this->Application->RecallVar('zone_mode' . $this->Application->GetVar('m_wid')) == 'create' ) { @@ -259,10 +259,18 @@ } } - function OnNew(&$event) + /** + * Prepares new kDBItem object + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnNew(kEvent &$event) { parent::OnNew($event); - $this->Application->StoreVar('zone_mode'.$this->Application->GetVar('m_wid'), 'create'); + + $this->Application->StoreVar('zone_mode' . $this->Application->GetVar('m_wid'), 'create'); } } \ No newline at end of file Index: branches/5.2.x/units/files/files_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/files/files_event_handler.php (.../files_event_handler.php) (revision 14986) +++ branches/5.2.x/units/files/files_event_handler.php (.../files_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ getObject( Array('skip_autoload' => true) ); + /* @var $object kDBItem */ + $object->Load($id); $object->SetDBField('IsPrimary', 1); @@ -149,7 +151,7 @@ * @return void * @access protected */ - protected function customProcessing(&$event, $type) + protected function customProcessing(kEvent &$event, $type) { if ( $event->Name == 'OnMassDelete' && $type == 'before' ) { $ids = $event->getEventParam('ids'); Index: branches/5.2.x/units/affiliate_plans/affiliate_plans_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/affiliate_plans/affiliate_plans_event_handler.php (.../affiliate_plans_event_handler.php) (revision 14986) +++ branches/5.2.x/units/affiliate_plans/affiliate_plans_event_handler.php (.../affiliate_plans_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Name == 'OnMassDelete' && $type == 'before' ) { $ids = $event->getEventParam('ids'); Index: branches/5.2.x/units/taxes/taxes_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/taxes/taxes_event_handler.php (.../taxes_event_handler.php) (revision 14986) +++ branches/5.2.x/units/taxes/taxes_event_handler.php (.../taxes_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ getObject(); /* @var $zone_object kDBItem */ Index: branches/5.2.x/units/affiliate_plans_items/affiliate_plans_items_event_handler.php =================================================================== diff -u -N -r14849 -r15061 --- branches/5.2.x/units/affiliate_plans_items/affiliate_plans_items_event_handler.php (.../affiliate_plans_items_event_handler.php) (revision 14849) +++ branches/5.2.x/units/affiliate_plans_items/affiliate_plans_items_event_handler.php (.../affiliate_plans_items_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ Create() ) { $this->customProcessing($event, 'after'); $event->status = kEvent::erSUCCESS; - $event->setRedirectParams(Array('opener' => 's'), true); //stay! + $event->SetRedirectParam('opener', 's'); //stay! } else { $event->status = kEvent::erFAIL; Index: branches/5.2.x/units/gift_certificates/gift_certificates_eh.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/gift_certificates/gift_certificates_eh.php (.../gift_certificates_eh.php) (revision 14986) +++ branches/5.2.x/units/gift_certificates/gift_certificates_eh.php (.../gift_certificates_eh.php) (revision 15061) @@ -1,6 +1,6 @@ Application->GetVar('currency_list'); - if (!$currency_id_list) { - return ; + if ( !$currency_id_list ) { + return; } - $object =& $event->getObject( Array('skip_autoload' => true) ); + $object =& $event->getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ + $pt_id = $this->Application->GetVar('pt_id'); - if ($pt_id === false) { - return ; + if ( $pt_id === false ) { + return; } $sql = 'DELETE FROM ' . $object->TableName . ' @@ -56,5 +60,4 @@ } } } - } \ No newline at end of file