in lib.php [341:441]
function auth_oidc_display_auth_lock_options($settings, $auth, $userfields, $helptext, $mapremotefields, $updateremotefields,
$customfields = array()) {
global $DB;
// Introductory explanation and help text.
if ($mapremotefields) {
$settings->add(new admin_setting_heading($auth.'/data_mapping', new lang_string('auth_data_mapping', 'auth'), $helptext));
} else {
$settings->add(new admin_setting_heading($auth.'/auth_fieldlocks', new lang_string('auth_fieldlocks', 'auth'), $helptext));
}
// Generate the list of options.
$lockoptions = [
'unlocked' => get_string('unlocked', 'auth'),
'unlockedifempty' => get_string('unlockedifempty', 'auth'),
'locked' => get_string('locked', 'auth'),
];
if (auth_oidc_is_local_365_installed()) {
$alwaystext = get_string('update_oncreate_and_onlogin_and_usersync', 'auth_oidc');
$onlogintext = get_string('update_onlogin_and_usersync', 'auth_oidc');
} else {
$alwaystext = get_string('update_oncreate_and_onlogin', 'auth_oidc');
$onlogintext = get_string('update_onlogin', 'auth');
}
$updatelocaloptions = [
'always' => $alwaystext,
'oncreate' => get_string('update_oncreate', 'auth'),
'onlogin' => $onlogintext,
];
$updateextoptions = [
'0' => get_string('update_never', 'auth'),
'1' => get_string('update_onupdate', 'auth'),
];
// Generate the list of profile fields to allow updates / lock.
if (!empty($customfields)) {
$userfields = array_merge($userfields, $customfields);
$customfieldname = $DB->get_records('user_info_field', null, '', 'shortname, name');
}
$remotefields = auth_oidc_get_remote_fields();
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 {
$fieldname = get_string($fieldname);
}
// Generate the list of fields / mappings.
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_configselect("auth_oidc/field_map_{$field}",
get_string('auth_fieldmapping', 'auth', $fieldname), '', null, $remotefields));
// Update local.
$settings->add(new admin_setting_configselect("auth_{$auth}/field_updatelocal_{$field}",
get_string('auth_updatelocalfield', 'auth', $fieldname), '', 'always', $updatelocaloptions));
// Update remote.
if ($updateremotefields) {
$settings->add(new admin_setting_configselect("auth_{$auth}/field_updateremote_{$field}",
get_string('auth_updateremotefield', 'auth', $fieldname), '', 0, $updateextoptions));
}
// Lock fields.
$settings->add(new admin_setting_configselect("auth_{$auth}/field_lock_{$field}",
get_string('auth_fieldlockfield', 'auth', $fieldname), '', 'unlocked', $lockoptions));
} else {
// Lock fields Only.
$settings->add(new admin_setting_configselect("auth_{$auth}/field_lock_{$field}",
get_string('auth_fieldlockfield', 'auth', $fieldname), '', 'unlocked', $lockoptions));
}
}
}