Index: branches/5.2.x/units/zones/zones_event_handler.php =================================================================== diff -u -N -r14258 -r14625 --- branches/5.2.x/units/zones/zones_event_handler.php (.../zones_event_handler.php) (revision 14258) +++ branches/5.2.x/units/zones/zones_event_handler.php (.../zones_event_handler.php) (revision 14625) @@ -1,6 +1,6 @@ eventMethods = array_merge($this->eventMethods, $zones_events); } - function customProcessing(&$event, $type) + /** + * Apply custom processing to item + * + * @param kEvent $event + * @param string $type + * @return void + * @access protected + */ + protected function customProcessing(&$event, $type) { - $zone_object =& $event->GetObject(); - switch($type) - { + $zone_object =& $event->getObject(); + /* @var $zone_object kDBItem */ + + switch ( $type ) { case 'before': - if ($event->Name == 'OnCreate') - { + if ( $event->Name == 'OnCreate' ) { $zone_object->SetDBField('ShippingTypeID', $this->Application->GetVar('s_id')); } break; + case 'after': - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - $dst_object =& $this->Application->RecallObject('dst'); - if ($event->Name == 'OnUpdate') - { - $sql = 'DELETE FROM '.$dst_object->TableName.' WHERE ShippingZoneId='.$zone_object->GetID(); + $dst_object =& $this->Application->recallObject('dst'); + /* @var $dst_object kDBItem */ + + if ( $event->Name == 'OnUpdate' ) { + $sql = 'DELETE FROM ' . $dst_object->TableName . ' + WHERE ShippingZoneId = ' . $zone_object->GetID(); $this->Conn->Query($sql); } - else - { - $temp = $this->Application->GetVar('dst'); - foreach ($temp as $key => $value) - { + else { + $temp = $this->Application->GetVar('dst', Array ()); + foreach ($temp as $key => $value) { $temp[$key]['ShippingZoneId'] = $zone_object->GetID(); } $this->Application->SetVar('dst', $temp); } - $dst_event = new kEvent(); - $dst_event->Init('dst'); - $dst_event->Name = 'OnCreate'; + $dst_event = new kEvent('dst:OnCreate'); $this->Application->HandleEvent($dst_event); break; - - default: } } @@ -200,22 +204,6 @@ } } - function OnMassDelete(&$event) - { - $ids = $this->StoreSelectedIDs($event); - - $event->setEventParam('ids', $ids); - $this->customProcessing($event, 'before'); - $ids = $event->getEventParam('ids'); - $ids = implode(',', $ids); - - $dst =& $this->Application->recallObject('dst'); - $sql = 'DELETE FROM '.$dst->TableName.' WHERE ShippingZoneId IN ('.$ids.')'; - $this->Conn->Query($sql); - - parent::OnMassDelete($event); - } - function OnCountryChange(&$event) { $destinations = &$this->Application->recallObject('dst'); @@ -229,16 +217,29 @@ $event->redirect = false; } - function OnCancel(&$event){ - + /** + * Cancels kDBItem Editing/Creation + * + * @param kEvent $event + * @return void + * @access protected + */ + function OnCancel(&$event) + { parent::OnCancel($event); + $dst_object = &$this->Application->recallObject('dst'); - $delete_zones_sql = 'DELETE FROM '.$dst_object->TableName.' WHERE ShippingZoneId = 0'; + /* @var $dst_object kDBItem */ + + $delete_zones_sql = ' DELETE FROM ' . $dst_object->TableName . ' + WHERE ShippingZoneId = 0'; $this->Conn->Query($delete_zones_sql); // if cancelling after create - if ($this->Application->RecallVar('zone_mode'.$this->Application->GetVar('m_wid')) == 'create') { + if ( $this->Application->RecallVar('zone_mode' . $this->Application->GetVar('m_wid')) == 'create' ) { $zone =& $event->getObject(); + /* @var $zone kDBItem */ + $zone->Delete(); } }