mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-40683 libraries: Include alternate name fields in CSV user import.
This commit is contained in:
parent
68291f2d57
commit
6f4ece9f57
@ -97,6 +97,8 @@ $STD_FIELDS = array('id', 'firstname', 'lastname', 'username', 'email',
|
||||
'deleted', // 1 means delete user
|
||||
'mnethostid', // Can not be used for adding, updating or deleting of users - only for enrolments, groups, cohorts and suspending.
|
||||
);
|
||||
// Include alternate name fields such as firstnamephonetic.
|
||||
$STD_FIELDS = array_merge($STD_FIELDS, get_all_user_name_fields());
|
||||
|
||||
$PRF_FIELDS = array();
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
require_once($CFG->dirroot . '/user/editlib.php');
|
||||
|
||||
/**
|
||||
* Upload a file CVS file with user information.
|
||||
@ -375,24 +375,17 @@ class admin_uploaduser_form2 extends moodleform {
|
||||
|
||||
// look for other required data
|
||||
if ($optype != UU_USER_UPDATE) {
|
||||
if (!in_array('firstname', $columns)) {
|
||||
$errors['uutype'] = get_string('missingfield', 'error', 'firstname');
|
||||
}
|
||||
|
||||
if (!in_array('lastname', $columns)) {
|
||||
if (isset($errors['uutype'])) {
|
||||
$errors['uutype'] = '';
|
||||
} else {
|
||||
$errors['uutype'] = ' ';
|
||||
$requiredusernames = useredit_get_required_name_fields();
|
||||
$errors['uutype'] = '';
|
||||
foreach ($requiredusernames as $requiredusername) {
|
||||
if (!in_array($requiredusername, $columns)) {
|
||||
$errors['uutype'] .= ' ' . get_string('missingfield', 'error', $requiredusername);
|
||||
}
|
||||
$errors['uutype'] .= get_string('missingfield', 'error', 'lastname');
|
||||
}
|
||||
|
||||
if (!in_array('email', $columns) and empty($data['email'])) {
|
||||
$errors['email'] = get_string('requiredtemplate', 'tool_uploaduser');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user