MDL-17457 migrated all modules to new db/install.php; added upgrade.txt file for...
[moodle.git] / enrol / ldap / enrol_ldap_sync.php
CommitLineData
64031bbb 1<?php
2
3 if(!empty($_SERVER['GATEWAY_INTERFACE'])){
4 error_log("should not be called from apache!");
5 exit;
6 }
7 error_reporting(E_ALL);
8
9 require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
10
11 require_once($CFG->dirroot . '/course/lib.php');
12 require_once($CFG->dirroot . '/lib/moodlelib.php');
13 require_once($CFG->dirroot . '/lib/datalib.php');
f9667a5a 14 require_once($CFG->dirroot . "/enrol/ldap/enrol.php");
64031bbb 15
16 // ensure errors are well explained
7eb0b60a 17 $CFG->debug = DEBUG_NORMAL;
0e1cc907 18
64031bbb 19 // update enrolments -- these handlers should autocreate courses if required
f9667a5a 20 $enrol = new enrolment_plugin_ldap();
87c75906 21 $enrol->enrol_ldap_connect();
22
23 $enrol->check_legacy_config();
24
9101efd3 25 $roles = get_all_roles();
87c75906 26 foreach ($roles as $role) {
27 $enrol->sync_enrolments($role->shortname, true);
28 }
64031bbb 29
30 // sync metacourses
31 if (function_exists('sync_metacourses')) {
32 sync_metacourses();
33 }
34
35?>