MDL-37299 use progress_trace in enrol_manual and enrol_self sync

This commit is contained in:
Petr Škoda
2012-12-29 21:50:32 +01:00
parent 0dc5a532ec
commit 5d549ffc8c
7 changed files with 114 additions and 109 deletions
+14 -7
View File
@@ -30,8 +30,8 @@
define('CLI_SCRIPT', true);
require(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
require_once($CFG->libdir.'/clilib.php');
require(__DIR__.'/../../../config.php');
require_once("$CFG->libdir/clilib.php");
// Now get cli options.
list($options, $unrecognized) = cli_get_params(array('verbose'=>false, 'help'=>false), array('v'=>'verbose', 'h'=>'help'));
@@ -50,20 +50,27 @@ Options:
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php enrol/self/cli/sync.php
\$ sudo -u www-data /usr/bin/php enrol/self/cli/sync.php
";
echo $help;
die;
}
$verbose = !empty($options['verbose']);
if (!enrol_is_enabled('self')) {
cli_error('enrol_self plugin is disabled, synchronisation stopped', 2);
}
if (empty($options['verbose'])) {
$trace = new null_progress_trace();
} else {
$trace = new text_progress_trace();
}
/** @var $plugin enrol_self_plugin */
$plugin = enrol_get_plugin('self');
$result = $plugin->sync(null, $verbose);
$plugin->send_expiry_notifications($verbose);
$result = $plugin->sync($trace, null);
$plugin->send_expiry_notifications($trace);
exit($result);