MDL-57888 core_calendar: moved functions from calendar/lib.php
Part of MDL-55611 epic.
This commit is contained in:
committed by
Damyon Wiese
parent
e46efe3a72
commit
12cbce0aa3
@@ -23,6 +23,10 @@
|
||||
*/
|
||||
namespace core\task;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/cronlib.php');
|
||||
|
||||
/**
|
||||
* Simple task to run the calendar cron.
|
||||
*/
|
||||
@@ -42,11 +46,32 @@ class calendar_cron_task extends scheduled_task {
|
||||
* Throw exceptions on errors (the job will be retried).
|
||||
*/
|
||||
public function execute() {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
// Run calendar cron.
|
||||
require_once("{$CFG->dirroot}/calendar/lib.php");
|
||||
calendar_cron();
|
||||
require_once($CFG->libdir . '/bennu/bennu.inc.php');
|
||||
|
||||
mtrace('Updating calendar subscriptions:');
|
||||
cron_trace_time_and_memory();
|
||||
|
||||
$time = time();
|
||||
$sql = "SELECT *
|
||||
FROM {event_subscriptions}
|
||||
WHERE pollinterval > 0
|
||||
AND lastupdated + pollinterval < :time";
|
||||
$subscriptions = $DB->get_records_sql($sql, array('time' => $time));
|
||||
foreach ($subscriptions as $sub) {
|
||||
mtrace("Updating calendar subscription {$sub->name} in course {$sub->courseid}");
|
||||
try {
|
||||
$log = \core_calendar\api::update_subscription_events($sub->id);
|
||||
mtrace(trim(strip_tags($log)));
|
||||
} catch (\moodle_exception $ex) {
|
||||
mtrace('Error updating calendar subscription: ' . $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
mtrace('Finished updating calendar subscriptions.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user