Changeset View
Changeset View
Standalone View
Standalone View
core/kernel/db/db_event_handler.php
Show First 20 Lines • Show All 1228 Lines • ▼ Show 20 Line(s) | |||||
$view_name = $this->Application->RecallVar($event->getPrefixSpecial() . '_current_view'); | $view_name = $this->Application->RecallVar($event->getPrefixSpecial() . '_current_view'); | ||||
$custom_filters = $this->Application->RecallPersistentVar($event->getPrefixSpecial() . '_custom_filter.' . $view_name); | $custom_filters = $this->Application->RecallPersistentVar($event->getPrefixSpecial() . '_custom_filter.' . $view_name); | ||||
if ( $custom_filters ) { | if ( $custom_filters ) { | ||||
$grid_name = $event->getEventParam('grid'); | $grid_name = $event->getEventParam('grid'); | ||||
$custom_filters = unserialize($custom_filters); | $custom_filters = unserialize($custom_filters); | ||||
if ( isset($custom_filters[$grid_name]) ) { | if ( isset($custom_filters[$grid_name]) ) { | ||||
foreach ($custom_filters[$grid_name] as $field_name => $field_options) { | foreach ($custom_filters[$grid_name] as $field_name => $field_options) { | ||||
Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace: Expected 1 spaces before "foreach" closing bracket; 0 found | |||||
Expected 1 spaces after "foreach" opening bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace: Expected 1 spaces after "foreach" opening bracket; 0 found | |||||
list ($filter_type, $field_options) = each($field_options); | $field_options = current($field_options); | ||||
if ( isset($field_options['value']) && $field_options['value'] ) { | if ( isset($field_options['value']) && $field_options['value'] ) { | ||||
$filter_type = ($field_options['sql_filter_type'] == 'having') ? kDBList::HAVING_FILTER : kDBList::WHERE_FILTER; | $filter_type = ($field_options['sql_filter_type'] == 'having') ? kDBList::HAVING_FILTER : kDBList::WHERE_FILTER; | ||||
$filter_value = str_replace(EDIT_MARK, $edit_mark, $field_options['value']); | $filter_value = str_replace(EDIT_MARK, $edit_mark, $field_options['value']); | ||||
$object->addFilter($field_name, $filter_value, $filter_type, kDBList::FLT_CUSTOM); | $object->addFilter($field_name, $filter_value, $filter_type, kDBList::FLT_CUSTOM); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 317 Lines • ▼ Show 20 Line(s) | |||||
$object = $event->getObject(Array ('skip_autoload' => true)); | $object = $event->getObject(Array ('skip_autoload' => true)); | ||||
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | ||||
if ( !$items_info ) { | if ( !$items_info ) { | ||||
return; | return; | ||||
} | } | ||||
list($id, $field_values) = each($items_info); | $id = key($items_info); | ||||
$field_values = $items_info[$id]; | |||||
$object->setID($id); | $object->setID($id); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
$this->customProcessing($event, 'before'); | $this->customProcessing($event, 'before'); | ||||
// look at kDBItem' Create for ForceCreateId description, it's rarely used and is NOT set by default | // look at kDBItem' Create for ForceCreateId description, it's rarely used and is NOT set by default | ||||
if ( $object->Create($event->getEventParam('ForceCreateId')) ) { | if ( $object->Create($event->getEventParam('ForceCreateId')) ) { | ||||
▲ Show 20 Lines • Show All 1354 Lines • ▼ Show 20 Line(s) | |||||
protected function OnSelectUser(kEvent $event) | protected function OnSelectUser(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | /** @var kDBItem $object */ | ||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
$items_info = $this->Application->GetVar('u'); | $items_info = $this->Application->GetVar('u'); | ||||
if ( $items_info ) { | if ( $items_info ) { | ||||
list ($user_id, ) = each($items_info); | $user_id = key($items_info); | ||||
$this->RemoveRequiredFields($object); | $this->RemoveRequiredFields($object); | ||||
$is_new = !$object->isLoaded(); | $is_new = !$object->isLoaded(); | ||||
$is_main = substr($this->Application->GetVar($event->Prefix . '_mode'), 0, 1) == 't'; | $is_main = substr($this->Application->GetVar($event->Prefix . '_mode'), 0, 1) == 't'; | ||||
if ( $is_new ) { | if ( $is_new ) { | ||||
$new_event = $is_main ? 'OnPreCreate' : 'OnNew'; | $new_event = $is_main ? 'OnPreCreate' : 'OnNew'; | ||||
$event->CallSubEvent($new_event); | $event->CallSubEvent($new_event); | ||||
▲ Show 20 Lines • Show All 336 Lines • ▼ Show 20 Line(s) | |||||
$object = $event->getObject(Array ('skip_autoload' => true)); | $object = $event->getObject(Array ('skip_autoload' => true)); | ||||
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | ||||
if ( !$items_info ) { | if ( !$items_info ) { | ||||
return; | return; | ||||
} | } | ||||
list ($id, $field_values) = each($items_info); | $id = key($items_info); | ||||
$field_values = $items_info[$id]; | |||||
$object->Load($id); | $object->Load($id); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
$object->setID($id); | $object->setID($id); | ||||
$response = Array ('status' => 'OK'); | $response = Array ('status' => 'OK'); | ||||
$event->CallSubEvent($object->isLoaded() ? 'OnBeforeItemUpdate' : 'OnBeforeItemCreate'); | $event->CallSubEvent($object->isLoaded() ? 'OnBeforeItemUpdate' : 'OnBeforeItemCreate'); | ||||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |
Expected 1 spaces before "foreach" closing bracket; 0 found