diff --git a/lang/en/admin.php b/lang/en/admin.php index c8038b29ac3..f480d4dadce 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -975,7 +975,8 @@ $string['profilerequired'] = 'Is this field required?'; $string['profileroles'] = 'Profile visible roles'; $string['profilesforenrolledusersonly'] = 'Profiles for enrolled users only'; $string['profileshortname'] = 'Short name (must be unique)'; -$string['profileshortnameinvalid'] = 'This short name can only contain alphanumeric characters (letters and numbers) or underscore (_).'; +$string['profileshortnameinvalid'] = 'This short name can only contain alphanumeric characters (lowercase letters and numbers) or underscore (_).'; +$string['profileshortname_help'] = 'This short name can only contain alphanumeric characters (lowercase letters and numbers) or underscore (_).'; $string['profileshortnamenotunique'] = 'This short name is already in use'; $string['profilesignup'] = 'Display on signup page?'; $string['profilespecificsettings'] = 'Specific settings'; diff --git a/user/profile/definelib.php b/user/profile/definelib.php index 37ae8f5f2be..d6d394e87bf 100644 --- a/user/profile/definelib.php +++ b/user/profile/definelib.php @@ -55,6 +55,8 @@ class profile_define_base { // but we are accepting any PARAM_TEXT value here, // and checking [a-zA-Z0-9_] pattern in define_validate_common() function to throw an error when needed. $form->addElement('text', 'shortname', get_string('profileshortname', 'admin'), 'maxlength="100" size="25"'); + $form->addHelpButton('shortname', 'profileshortname', 'admin'); + $form->addRule('shortname', $strrequired, 'required', null, 'client'); $form->setType('shortname', PARAM_TEXT); @@ -131,8 +133,9 @@ class profile_define_base { $err['shortname'] = get_string('required'); } else { + // '/^[a-z0-9_]+$/' this is the porposed change for this bug. // Check allowed pattern (numbers, letters and underscore). - if (!preg_match('/^[a-zA-Z0-9_]+$/', $data->shortname)) { + if (!preg_match('/^[a-z0-9_]+$/', $data->shortname)) { $err['shortname'] = get_string('profileshortnameinvalid', 'admin'); } else { // Fetch field-record from DB. diff --git a/user/profile/lib.php b/user/profile/lib.php index c82551f99c1..8b4ac6823de 100644 --- a/user/profile/lib.php +++ b/user/profile/lib.php @@ -770,7 +770,8 @@ function profile_user_record($userid, $onlyinuserobject = true) { $fields = profile_get_user_fields_with_data($userid); foreach ($fields as $formfield) { if (!$onlyinuserobject || $formfield->is_user_object_data()) { - $usercustomfields->{$formfield->field->shortname} = $formfield->data; + $usercustomfields->{$formfield->field->shortname} = //$formfield->data; + core_text::strtolower($formfield->data); } }