MDL-9137 Fixing errors in the overview report
[moodle-pu.git] / auth / db / auth_db_sync_users.php
blobb4e22aa4b829e969db306f05d19922bedfbd8177
1 <?php
2 /** auth_db_sync_users.php
4 * This script is meant to be called from a system cronjob to
5 * sync moodle user accounts with external database.
6 * It is required when using internal passwords (== passwords not defined in external database).
8 * Recommended cron entry:
9 * # 5 minutes past 4am
10 * 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/db/auth_db_sync_users.php
12 * Notes:
13 * - If you have a large number of users, you may want to raise the memory limits
14 * by passing -d memory_limit=256M
15 * - For debugging & better logging, you are encouraged to use in the command line:
16 * -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
18 * Performance notes:
19 * + The code is simpler, but not as optimized as its LDAP counterpart.
25 if (isset($_SERVER['REMOTE_ADDR'])) {
26 error_log("should not be called from web server!");
27 exit;
30 $nomoodlecookie = true; // cookie not needed
32 require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
34 require_once($CFG->libdir.'/blocklib.php');
35 require_once($CFG->dirroot.'/course/lib.php');
36 require_once($CFG->dirroot.'/mod/resource/lib.php');
37 require_once($CFG->dirroot.'/mod/forum/lib.php');
39 if (!is_enabled_auth('db')) {
40 echo "Plugin not enabled!";
41 die;
44 $dbauth = get_auth_plugin('db');
45 $dbauth->sync_users(true);