Commit d4a6f866 authored by Francois Marier's avatar Francois Marier

bulkimport: import existing users under a different name in case of conflicts

Also removed a unnecessary debug statement and fixed the redirection.
Signed-off-by: default avatarFrancois Marier <francois@catalyst.net.nz>
parent f6852741
......@@ -193,8 +193,6 @@ function bulkimport_validate(Pieform $form, $values) {
function bulkimport_submit(Pieform $form, $values) {
global $SESSION, $LEAP2AFILES;
log_debug($values);
require_once(get_config('docroot') . 'import/lib.php');
safe_require('import', 'leap');
......@@ -241,6 +239,11 @@ function bulkimport_submit(Pieform $form, $values) {
continue;
}
// If the username is already taken, append something to the end
while (get_record('usr', 'username', $username)) {
$username .= "_";
}
$user = (object)array(
'authinstance' => $authinstance,
'username' => $username,
......@@ -339,7 +342,7 @@ function bulkimport_submit(Pieform $form, $values) {
$SESSION->add_err_msg($message, false);
}
redirect('/admin/users/bulkimport.php');
redirect(get_config('wwwroot') . '/admin/users/bulkimport.php');
}
$form = pieform($form);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment