Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/units/orders/orders_event_handler.php
Show First 20 Lines • Show All 3793 Lines • ▼ Show 20 Line(s) | |||||
protected function OnSave(kEvent $event) | protected function OnSave(kEvent $event) | ||||
{ | { | ||||
parent::OnSave($event); | parent::OnSave($event); | ||||
if ( $event->status != kEvent::erSUCCESS ) { | if ( $event->status != kEvent::erSUCCESS ) { | ||||
return ; | return ; | ||||
} | } | ||||
$copied_ids = unserialize($this->Application->RecallVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize(Array ()))); | foreach ( $this->trackCopiedOrderIDs($event) as $id ) { | ||||
foreach ($copied_ids as $id) { | |||||
$an_event = new kEvent($this->Prefix . ':Dummy'); | $an_event = new kEvent($this->Prefix . ':Dummy'); | ||||
$this->Application->SetVar($this->Prefix . '_id', $id); | $this->Application->SetVar($this->Prefix . '_id', $id); | ||||
$this->Application->SetVar($this->Prefix . '_mode', ''); // this is to fool ReserveItems to use live table | $this->Application->SetVar($this->Prefix . '_mode', ''); // this is to fool ReserveItems to use live table | ||||
$this->ReserveItems($an_event); | $this->ReserveItems($an_event); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Occurs before an item is copied to live table (after all foreign keys have been updated) | * Occurs after an item has been copied to live table | ||||
* Id of item being copied is passed as event' 'id' param | * Id of copied item is passed as event' 'id' param | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBeforeCopyToLive(kEvent $event) | protected function OnAfterCopyToLive(kEvent $event) | ||||
{ | { | ||||
parent::OnBeforeCopyToLive($event); | parent::OnAfterCopyToLive($event); | ||||
$id = $event->getEventParam('id'); | $this->trackCopiedOrderIDs($event, $event->getEventParam('id')); | ||||
$copied_ids = unserialize($this->Application->RecallVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize(array ()))); | } | ||||
array_push($copied_ids, $id); | |||||
/** | |||||
* Tracks copied order IDs. | |||||
* | |||||
* @param kEvent $event Event. | |||||
* @param integer $id Order ID. | |||||
* | |||||
* @return array | |||||
*/ | |||||
protected function trackCopiedOrderIDs(kEvent $event, $id = null) | |||||
{ | |||||
$setting_name = $event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'); | |||||
$ids = $this->Application->GetVar($setting_name, array()); | |||||
if ( isset($id) ) { | |||||
array_push($ids, $id); | |||||
$this->Application->SetVar($setting_name, $ids); | |||||
} | |||||
$this->Application->StoreVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize($copied_ids)); | return $ids; | ||||
} | } | ||||
/** | /** | ||||
* Checks, that currently loaded item is allowed for viewing (non permission-based) | * Checks, that currently loaded item is allowed for viewing (non permission-based) | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return bool | * @return bool | ||||
* @access protected | * @access protected | ||||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |