Changeset View
Changeset View
Standalone View
Standalone View
core/units/categories/categories_event_handler.php
Show First 20 Lines • Show All 1572 Lines • ▼ Show 20 Line(s) | |||||
$ids = $this->StoreSelectedIDs($event); | $ids = $this->StoreSelectedIDs($event); | ||||
if ( $ids ) { | if ( $ids ) { | ||||
$status_field = $object->getStatusField(); | $status_field = $object->getStatusField(); | ||||
$propagate_category_status = $this->Application->GetVar('propagate_category_status'); | $propagate_category_status = $this->Application->GetVar('propagate_category_status'); | ||||
foreach ($ids as $id) { | foreach ($ids as $id) { | ||||
$object->Clear(); | |||||
$object->Load($id); | $object->Load($id); | ||||
$object->SetDBField($status_field, $event->Name == 'OnMassApprove' ? 1 : 0); | $object->SetDBField($status_field, $event->Name == 'OnMassApprove' ? 1 : 0); | ||||
if ( $object->Update() ) { | if ( $object->Update() ) { | ||||
if ( $propagate_category_status ) { | if ( $propagate_category_status ) { | ||||
$sql = 'UPDATE ' . $object->TableName . ' | $sql = 'UPDATE ' . $object->TableName . ' | ||||
SET ' . $status_field . ' = ' . $object->GetDBField($status_field) . ' | SET ' . $status_field . ' = ' . $object->GetDBField($status_field) . ' | ||||
WHERE TreeLeft BETWEEN ' . $object->GetDBField('TreeLeft') . ' AND ' . $object->GetDBField('TreeRight'); | WHERE TreeLeft BETWEEN ' . $object->GetDBField('TreeLeft') . ' AND ' . $object->GetDBField('TreeRight'); | ||||
$this->Conn->Query($sql); | $this->Conn->Query($sql); | ||||
} | } | ||||
$event->status = kEvent::erSUCCESS; | |||||
$email_event = $event->Name == 'OnMassApprove' ? 'CATEGORY.APPROVE' : 'CATEGORY.DENY'; | $email_event = $event->Name == 'OnMassApprove' ? 'CATEGORY.APPROVE' : 'CATEGORY.DENY'; | ||||
$this->Application->emailUser($email_event, $object->GetDBField('CreatedById')); | $this->Application->emailUser($email_event, $object->GetDBField('CreatedById')); | ||||
} | } | ||||
else { | |||||
$event->status = kEvent::erFAIL; | |||||
$event->redirect = false; | |||||
break; | |||||
} | |||||
} | } | ||||
} | } | ||||
$this->clearSelectedIDs($event); | $this->clearSelectedIDs($event); | ||||
$this->Application->StoreVar('RefreshStructureTree', 1); | $this->Application->StoreVar('RefreshStructureTree', 1); | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 1535 Lines • Show Last 20 Lines |