Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/priority_helper.php
Show All 21 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @param bool $is_new for newly created items add new priority to the end | * @param bool $is_new for newly created items add new priority to the end | ||||
* @param string $constrain constrain for priority selection (if any) | * @param string $constrain constrain for priority selection (if any) | ||||
* @param string $joins left joins, used by constrain (if any) | * @param string $joins left joins, used by constrain (if any) | ||||
* | * | ||||
*/ | */ | ||||
function preparePriorities($event, $is_new = false, $constrain = '', $joins = '') | function preparePriorities($event, $is_new = false, $constrain = '', $joins = '') | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$field_options = $object->GetFieldOptions('Priority'); | $field_options = $object->GetFieldOptions('Priority'); | ||||
$table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); | $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); | ||||
$sql = 'SELECT COUNT(*) | $sql = 'SELECT COUNT(*) | ||||
FROM ' . $table_name . ' item_table | FROM ' . $table_name . ' item_table | ||||
' . $joins; | ' . $joins; | ||||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @param string $prefix | * @param string $prefix | ||||
* @param Array $ids | * @param Array $ids | ||||
*/ | */ | ||||
function massUpdateChanged($prefix, $ids) | function massUpdateChanged($prefix, $ids) | ||||
{ | { | ||||
$ids = array_unique($ids); | $ids = array_unique($ids); | ||||
/** @var kDBItem $dummy */ | |||||
$dummy = $this->Application->recallObject($prefix . '.-dummy', null, Array ('skip_autoload' => true)); | $dummy = $this->Application->recallObject($prefix . '.-dummy', null, Array ('skip_autoload' => true)); | ||||
/* @var $dummy kDBItem */ | |||||
$sql = $dummy->GetSelectSQL() . ' | $sql = $dummy->GetSelectSQL() . ' | ||||
WHERE ' . $dummy->TableName . '.' . $dummy->IDField . ' IN (' . implode(',', $ids) . ')'; | WHERE ' . $dummy->TableName . '.' . $dummy->IDField . ' IN (' . implode(',', $ids) . ')'; | ||||
$records = $this->Conn->Query($sql); | $records = $this->Conn->Query($sql); | ||||
foreach ($records as $record) { | foreach ($records as $record) { | ||||
$dummy->LoadFromHash($record); | $dummy->LoadFromHash($record); | ||||
$dummy->Update(); | $dummy->Update(); | ||||
} | } | ||||
} | } | ||||
} | } |