diff --git a/admin/tool/uploaduser/index.php b/admin/tool/uploaduser/index.php index a9f7afa3d82..a75e0c4c0ea 100644 --- a/admin/tool/uploaduser/index.php +++ b/admin/tool/uploaduser/index.php @@ -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(); diff --git a/admin/tool/uploaduser/user_form.php b/admin/tool/uploaduser/user_form.php index 9dfc28846e8..dda9abdbc81 100644 --- a/admin/tool/uploaduser/user_form.php +++ b/admin/tool/uploaduser/user_form.php @@ -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; }