From: skodak <skodak>
Date: Tue, 21 Aug 2007 09:53:35 +0000 (+0000)
Subject: MDL-10927 implemented cron support in assignment plugins
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=d014b69b92df366b3d69d342561b458c073d396e;p=moodle.git

MDL-10927 implemented cron support in assignment plugins
---

diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php
index efea612c88..a0d03762f8 100644
--- a/mod/assignment/lib.php
+++ b/mod/assignment/lib.php
@@ -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