MDL-42547 tool_uploaduser: trim values before uploading users

This commit is contained in:
Mark Nelson 2013-11-13 17:25:48 -08:00
parent d214057cad
commit 7ca44a4963

View file

@ -235,10 +235,10 @@ if ($formdata = $mform2->is_cancelled()) {
$user->$key['text'] = $value;
$user->$key['format'] = FORMAT_MOODLE;
} else {
$user->$key = $value;
$user->$key = trim($value);
}
} else {
$user->$key = $value;
$user->$key = trim($value);
}
if (in_array($key, $upt->columns)) {
@ -966,7 +966,7 @@ if ($formdata = $mform2->is_cancelled()) {
$status = null;
if (isset($user->{'enrolstatus'.$i})) {
$enrolstatus = trim($user->{'enrolstatus'.$i});
$enrolstatus = $user->{'enrolstatus'.$i};
if ($enrolstatus == '') {
$status = null;
} else if ($enrolstatus === (string)ENROL_USER_ACTIVE) {
@ -1109,7 +1109,7 @@ while ($linenum <= $previewrows and $fields = $cir->next()) {
$rowcols = array();
$rowcols['line'] = $linenum;
foreach($fields as $key => $field) {
$rowcols[$filecolumns[$key]] = s($field);
$rowcols[$filecolumns[$key]] = s(trim($field));
}
$rowcols['status'] = array();
@ -1135,7 +1135,7 @@ while ($linenum <= $previewrows and $fields = $cir->next()) {
}
if (isset($rowcols['city'])) {
$rowcols['city'] = trim($rowcols['city']);
$rowcols['city'] = $rowcols['city'];
}
// Check if rowcols have custom profile field with correct data and update error state.
$noerror = uu_check_custom_profile_data($rowcols) && $noerror;