Changeset View
Changeset View
Standalone View
Standalone View
core/units/filters/item_filter_eh.php
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
* @access protected | * @access protected | ||||
* @see kDBEventHandler::OnListBuild() | * @see kDBEventHandler::OnListBuild() | ||||
*/ | */ | ||||
protected function SetCustomQuery(kEvent $event) | protected function SetCustomQuery(kEvent $event) | ||||
{ | { | ||||
parent::SetCustomQuery($event); | parent::SetCustomQuery($event); | ||||
if ( !$this->Application->isAdmin ) { | if ( !$this->Application->isAdmin ) { | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
$prefix_info = $this->Application->processPrefix($event->getEventParam('prefix')); | $prefix_info = $this->Application->processPrefix($event->getEventParam('prefix')); | ||||
$object->addFilter('prefix_filter', '%1$s.ItemPrefix = ' . $this->Conn->qstr($prefix_info['prefix'])); | $object->addFilter('prefix_filter', '%1$s.ItemPrefix = ' . $this->Conn->qstr($prefix_info['prefix'])); | ||||
$object->addFilter('status_filter', '%1$s.Enabled = 1'); | $object->addFilter('status_filter', '%1$s.Enabled = 1'); | ||||
if ( $event->Special == 'used' ) { | if ( $event->Special == 'used' ) { | ||||
$filters = array_keys($this->Application->GetVar('filters', Array ())); | $filters = array_keys($this->Application->GetVar('filters', Array ())); | ||||
Show All 26 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBeforeItemValidate(kEvent $event) | protected function OnBeforeItemValidate(kEvent $event) | ||||
{ | { | ||||
parent::OnBeforeItemValidate($event); | parent::OnBeforeItemValidate($event); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$prefix = $object->GetDBField('ItemPrefix'); | $prefix = $object->GetDBField('ItemPrefix'); | ||||
if ( $prefix ) { | if ( $prefix ) { | ||||
if ( !$this->Application->prefixRegistred($prefix) ) { | if ( !$this->Application->prefixRegistred($prefix) ) { | ||||
$object->SetError('ItemPrefix', 'not_registered'); | $object->SetError('ItemPrefix', 'not_registered'); | ||||
} | } | ||||
Show All 24 Lines | |||||
static $cache = null; | static $cache = null; | ||||
if ( $this->Application->isAdmin ) { | if ( $this->Application->isAdmin ) { | ||||
parent::LoadItem($event); | parent::LoadItem($event); | ||||
return; | return; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
if ( !isset($cache) ) { | if ( !isset($cache) ) { | ||||
$cache = $this->Conn->Query($object->GetSelectSQL(), 'FilterKey'); | $cache = $this->Conn->Query($object->GetSelectSQL(), 'FilterKey'); | ||||
} | } | ||||
$filter_key = $event->getEventParam('prefix') . '_' . $event->getEventParam('field'); | $filter_key = $event->getEventParam('prefix') . '_' . $event->getEventParam('field'); | ||||
if ( isset($cache[$filter_key]) ) { | if ( isset($cache[$filter_key]) ) { | ||||
$object->LoadFromHash($cache[$filter_key]); | $object->LoadFromHash($cache[$filter_key]); | ||||
} | } | ||||
if ( $object->isLoaded() ) { | if ( $object->isLoaded() ) { | ||||
/** @var Params $actions */ | |||||
$actions = $this->Application->recallObject('kActions'); | $actions = $this->Application->recallObject('kActions'); | ||||
/* @var $actions Params */ | |||||
$actions->Set($event->getPrefixSpecial() . '_id', $object->GetID()); | $actions->Set($event->getPrefixSpecial() . '_id', $object->GetID()); | ||||
} | } | ||||
else { | else { | ||||
$object->setID(false); | $object->setID(false); | ||||
} | } | ||||
} | } | ||||
} | } |