Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/relationship/relationship_event_handler.php
Show All 39 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnNew(kEvent $event) | protected function OnNew(kEvent $event) | ||||
{ | { | ||||
parent::OnNew($event); | parent::OnNew($event); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$table_info = $object->getLinkedInfo(); | $table_info = $object->getLinkedInfo(); | ||||
$object->SetDBField('SourceId', $table_info['ParentId']); | $object->SetDBField('SourceId', $table_info['ParentId']); | ||||
$source_itemtype = $this->Application->getUnitOption($table_info['ParentPrefix'], 'ItemType'); | $source_itemtype = $this->Application->getUnitOption($table_info['ParentPrefix'], 'ItemType'); | ||||
$object->SetDBField('SourceType', $source_itemtype); | $object->SetDBField('SourceType', $source_itemtype); | ||||
$object->SetDBField('TargetId', $this->Application->GetVar('target_id')); | $object->SetDBField('TargetId', $this->Application->GetVar('target_id')); | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterItemLoad(kEvent $event) | protected function OnAfterItemLoad(kEvent $event) | ||||
{ | { | ||||
parent::OnAfterItemLoad($event); | parent::OnAfterItemLoad($event); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$sql = 'SELECT Prefix | $sql = 'SELECT Prefix | ||||
FROM ' . TABLE_PREFIX . 'ItemTypes | FROM ' . TABLE_PREFIX . 'ItemTypes | ||||
WHERE ItemType = ' . $object->GetDBField('TargetType'); | WHERE ItemType = ' . $object->GetDBField('TargetType'); | ||||
$target_prefix = $this->Conn->GetOne($sql); | $target_prefix = $this->Conn->GetOne($sql); | ||||
$title_field = $this->getTitleField($target_prefix); | $title_field = $this->getTitleField($target_prefix); | ||||
$title_phrase = $this->Application->getUnitOption($target_prefix, 'TitlePhrase'); | $title_phrase = $this->Application->getUnitOption($target_prefix, 'TitlePhrase'); | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Deletes relations to hooked item from other items | * Deletes relations to hooked item from other items | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnDeleteForeignRelations($event) | function OnDeleteForeignRelations($event) | ||||
{ | { | ||||
/** @var kDBItem $main_object */ | |||||
$main_object = $event->MasterEvent->getObject(); | $main_object = $event->MasterEvent->getObject(); | ||||
/* @var $main_object kDBItem */ | |||||
$sql = 'DELETE FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . ' | $sql = 'DELETE FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . ' | ||||
WHERE TargetId = ' . $main_object->GetDBField('ResourceId'); | WHERE TargetId = ' . $main_object->GetDBField('ResourceId'); | ||||
$this->Conn->Query($sql); | $this->Conn->Query($sql); | ||||
} | } | ||||
} | } | ||||
No newline at end of file | No newline at end of file |