libdir.'/adminlib.php';
$adminroot = admin_get_root();
admin_externalpage_setup('userauthentication', $adminroot);
$auth = optional_param('auth', '', PARAM_SAFEDIR);
$authplugin = get_auth_plugin($auth);
$err = array();
// save configuration changes
if ($frm = data_submitted()) {
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
if (method_exists($authplugin, 'validate_form')) {
$authplugin->validate_form($frm, $err);
}
if (count($err) == 0) {
// save plugin config
if ($authplugin->process_config($frm)) {
// save field lock configuration
foreach ($frm as $name => $value) {
if (preg_match('/^lockconfig_(.+?)$/', $name, $matches)) {
$plugin = "auth/$auth";
$name = $matches[1];
if (!set_config($name, $value, $plugin)) {
notify("Problem saving config $name as $value for plugin $plugin");
}
}
}
redirect("auth.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
exit;
}
} else {
foreach ($err as $key => $value) {
$focus = "form.$key";
}
}
} else {
$frm = get_config("auth/$auth");
}
$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", "idnumber", "lang");
$modules = get_list_of_plugins('auth');
foreach ($modules as $module) {
$options[$module] = get_string("auth_{$module}title", 'auth');
}
asort($options);
// output configuration form
admin_externalpage_print_header($adminroot);
// choose an authentication method
echo "
\n";
admin_externalpage_print_footer($adminroot);
exit;
/// Functions /////////////////////////////////////////////////////////////////
// Good enough for most auth plugins
// but some may want a custom one if they are offering
// other options
// Note: lockconfig_ fields have special handling.
function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts, $updateopts) {
echo '