Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/managers/scheduled_task_manager.php
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Line(s) | |||||
ignore_user_abort(true); | ignore_user_abort(true); | ||||
set_time_limit(0); | set_time_limit(0); | ||||
$events_source = $this->getAll(); | $events_source = $this->getAll(); | ||||
$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 */ | |||||
$site_helper = $this->Application->recallObject('SiteHelper'); | $site_helper = $this->Application->recallObject('SiteHelper'); | ||||
/* @var $site_helper 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) { | ||||
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) ) { | ||||
Show All 31 Lines | |||||
{ | { | ||||
$event = new kEvent($scheduled_task_data['Event']); | $event = new kEvent($scheduled_task_data['Event']); | ||||
if ( !$this->Application->prefixRegistred($event->Prefix) ) { | if ( !$this->Application->prefixRegistred($event->Prefix) ) { | ||||
// don't process scheduled tasks, left from disabled modules | // don't process scheduled tasks, left from disabled modules | ||||
return false; | return false; | ||||
} | } | ||||
/** @var kCronHelper $cron_helper */ | |||||
$cron_helper = $this->Application->recallObject('kCronHelper'); | $cron_helper = $this->Application->recallObject('kCronHelper'); | ||||
/* @var $cron_helper kCronHelper */ | |||||
$start_time = adodb_mktime(); | $start_time = adodb_mktime(); | ||||
// remember, when scheduled task execution started | // remember, when scheduled task execution started | ||||
$fields_hash = Array ( | $fields_hash = Array ( | ||||
'LastRunOn' => $start_time, | 'LastRunOn' => $start_time, | ||||
'LastRunStatus' => ScheduledTask::LAST_RUN_RUNNING, | 'LastRunStatus' => ScheduledTask::LAST_RUN_RUNNING, | ||||
'NextRunOn' => $cron_helper->getMatch($scheduled_task_data['RunSchedule'], $start_time), | 'NextRunOn' => $cron_helper->getMatch($scheduled_task_data['RunSchedule'], $start_time), | ||||
Show All 36 Lines | |||||
{ | { | ||||
$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 | No newline at end of file |