Skip to content

Commit

Permalink
MDL-42547 tool_uploaduser: trim values before uploading users
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjnelson committed Nov 20, 2013
1 parent b3f2d75 commit 68cc921
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions admin/tool/uploaduser/index.php
Expand Up @@ -232,10 +232,10 @@
$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)) {
Expand Down Expand Up @@ -966,6 +966,7 @@
if ($rid) {
// find duration
$timeend = 0;

if (!empty($user->{'enrolperiod'.$i})) {
$duration = (int)$user->{'enrolperiod'.$i} * 60*60*24; // convert days to seconds
if ($duration > 0) { // sanity check
Expand Down Expand Up @@ -1097,7 +1098,7 @@
$rowcols = array();
$rowcols['line'] = $linenum;
foreach($fields as $key => $field) {
$rowcols[$filecolumns[$key]] = s($field);
$rowcols[$filecolumns[$key]] = s(trim($field));
}
$rowcols['status'] = array();

Expand All @@ -1123,7 +1124,7 @@
}

if (isset($rowcols['city'])) {
$rowcols['city'] = trim($rowcols['city']);
$rowcols['city'] = $rowcols['city'];
if (empty($rowcols['city'])) {
$rowcols['status'][] = get_string('fieldrequired', 'error', 'city');
}
Expand Down

0 comments on commit 68cc921

Please sign in to comment.