Merge branch 'MDL-55062_master' of git://github.com/markn86/moodle

This commit is contained in:
Andrew Nicols 2016-12-14 09:26:10 +08:00
commit 428e18ed2b
3 changed files with 38 additions and 28 deletions

View file

@ -358,6 +358,7 @@ if ($formdata = $mform2->is_cancelled()) {
// add default values for remaining fields // add default values for remaining fields
$formdefaults = array(); $formdefaults = array();
if ($updatetype != UU_UPDATE_FILEOVERRIDE && $updatetype != UU_UPDATE_NOCHANGES) {
foreach ($STD_FIELDS as $field) { foreach ($STD_FIELDS as $field) {
if (isset($user->$field)) { if (isset($user->$field)) {
continue; continue;
@ -392,6 +393,7 @@ if ($formdata = $mform2->is_cancelled()) {
$formdefaults[$field] = true; $formdefaults[$field] = true;
} }
} }
}
// delete user // delete user
if (!empty($user->deleted)) { if (!empty($user->deleted)) {

View file

@ -33,6 +33,7 @@ $string['deleteerrors'] = 'Delete errors';
$string['encoding'] = 'Encoding'; $string['encoding'] = 'Encoding';
$string['errormnetadd'] = 'Can not add remote users'; $string['errormnetadd'] = 'Can not add remote users';
$string['errors'] = 'Errors'; $string['errors'] = 'Errors';
$string['invalidupdatetype'] = 'You can not select this option with the chosen \'Upload type\'';
$string['invaliduserdata'] = 'Invalid data detected for user {$a} and it has been automatically cleaned.'; $string['invaliduserdata'] = 'Invalid data detected for user {$a} and it has been automatically cleaned.';
$string['nochanges'] = 'No changes'; $string['nochanges'] = 'No changes';
$string['pluginname'] = 'User upload'; $string['pluginname'] = 'User upload';

View file

@ -350,6 +350,7 @@ class admin_uploaduser_form2 extends moodleform {
$errors = parent::validation($data, $files); $errors = parent::validation($data, $files);
$columns = $this->_customdata['columns']; $columns = $this->_customdata['columns'];
$optype = $data['uutype']; $optype = $data['uutype'];
$updatetype = $data['uuupdatetype'];
// detect if password column needed in file // detect if password column needed in file
if (!in_array('password', $columns)) { if (!in_array('password', $columns)) {
@ -382,6 +383,12 @@ class admin_uploaduser_form2 extends moodleform {
} }
} }
// If the 'Existing user details' value is set we need to ensure that the
// 'Upload type' is not set to something invalid.
if (!empty($updatetype) && ($optype == UU_USER_ADDNEW || $optype == UU_USER_ADDINC)) {
$errors['uuupdatetype'] = get_string('invalidupdatetype', 'tool_uploaduser');
}
// look for other required data // look for other required data
if ($optype != UU_USER_UPDATE) { if ($optype != UU_USER_UPDATE) {
$requiredusernames = useredit_get_required_name_fields(); $requiredusernames = useredit_get_required_name_fields();