function local_enrolmentreminder_cron() { global $CFG; global $DB; $lastcron = get_config('local_enrolmentreminder', 'lastcron') ?: time() - 24 * 3600; $events = local_enrolmentreminder_get_events($lastcron + 1, time()); mtrace("Found " . count($events) . " expiring enrollments"); local_enrolmentreminder_send_messages($events); }
function local_enrolmentreminder_cron() { global $CFG; global $DB; $lastcron = get_config('local_enrolmentreminder', 'lastcron') ?: time() - 24 * 3600; $events = local_enrolmentreminder_get_events($lastcron, time()); mtrace("Found " . count($events) . " expiring enrollments"); local_enrolmentreminder_send_messages($events); if (!time() > $lastcron) { sleep(1); // To ensure that the same mesage isn't sent next time. } }