Changeset View
Changeset View
Standalone View
Standalone View
core/units/priorites/priority_eh.php
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | |||||
'HookToEvent' => Array('OnAfterItemDelete'), | 'HookToEvent' => Array('OnAfterItemDelete'), | ||||
'DoPrefix' => 'priority', | 'DoPrefix' => 'priority', | ||||
'DoSpecial' => '*', | 'DoSpecial' => '*', | ||||
'DoEvent' => 'OnItemDelete', | 'DoEvent' => 'OnItemDelete', | ||||
'Conditional' => false, | 'Conditional' => false, | ||||
) | ) | ||||
); | ); | ||||
/** @var Array $prefixes */ | |||||
$prefixes = $this->Application->getUnitOption($event->Prefix, 'ProcessPrefixes', Array ()); | $prefixes = $this->Application->getUnitOption($event->Prefix, 'ProcessPrefixes', Array ()); | ||||
Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
PHP keywords must be lowercase; expected "array" but found "Array" Lint: Generic.PHP.LowerCaseKeyword.Found: PHP keywords must be lowercase; expected "array" but found "Array" | |||||
/* @var $prefixes Array */ | |||||
foreach ($prefixes as $prefix) { | foreach ($prefixes as $prefix) { | ||||
foreach ($hooks as $hook) { | foreach ($hooks as $hook) { | ||||
if ( !is_array($hook['HookToEvent']) ) { | if ( !is_array($hook['HookToEvent']) ) { | ||||
$hook['HookToEvent'] = Array($hook['HookToEvent']); | $hook['HookToEvent'] = Array($hook['HookToEvent']); | ||||
} | } | ||||
foreach ($hook['HookToEvent'] as $hook_event) { | foreach ($hook['HookToEvent'] as $hook_event) { | ||||
Show All 14 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnPreparePriorities($event) | function OnPreparePriorities($event) | ||||
{ | { | ||||
if ( !$this->Application->isAdminUser ) { | if ( !$this->Application->isAdminUser ) { | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kPriorityHelper $priority_helper */ | |||||
$priority_helper = $this->Application->recallObject('PriorityHelper'); | $priority_helper = $this->Application->recallObject('PriorityHelper'); | ||||
/* @var $priority_helper kPriorityHelper */ | |||||
list ($constrain, $joins) = $this->getConstrainInfo($event); | list ($constrain, $joins) = $this->getConstrainInfo($event); | ||||
$is_new = $event->MasterEvent->Name == 'OnPreCreate' || $event->MasterEvent->Name == 'OnPreSaveCreated'; | $is_new = $event->MasterEvent->Name == 'OnPreCreate' || $event->MasterEvent->Name == 'OnPreSaveCreated'; | ||||
$priority_helper->preparePriorities($event->MasterEvent, $is_new, $constrain, $joins); | $priority_helper->preparePriorities($event->MasterEvent, $is_new, $constrain, $joins); | ||||
} | } | ||||
/** | /** | ||||
* Enter description here... | * Enter description here... | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnBeforeShutDown($event) | function OnBeforeShutDown($event) | ||||
{ | { | ||||
$del = $this->Application->RecallVar('priority_deleted'.$this->Application->GetVar('m_wid')); | $del = $this->Application->RecallVar('priority_deleted'.$this->Application->GetVar('m_wid')); | ||||
$del = $del ? unserialize($del) : array(); | $del = $del ? unserialize($del) : array(); | ||||
/** @var kPriorityHelper $priority_helper */ | |||||
$priority_helper = $this->Application->recallObject('PriorityHelper'); | $priority_helper = $this->Application->recallObject('PriorityHelper'); | ||||
/* @var $priority_helper kPriorityHelper */ | |||||
foreach ($del as $del_info) { | foreach ($del as $del_info) { | ||||
$dummy_event = new kEvent( array('prefix'=>$del_info['prefix'], 'name'=>'Dummy' ) ); | $dummy_event = new kEvent( array('prefix'=>$del_info['prefix'], 'name'=>'Dummy' ) ); | ||||
$ids = $priority_helper->recalculatePriorities($dummy_event, $del_info['constrain'], $del_info['joins']); | $ids = $priority_helper->recalculatePriorities($dummy_event, $del_info['constrain'], $del_info['joins']); | ||||
if ($ids) { | if ($ids) { | ||||
$priority_helper->massUpdateChanged($del_info['prefix'], $ids); | $priority_helper->massUpdateChanged($del_info['prefix'], $ids); | ||||
} | } | ||||
} | } | ||||
$this->Application->RemoveVar('priority_deleted'.$this->Application->GetVar('m_wid')); | $this->Application->RemoveVar('priority_deleted'.$this->Application->GetVar('m_wid')); | ||||
} | } | ||||
/** | /** | ||||
* Enter description here... | * Enter description here... | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnSaveItems($event) | function OnSaveItems($event) | ||||
{ | { | ||||
$tmp = $this->Application->RecallVar('priority_changes'.$this->Application->GetVar('m_wid')); | $tmp = $this->Application->RecallVar('priority_changes'.$this->Application->GetVar('m_wid')); | ||||
$changes = $tmp ? unserialize($tmp) : array(); | $changes = $tmp ? unserialize($tmp) : array(); | ||||
/** @var kPriorityHelper $priority_helper */ | |||||
$priority_helper = $this->Application->recallObject('PriorityHelper'); | $priority_helper = $this->Application->recallObject('PriorityHelper'); | ||||
/* @var $priority_helper kPriorityHelper */ | |||||
list ($constrain, $joins) = $this->getConstrainInfo($event); | list ($constrain, $joins) = $this->getConstrainInfo($event); | ||||
$ids = $priority_helper->updatePriorities($event->MasterEvent, $changes, Array (0 => $event->MasterEvent->getEventParam('ids')), $constrain, $joins); | $ids = $priority_helper->updatePriorities($event->MasterEvent, $changes, Array (0 => $event->MasterEvent->getEventParam('ids')), $constrain, $joins); | ||||
if ($ids) { | if ($ids) { | ||||
$priority_helper->massUpdateChanged($event->MasterEvent->Prefix, $ids); | $priority_helper->massUpdateChanged($event->MasterEvent->Prefix, $ids); | ||||
} | } | ||||
} | } | ||||
function OnItemCreate($event) | function OnItemCreate($event) | ||||
{ | { | ||||
$obj = $event->MasterEvent->getObject(); | $obj = $event->MasterEvent->getObject(); | ||||
if ($obj->GetDBField('Priority') == 0) { | if ($obj->GetDBField('Priority') == 0) { | ||||
Expected 1 spaces before "if" closing bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace: Expected 1 spaces before "if" closing bracket; 0 found | |||||
Expected 1 spaces after "if" opening bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace: Expected 1 spaces after "if" opening bracket; 0 found | |||||
No blank line found before "if" control structure Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.NoLineBeforeOpen: No blank line found before "if" control structure | |||||
/** @var kPriorityHelper $priority_helper */ | |||||
$priority_helper = $this->Application->recallObject('PriorityHelper'); | $priority_helper = $this->Application->recallObject('PriorityHelper'); | ||||
/* @var $priority_helper kPriorityHelper */ | |||||
list ($constrain, $joins) = $this->getConstrainInfo($event); | list ($constrain, $joins) = $this->getConstrainInfo($event); | ||||
$priority_helper->preparePriorities($event->MasterEvent, true, $constrain, $joins); | $priority_helper->preparePriorities($event->MasterEvent, true, $constrain, $joins); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Processes OnMassMoveUp, OnMassMoveDown events | * Processes OnMassMoveUp, OnMassMoveDown events | ||||
Show All 15 Lines | |||||
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $prefix); | $table_name = $this->Application->GetTempName($table_name, 'prefix:' . $prefix); | ||||
} | } | ||||
$sql = 'SELECT Priority, '.$id_field.' | $sql = 'SELECT Priority, '.$id_field.' | ||||
FROM '.$table_name.' | FROM '.$table_name.' | ||||
WHERE '.$id_field.' IN ('.implode(',', $ids).') ORDER BY Priority DESC'; | WHERE '.$id_field.' IN ('.implode(',', $ids).') ORDER BY Priority DESC'; | ||||
$priorities = $this->Conn->GetCol($sql, $id_field); | $priorities = $this->Conn->GetCol($sql, $id_field); | ||||
/** @var kPriorityHelper $priority_helper */ | |||||
$priority_helper = $this->Application->recallObject('PriorityHelper'); | $priority_helper = $this->Application->recallObject('PriorityHelper'); | ||||
/* @var $priority_helper kPriorityHelper */ | |||||
list ($constrain, $joins) = $this->getConstrainInfo($event); | list ($constrain, $joins) = $this->getConstrainInfo($event); | ||||
$sql = 'SELECT IFNULL(MIN(item_table.Priority), -1) | $sql = 'SELECT IFNULL(MIN(item_table.Priority), -1) | ||||
FROM '.$table_name . ' item_table | FROM '.$table_name . ' item_table | ||||
' . $joins; | ' . $joins; | ||||
if ( $constrain ) { | if ( $constrain ) { | ||||
Show All 34 Lines | |||||
/** | /** | ||||
* Completely recalculates priorities in current category | * Completely recalculates priorities in current category | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnRecalculatePriorities($event) | function OnRecalculatePriorities($event) | ||||
{ | { | ||||
/** @var kPriorityHelper $priority_helper */ | |||||
$priority_helper = $this->Application->recallObject('PriorityHelper'); | $priority_helper = $this->Application->recallObject('PriorityHelper'); | ||||
/* @var $priority_helper kPriorityHelper */ | |||||
$prefix = $this->Application->GetVar('priority_prefix'); | $prefix = $this->Application->GetVar('priority_prefix'); | ||||
$dummy_event = new kEvent($prefix . ':Dummy'); | $dummy_event = new kEvent($prefix . ':Dummy'); | ||||
list ($constrain, $joins) = $this->getConstrainInfo($event); | list ($constrain, $joins) = $this->getConstrainInfo($event); | ||||
$ids = $priority_helper->recalculatePriorities($dummy_event, $constrain, $joins); | $ids = $priority_helper->recalculatePriorities($dummy_event, $constrain, $joins); | ||||
if ($ids) { | if ($ids) { | ||||
Show All 21 Lines |
There must be no space between the Array keyword and the opening parenthesis