MDL-60926 auth: do not map very long profile fields
This commit is contained in:
+14
-2
@@ -1016,16 +1016,22 @@ function display_auth_lock_options($settings, $auth, $userfields, $helptext, $ma
|
||||
}
|
||||
|
||||
foreach ($userfields as $field) {
|
||||
|
||||
// Define the fieldname we display to the user.
|
||||
// this includes special handling for some profile fields.
|
||||
$fieldname = $field;
|
||||
$fieldnametoolong = false;
|
||||
if ($fieldname === 'lang') {
|
||||
$fieldname = get_string('language');
|
||||
} else if (!empty($customfields) && in_array($field, $customfields)) {
|
||||
// If custom field then pick name from database.
|
||||
$fieldshortname = str_replace('profile_field_', '', $fieldname);
|
||||
$fieldname = $customfieldname[$fieldshortname]->name;
|
||||
if (core_text::strlen($fieldshortname) > 67) {
|
||||
// If custom profile field name is longer than 67 characters we will not be able to store the setting
|
||||
// such as 'field_updateremote_profile_field_NOTSOSHORTSHORTNAME' in the database because the character
|
||||
// limit for the setting name is 100.
|
||||
$fieldnametoolong = true;
|
||||
}
|
||||
} else if ($fieldname == 'url') {
|
||||
$fieldname = get_string('webpage');
|
||||
} else {
|
||||
@@ -1033,7 +1039,13 @@ function display_auth_lock_options($settings, $auth, $userfields, $helptext, $ma
|
||||
}
|
||||
|
||||
// Generate the list of fields / mappings.
|
||||
if ($mapremotefields) {
|
||||
if ($fieldnametoolong) {
|
||||
// Display a message that the field can not be mapped because it's too long.
|
||||
$url = new moodle_url('/user/profile/index.php');
|
||||
$a = (object)['fieldname' => s($fieldname), 'shortname' => s($field), 'charlimit' => 67, 'link' => $url->out()];
|
||||
$settings->add(new admin_setting_heading($auth.'/field_not_mapped_'.sha1($field), '',
|
||||
get_string('cannotmapfield', 'auth', $a)));
|
||||
} else if ($mapremotefields) {
|
||||
// We are mapping to a remote field here.
|
||||
// Mapping.
|
||||
$settings->add(new admin_setting_configtext("auth_{$auth}/field_map_{$field}",
|
||||
|
||||
Reference in New Issue
Block a user