File: auth_db_sync_users.php

package info (click to toggle)
moodle 1.6.3-2%2Betch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 37,172 kB
  • ctags: 51,688
  • sloc: php: 231,916; sql: 5,631; xml: 2,688; sh: 1,185; perl: 638; makefile: 48; pascal: 36
file content (39 lines) | stat: -rw-r--r-- 1,264 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/** auth_db_sync_users.php
 * 
 * This script is meant to be called from a cronjob to sync moodle with the LDAP 
 * backend in those setups where the LDAP backend acts as 'master'.
 * 
 * Recommended cron entry:
 * # 5 minutes past 4am
 * 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/db/auth_db_sync_users.php
 * 
 * Notes: 
 *   - If you have a large number of users, you may want to raise the memory limits
 *     by passing -d memory_limit=256M
 *   - For debugging & better logging, you are encouraged to use in the command line:
 *     -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
 *     
 * Performance notes:
 * + The code is simpler, but not as optimized as its LDAP counterpart. 
 * 
 *    
 */


if(!empty($_SERVER['GATEWAY_INTERFACE'])){
    error_log("should not be called from apache!");
    exit;
}

require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.

require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot.'/lib/blocklib.php');
require_once($CFG->dirroot.'/mod/resource/lib.php');
require_once($CFG->dirroot.'/auth/db/lib.php');
require_once($CFG->dirroot.'/mod/forum/lib.php');
$CFG->debug=10;
auth_sync_users(true  );

?>