MDL-27931 admin bulk user upload: convert city as required field. Credit goes to Charles Fulton for supplying the patch.
This commit is contained in:
@@ -915,6 +915,14 @@ while ($linenum <= $previewrows and $fields = $cir->next()) {
|
||||
$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']);
|
||||
$data[] = $rowcols;
|
||||
}
|
||||
|
||||
@@ -264,6 +264,7 @@ class admin_uploaduser_form2 extends moodleform {
|
||||
} else {
|
||||
$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());
|
||||
if (empty($CFG->country)) {
|
||||
@@ -408,10 +409,6 @@ class admin_uploaduser_form2 extends moodleform {
|
||||
if (!in_array('email', $columns) and empty($data['email'])) {
|
||||
$errors['email'] = get_string('requiredtemplate', 'admin');
|
||||
}
|
||||
|
||||
if (!in_array('city', $columns) and empty($data['city'])) {
|
||||
$errors['city'] = get_string('required');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
|
||||
Reference in New Issue
Block a user