MDL-64570 accessibility: autocomplete user profile fields
Only if editing your own user details and not logged in as someone else.
This commit is contained in:
+15
-6
@@ -22,6 +22,8 @@
|
||||
* @package core_user
|
||||
*/
|
||||
|
||||
require_once($CFG->dirroot . '/user/lib.php');
|
||||
|
||||
/**
|
||||
* Cancels the requirement for a user to update their email address.
|
||||
*
|
||||
@@ -267,7 +269,8 @@ function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions
|
||||
|
||||
// Add the necessary names.
|
||||
foreach (useredit_get_required_name_fields() as $fullname) {
|
||||
$mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"');
|
||||
$purpose = user_edit_map_field_purpose($user->id, $fullname);
|
||||
$mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"' . $purpose);
|
||||
if ($stringman->string_exists('missing'.$fullname, 'core')) {
|
||||
$strmissingfield = get_string('missing'.$fullname, 'core');
|
||||
} else {
|
||||
@@ -280,7 +283,8 @@ function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions
|
||||
$enabledusernamefields = useredit_get_enabled_name_fields();
|
||||
// Add the enabled additional name fields.
|
||||
foreach ($enabledusernamefields as $addname) {
|
||||
$mform->addElement('text', $addname, get_string($addname), 'maxlength="100" size="30"');
|
||||
$purpose = user_edit_map_field_purpose($user->id, $addname);
|
||||
$mform->addElement('text', $addname, get_string($addname), 'maxlength="100" size="30"' . $purpose);
|
||||
$mform->setType($addname, PARAM_NOTAGS);
|
||||
}
|
||||
|
||||
@@ -291,7 +295,8 @@ function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions
|
||||
. get_string('emailchangecancel', 'auth') . '</a>';
|
||||
$mform->addElement('static', 'emailpending', get_string('email'), $notice);
|
||||
} else {
|
||||
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
|
||||
$purpose = user_edit_map_field_purpose($user->id, 'email');
|
||||
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"' . $purpose);
|
||||
$mform->addRule('email', $strrequired, 'required', null, 'client');
|
||||
$mform->setType('email', PARAM_RAW_TRIMMED);
|
||||
}
|
||||
@@ -310,9 +315,10 @@ function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions
|
||||
$mform->setDefault('city', $CFG->defaultcity);
|
||||
}
|
||||
|
||||
$purpose = user_edit_map_field_purpose($user->id, 'country');
|
||||
$choices = get_string_manager()->get_list_of_countries();
|
||||
$choices = array('' => get_string('selectacountry') . '...') + $choices;
|
||||
$mform->addElement('select', 'country', get_string('selectacountry'), $choices);
|
||||
$mform->addElement('select', 'country', get_string('selectacountry'), $choices, $purpose);
|
||||
if (!empty($CFG->country)) {
|
||||
$mform->setDefault('country', core_user::get_property_default('country'));
|
||||
}
|
||||
@@ -328,7 +334,9 @@ function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions
|
||||
}
|
||||
|
||||
if ($user->id < 0) {
|
||||
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
|
||||
$purpose = user_edit_map_field_purpose($user->id, 'lang');
|
||||
$translations = get_string_manager()->get_list_of_translations();
|
||||
$mform->addElement('select', 'lang', get_string('preferredlanguage'), $translations, $purpose);
|
||||
$lang = empty($user->lang) ? $CFG->lang : $user->lang;
|
||||
$mform->setDefault('lang', $lang);
|
||||
}
|
||||
@@ -375,7 +383,8 @@ function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions
|
||||
if (count($disabledusernamefields) > 0) {
|
||||
$mform->addElement('header', 'moodle_additional_names', get_string('additionalnames'));
|
||||
foreach ($disabledusernamefields as $allname) {
|
||||
$mform->addElement('text', $allname, get_string($allname), 'maxlength="100" size="30"');
|
||||
$purpose = user_edit_map_field_purpose($user->id, $allname);
|
||||
$mform->addElement('text', $allname, get_string($allname), 'maxlength="100" size="30"' . $purpose);
|
||||
$mform->setType($allname, PARAM_NOTAGS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user