enrol_imsenterprise: MDL-46363 including course lib when create_course is
authorJim Thorpe <jim.thorpe@canterbury.ac.nz>
Wed, 16 Jul 2014 23:57:00 +0000 (11:57 +1200)
committerDan Marsden <dan@danmarsden.com>
Thu, 17 Jul 2014 23:28:12 +0000 (11:28 +1200)
used

enrol/imsenterprise/lib.php

index 6db0851..f6d2d9b 100644 (file)
@@ -270,13 +270,16 @@ class enrol_imsenterprise_plugin extends enrol_plugin {
      * @param string $tagcontents The raw contents of the XML element
      */
     protected function process_group_tag($tagcontents) {
-        global $DB;
+        global $DB, $CFG;
 
         // Get configs.
         $truncatecoursecodes    = $this->get_config('truncatecoursecodes');
         $createnewcourses       = $this->get_config('createnewcourses');
         $createnewcategories    = $this->get_config('createnewcategories');
 
+        if ($createnewcourses) {
+            require_once("$CFG->dirroot/course/lib.php");
+        }
         // Process tag contents.
         $group = new stdClass();
         if (preg_match('{<sourcedid>.*?<id>(.+?)</id>.*?</sourcedid>}is', $tagcontents, $matches)) {