MDL-17457 migrated all modules to new db/install.php; added upgrade.txt file for...
[moodle.git] / enrol / ldap / enrol_ldap_sync.php
1 <?php
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.
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_all_roles();
26     foreach ($roles as $role) {
27         $enrol->sync_enrolments($role->shortname, true);
28     }
29     
30     // sync metacourses
31     if (function_exists('sync_metacourses')) {
32         sync_metacourses();
33     }
34     
35 ?>