From 2f874214ba4c05da18dfe4d85209048965b2aacf Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Wed, 13 Nov 2013 17:25:48 -0800 Subject: [PATCH] MDL-42547 tool_uploaduser: trim values before uploading users --- admin/tool/uploaduser/index.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/admin/tool/uploaduser/index.php b/admin/tool/uploaduser/index.php index 82f7ccc8362..266db622840 100644 --- a/admin/tool/uploaduser/index.php +++ b/admin/tool/uploaduser/index.php @@ -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;