]> git.mjollnir.org Git - moodle.git/commitdiff
Much better cron function method - instead of using a code fragment in
authormartin <martin>
Sat, 27 Jul 2002 06:09:54 +0000 (06:09 +0000)
committermartin <martin>
Sat, 27 Jul 2002 06:09:54 +0000 (06:09 +0000)
mod/cron.php, it now uses a function in mod/lib.php ... more contained

admin/cron.php

index efaf71d15ae351ea3283a1a7b441e18f14759548..642c04b941bc1b732da13f9249f4c9cd6283edf6 100644 (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");
 
     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";
+                        }
+                    }
                 }
             }
         }