Much better cron function method - instead of using a code fragment in

mod/cron.php, it now uses a function in mod/lib.php ... more contained
This commit is contained in:
martin
2002-07-27 06:09:54 +00:00
parent 2c4483e5fb
commit 673de29291
+11 -6
View File
@@ -8,7 +8,7 @@
// The script can either be invoked via the web server or via a standalone
// version of PHP compiled for CGI.
//
// eg wget -q -O /dev/null 'http://moodle.dougiamas.net/admin/cron.php'
// eg wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
// or php /web/moodle/admin/cron.php
require("../config.php");
@@ -21,11 +21,16 @@
if ($mods = get_records_sql("SELECT * FROM modules WHERE cron > 0 AND (($timenow - lastcron) > cron)")) {
foreach ($mods as $mod) {
$cronfile = "$CFG->dirroot/mod/$mod->name/cron.php";
if (file_exists($cronfile)) {
include($cronfile);
if (! set_field("modules", "lastcron", $timenow, "id", $mod->id)) {
echo "Error: could not update timestamp for $mod->fullname\n";
$libfile = "$CFG->dirroot/mod/$mod->name/lib.php";
if (file_exists($libfile)) {
include_once($libfile);
$cron_function = $mod->name."_cron";
if (function_exists($cron_function)) {
if ($cron_function()) {
if (! set_field("modules", "lastcron", $timenow, "id", $mod->id)) {
echo "Error: could not update timestamp for $mod->fullname\n";
}
}
}
}
}