Skip to content

Commit

Permalink
MDL-27931 admin bulk user upload: convert city as required field. Cre…
Browse files Browse the repository at this point in the history
…dit goes to Charles Fulton for supplying the patch.
  • Loading branch information
Rossiani Wijaya authored and stronk7 committed Jul 11, 2011
1 parent 661dd2c commit 3372846
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 8 additions & 0 deletions admin/uploaduser.php
Expand Up @@ -915,6 +915,14 @@
$rowcols['status'][] = $stremailduplicate; $rowcols['status'][] = $stremailduplicate;
} }
} }

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

$rowcols['status'] = implode('<br />', $rowcols['status']); $rowcols['status'] = implode('<br />', $rowcols['status']);
$data[] = $rowcols; $data[] = $rowcols;
} }
Expand Down
5 changes: 1 addition & 4 deletions admin/uploaduser_form.php
Expand Up @@ -264,6 +264,7 @@ function definition () {
} else { } else {
$mform->setDefault('city', $CFG->defaultcity); $mform->setDefault('city', $CFG->defaultcity);
} }
$mform->addRule('city', get_string('required'), 'required');


$mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries()); $mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
if (empty($CFG->country)) { if (empty($CFG->country)) {
Expand Down Expand Up @@ -408,10 +409,6 @@ function validation($data, $files) {
if (!in_array('email', $columns) and empty($data['email'])) { if (!in_array('email', $columns) and empty($data['email'])) {
$errors['email'] = get_string('requiredtemplate', 'admin'); $errors['email'] = get_string('requiredtemplate', 'admin');
} }

if (!in_array('city', $columns) and empty($data['city'])) {
$errors['city'] = get_string('required');
}
} }


return $errors; return $errors;
Expand Down

0 comments on commit 3372846

Please sign in to comment.