3 if(!empty($_SERVER['GATEWAY_INTERFACE'])){
4 error_log("should not be called from apache!");
7 error_reporting(E_ALL
);
9 require_once(dirname(dirname(dirname(__FILE__
))).'/config.php'); // global moodle config file.
11 require_once($CFG->dirroot
. '/course/lib.php');
12 require_once($CFG->dirroot
. '/lib/moodlelib.php');
13 require_once($CFG->dirroot
. '/lib/datalib.php');
14 require_once($CFG->dirroot
. "/enrol/ldap/enrol.php");
16 // ensure errors are well explained
17 $CFG->debug
= DEBUG_NORMAL
;
19 // update enrolments -- these handlers should autocreate courses if required
20 $enrol = new enrolment_plugin_ldap();
21 $enrol->enrol_ldap_connect();
23 $enrol->check_legacy_config();
25 $roles = get_records('role');
26 foreach ($roles as $role) {
27 $enrol->sync_enrolments($role->shortname
, true);
31 if (function_exists('sync_metacourses')) {