Changeset View
Changeset View
Standalone View
Standalone View
core/kernel/managers/scheduled_task_manager.php
Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | |||||
$user_id = $this->Application->RecallVar('user_id'); | $user_id = $this->Application->RecallVar('user_id'); | ||||
$this->Application->StoreVar('user_id', USER_ROOT, true); // to prevent permission checking inside events, true for optional storage | $this->Application->StoreVar('user_id', USER_ROOT, true); // to prevent permission checking inside events, true for optional storage | ||||
/** @var SiteHelper $site_helper */ | /** @var SiteHelper $site_helper */ | ||||
$site_helper = $this->Application->recallObject('SiteHelper'); | $site_helper = $this->Application->recallObject('SiteHelper'); | ||||
$site_domain_id = $site_helper->getDomainByName('DomainName', DOMAIN); | $site_domain_id = $site_helper->getDomainByName('DomainName', DOMAIN); | ||||
foreach ($events_source as $short_name => $event_data) { | foreach ($events_source as $short_name => $event_data) { | ||||
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 | |||||
// Scheduled task was updated from another process. | |||||
if ( $this->getLiveData($short_name) != $event_data ) { | |||||
continue; | |||||
} | |||||
if ( $site_domain_id && $event_data['SiteDomainLimitation'] != '' ) { | if ( $site_domain_id && $event_data['SiteDomainLimitation'] != '' ) { | ||||
$site_domains = explode('|', substr($event_data['SiteDomainLimitation'], 1, -1)); | $site_domains = explode('|', substr($event_data['SiteDomainLimitation'], 1, -1)); | ||||
if ( !in_array($site_domain_id, $site_domains) ) { | if ( !in_array($site_domain_id, $site_domains) ) { | ||||
// scheduled task isn't allowed on this site domain | // scheduled task isn't allowed on this site domain | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
Show All 12 Lines | |||||
$event_data['Name'] = $short_name; | $event_data['Name'] = $short_name; | ||||
$this->run($event_data); | $this->run($event_data); | ||||
} | } | ||||
$this->Application->StoreVar('user_id', $user_id, $user_id == USER_GUEST); | $this->Application->StoreVar('user_id', $user_id, $user_id == USER_GUEST); | ||||
} | } | ||||
/** | /** | ||||
* Returns LIVE scheduled task data. | |||||
* | |||||
* @param string $short_name Short scheduled task name. | |||||
* | |||||
* @return array | |||||
*/ | |||||
protected function getLiveData($short_name) | |||||
Type hint "string" missing for $short_name Lint: CodingStandard.Commenting.FunctionComment.ScalarTypeHintMissing: Type hint "string" missing for $short_name | |||||
{ | |||||
$sql = 'SELECT * | |||||
FROM ' . $this->Application->getUnitOption('scheduled-task', 'TableName') . ' | |||||
WHERE Status = ' . STATUS_ACTIVE . ' AND Name = ' . $this->Conn->qstr($short_name); | |||||
return $this->Conn->GetRow($sql); | |||||
} | |||||
/** | |||||
* Runs scheduled task based on given data | * Runs scheduled task based on given data | ||||
* | * | ||||
* @param Array $scheduled_task_data | * @param Array $scheduled_task_data | ||||
* @return bool | * @return bool | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function run($scheduled_task_data) | public function run($scheduled_task_data) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
protected function update($scheduled_task_name, $fields_hash) | protected function update($scheduled_task_name, $fields_hash) | ||||
{ | { | ||||
$this->Conn->doUpdate( | $this->Conn->doUpdate( | ||||
$fields_hash, | $fields_hash, | ||||
$this->Application->getUnitOption('scheduled-task', 'TableName'), | $this->Application->getUnitOption('scheduled-task', 'TableName'), | ||||
'Name = ' . $this->Conn->qstr($scheduled_task_name) | 'Name = ' . $this->Conn->qstr($scheduled_task_name) | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
No newline at end of file |
Expected 1 spaces before "foreach" closing bracket; 0 found