]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10927 implemented cron support in assignment plugins
authorskodak <skodak>
Tue, 21 Aug 2007 09:53:35 +0000 (09:53 +0000)
committerskodak <skodak>
Tue, 21 Aug 2007 09:53:35 +0000 (09:53 +0000)
mod/assignment/lib.php

index efea612c8832b4683e266111b7e024bb6e1bd401..a0d03762f8a9cb300481c042cfae1b5664546ddd 100644 (file)
@@ -1781,6 +1781,14 @@ class assignment_base {
         return false;
     }
 
+    /**
+     * Plugin cron method - do not use $this here, create new assignment instances if needed.
+     * @return void
+     */
+    function cron() {
+        //no plugin cron by default - override if needed
+    }
+
 } ////// End of the assignment_base class
 
 
@@ -1886,6 +1894,16 @@ function assignment_cron () {
 
     global $CFG, $USER;
 
+    /// first execute all crons in plugins
+    if ($plugins = get_list_of_plugins('mod/assignment/type')) {
+        foreach ($plugins as $plugin) {
+            require_once("$CFG->dirroot/mod/assignment/type/$plugin/assignment.class.php");
+            $assignmentclass = "assignment_$plugin";
+            $ass = new $assignmentclass();
+            $ass->cron();
+        }
+    }
+
     /// Notices older than 1 day will not be mailed.  This is to avoid the problem where
     /// cron has not been running for a long time, and then suddenly people are flooded
     /// with mail from the past few weeks or months