Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/units/listings/listings_event_handler.php
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | |||||
if ($object->GetDBField('ExpiresOn') < adodb_mktime()) { | if ($object->GetDBField('ExpiresOn') < adodb_mktime()) { | ||||
$object->SetDBField('Status', STATUS_PENDING); | $object->SetDBField('Status', STATUS_PENDING); | ||||
$object->Update(); | $object->Update(); | ||||
$this->ResetLink($original_values); | $this->ResetLink($original_values); | ||||
return false; | return false; | ||||
} | } | ||||
$this->UpdateLink('OnPurchase', $object->GetDBField('ItemResourceId'), $object->GetDBField('ListingTypeId')); | list($link_object, $listtype_object) = $this->UpdateLink( | ||||
'OnPurchase', | |||||
$object->GetDBField('ItemResourceId'), | |||||
$object->GetDBField('ListingTypeId') | |||||
); | |||||
$listtype_object = $this->Application->recallObject('lst'); | |||||
if ( $listtype_object->GetDBField('OnPurchaseAddToCatEnabled') ) | if ( $listtype_object->GetDBField('OnPurchaseAddToCatEnabled') ) | ||||
{ | { | ||||
$link_object = $this->Application->recallObject('l'); | |||||
$add_to_cat = (int)$listtype_object->GetDBField('OnPurchaseAddToCat'); | $add_to_cat = (int)$listtype_object->GetDBField('OnPurchaseAddToCat'); | ||||
$sql = 'DELETE FROM '.$this->Application->getUnitOption('l-ci', 'TableName').' | $sql = 'DELETE FROM '.$this->Application->getUnitOption('l-ci', 'TableName').' | ||||
WHERE CategoryId = '.$add_to_cat.' | WHERE CategoryId = '.$add_to_cat.' | ||||
AND ItemResourceId = '.$link_object->GetDBField('ResourceId').' | AND ItemResourceId = '.$link_object->GetDBField('ResourceId').' | ||||
AND PrimaryCat = 0'; | AND PrimaryCat = 0'; | ||||
$this->Conn->Query($sql); | $this->Conn->Query($sql); | ||||
$sql = 'INSERT INTO '.$this->Application->getUnitOption('l-ci', 'TableName').' | $sql = 'INSERT INTO '.$this->Application->getUnitOption('l-ci', 'TableName').' | ||||
(CategoryId, ItemResourceId, PrimaryCat) | (CategoryId, ItemResourceId, PrimaryCat) | ||||
Show All 9 Lines | |||||
if( $original_values['Status'] != STATUS_ACTIVE || | if( $original_values['Status'] != STATUS_ACTIVE || | ||||
getArrayValue($has_been_reset, $original_values['ListingId']) ) | getArrayValue($has_been_reset, $original_values['ListingId']) ) | ||||
{ | { | ||||
return; | return; | ||||
} | } | ||||
$has_been_reset[$original_values['ListingId']] = 1; | $has_been_reset[$original_values['ListingId']] = 1; | ||||
$this->UpdateLink('OnExpire', $original_values['ItemResourceId'], $original_values['ListingTypeId']); | list (, $listtype_object) = $this->UpdateLink( | ||||
'OnExpire', | |||||
$original_values['ItemResourceId'], | |||||
$original_values['ListingTypeId'] | |||||
); | |||||
$listtype_object = $this->Application->recallObject('lst'); | |||||
if( $listtype_object->GetDBField('OnExpireRemoveFromCatEnabled') ) | if( $listtype_object->GetDBField('OnExpireRemoveFromCatEnabled') ) | ||||
{ | { | ||||
$remove_from_cat = $listtype_object->GetDBField('OnExpireRemoveFromCat'); | $remove_from_cat = $listtype_object->GetDBField('OnExpireRemoveFromCat'); | ||||
$sql = 'DELETE FROM '.$this->Application->getUnitOption('l-ci', 'TableName').' | $sql = 'DELETE FROM '.$this->Application->getUnitOption('l-ci', 'TableName').' | ||||
WHERE ItemResourceId = '.$original_values['ItemResourceId'].' | WHERE ItemResourceId = '.$original_values['ItemResourceId'].' | ||||
AND CategoryId = '.$remove_from_cat.' | AND CategoryId = '.$remove_from_cat.' | ||||
AND PrimaryCat = 0'; | AND PrimaryCat = 0'; | ||||
$this->Conn->Query($sql); | $this->Conn->Query($sql); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
case 3: // decrease | case 3: // decrease | ||||
$original_priority = $link_object->GetDBField('Priority'); | $original_priority = $link_object->GetDBField('Priority'); | ||||
$link_object->SetDBField('Priority', $original_priority - $priority_value); | $link_object->SetDBField('Priority', $original_priority - $priority_value); | ||||
break; | break; | ||||
default: | default: | ||||
} | } | ||||
$link_object->Update(); | $link_object->Update(); | ||||
return array($link_object, $listtype_object); | |||||
} | } | ||||
/** | /** | ||||
* Enter description here... | * Enter description here... | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnRequestEnhancement($event) | function OnRequestEnhancement($event) | ||||
▲ Show 20 Lines • Show All 565 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
parent::OnAfterConfigRead($event); | parent::OnAfterConfigRead($event); | ||||
$language_id = $this->Application->GetVar('m_lang'); | $language_id = $this->Application->GetVar('m_lang'); | ||||
$calculated_fields = $this->Application->getUnitOption($event->Prefix, 'CalculatedFields'); | $calculated_fields = $this->Application->getUnitOption($event->Prefix, 'CalculatedFields'); | ||||
$calculated_fields['']['LinkName'] = 'CONCAT(item_table.l' . $language_id . '_Name, " (", item_table.Url, ")")'; | $calculated_fields['']['LinkName'] = 'CONCAT(item_table.l' . $language_id . '_Name, " (", item_table.Url, ")")'; | ||||
$this->Application->setUnitOption($event->Prefix, 'CalculatedFields', $calculated_fields); | $this->Application->setUnitOption($event->Prefix, 'CalculatedFields', $calculated_fields); | ||||
} | } | ||||
} | } | ||||
No newline at end of file |