From 7d0c60eecfa5ad9965a53329e569e1524fc5a50a Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Mon, 4 Jul 2022 14:59:40 +0800 Subject: [PATCH] MDL-69400 mod_forum: Added calender event refreshing. --- mod/forum/lib.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 3ad968c3881..16c7f40a3f6 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -7021,3 +7021,20 @@ function mod_forum_core_calendar_get_event_action_string(string $eventtype): str return get_string('requiresaction', 'calendar', $modulename); } } + +/** + * This callback will check the provided instance of this module + * and make sure there are up-to-date events created for it. + * + * @param int $courseid Not used. + * @param stdClass $instance Forum module instance. + * @param stdClass $cm Course module object. + */ +function forum_refresh_events(int $courseid, stdClass $instance, stdClass $cm): void { + global $CFG; + + // This function is called by cron and we need to include the locallib for calls further down. + require_once($CFG->dirroot . '/mod/forum/locallib.php'); + + forum_update_calendar($instance, $cm->id); +}