MDL-42547 tool_uploaduser: trim values before uploading users
This commit is contained in:
@@ -231,10 +231,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)) {
|
||||
@@ -870,6 +870,7 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
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
|
||||
@@ -1001,7 +1002,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();
|
||||
|
||||
@@ -1027,7 +1028,7 @@ while ($linenum <= $previewrows and $fields = $cir->next()) {
|
||||
}
|
||||
|
||||
if (isset($rowcols['city'])) {
|
||||
$rowcols['city'] = trim($rowcols['city']);
|
||||
$rowcols['city'] = $rowcols['city'];
|
||||
if (empty($rowcols['city'])) {
|
||||
$rowcols['status'][] = get_string('fieldrequired', 'error', 'city');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user