enrol/ldap: MDL-13952 Don't auto create courses if auto creation not enabled.
authorInaki <iarenuno@eteo.mondragon.edu>
Wed, 4 Nov 2009 21:00:58 +0000 (21:00 +0000)
committerInaki <iarenuno@eteo.mondragon.edu>
Wed, 4 Nov 2009 21:00:58 +0000 (21:00 +0000)
Merged from MOODLE_18_STABLE

enrol/ldap/enrol.php

index 1b3fde0..9b9c56d 100755 (executable)
@@ -210,6 +210,11 @@ function sync_enrolments($type, $enrol = false) {
                 $course_obj = false;
                 $course_obj = $DB->get_record('course', array($this->enrol_localcoursefield=>$idnumber));
                 if (!is_object($course_obj)) {
+                    if (empty($CFG->enrol_ldap_autocreate)) { // autocreation not allowed
+                        print "[ENROL_LDAP] Course $idnumber does not exist, skipping\n";
+                        continue; // next foreach course
+                    }
+
                     // ok, now then let's create it!
                     print "Creating Course $idnumber...";
                     $newcourseid = $this->create_course($course, true); // we are skipping fix_course_sortorder()