mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-58793-master-authcfgskip' of git://github.com/mudrd8mz/moodle
This commit is contained in:
commit
1595500ffe
@ -62,6 +62,7 @@ function xmldb_auth_cas_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/cas to auth_cas.
|
||||
upgrade_fix_config_auth_plugin_names('cas');
|
||||
upgrade_fix_config_auth_plugin_defaults('cas');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'cas');
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ if ($ADMIN->fulltree) {
|
||||
}
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('cas');
|
||||
$help = get_string('auth_ldapextrafields', 'auth_ldap');
|
||||
$help .= get_string('auth_updatelocal_expl', 'auth');
|
||||
$help .= get_string('auth_fieldlock_expl', 'auth');
|
||||
|
@ -38,6 +38,7 @@ function xmldb_auth_db_upgrade($oldversion) {
|
||||
if ($oldversion < 2017032800) {
|
||||
// Convert info in config plugins from auth/db to auth_db
|
||||
upgrade_fix_config_auth_plugin_names('db');
|
||||
upgrade_fix_config_auth_plugin_defaults('db');
|
||||
upgrade_plugin_savepoint(true, 2017032800, 'auth', 'db');
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ if ($ADMIN->fulltree) {
|
||||
new lang_string('auth_dbupdateusers_description', 'auth_db'), 0, $yesno));
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('db');
|
||||
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
|
||||
get_string('auth_dbextrafields', 'auth_db'),
|
||||
true, true, $authplugin->get_custom_user_profile_fields());
|
||||
|
@ -38,6 +38,7 @@ function xmldb_auth_email_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/email to auth_email.
|
||||
upgrade_fix_config_auth_plugin_names('email');
|
||||
upgrade_fix_config_auth_plugin_defaults('email');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'email');
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ if ($ADMIN->fulltree) {
|
||||
new lang_string('auth_emailrecaptcha', 'auth_email'), 0, $options));
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('email');
|
||||
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
|
||||
get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ function xmldb_auth_fc_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/fc to auth_fc.
|
||||
upgrade_fix_config_auth_plugin_names('fc');
|
||||
upgrade_fix_config_auth_plugin_defaults('fc');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'fc');
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ if ($ADMIN->fulltree) {
|
||||
get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('fc');
|
||||
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
|
||||
get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ function xmldb_auth_imap_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/imap to auth_imap.
|
||||
upgrade_fix_config_auth_plugin_names('imap');
|
||||
upgrade_fix_config_auth_plugin_defaults('imap');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'imap');
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ if ($ADMIN->fulltree) {
|
||||
get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('imap');
|
||||
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
|
||||
get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
|
||||
|
@ -62,6 +62,7 @@ function xmldb_auth_ldap_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/ldap to auth_ldap.
|
||||
upgrade_fix_config_auth_plugin_names('ldap');
|
||||
upgrade_fix_config_auth_plugin_defaults('ldap');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'ldap');
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ if ($ADMIN->fulltree) {
|
||||
}
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('ldap');
|
||||
$help = get_string('auth_ldapextrafields', 'auth_ldap');
|
||||
$help .= get_string('auth_updatelocal_expl', 'auth');
|
||||
$help .= get_string('auth_fieldlock_expl', 'auth');
|
||||
|
@ -50,6 +50,7 @@ function xmldb_auth_manual_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/manual to auth_manual.
|
||||
upgrade_fix_config_auth_plugin_names('manual');
|
||||
upgrade_fix_config_auth_plugin_defaults('manual');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'manual');
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ if ($ADMIN->fulltree) {
|
||||
new lang_string('expiration_warning_desc', 'auth_manual'), 0, $expirationwarningoptions));
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('manual');
|
||||
display_auth_lock_options($settings, $authplugin->authtype,
|
||||
$authplugin->userfields, get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ function xmldb_auth_mnet_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/mnet to auth_mnet.
|
||||
upgrade_fix_config_auth_plugin_names('mnet');
|
||||
upgrade_fix_config_auth_plugin_defaults('mnet');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'mnet');
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ function xmldb_auth_nntp_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/nntp to auth_nntp.
|
||||
upgrade_fix_config_auth_plugin_names('nntp');
|
||||
upgrade_fix_config_auth_plugin_defaults('nntp');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'nntp');
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ if ($ADMIN->fulltree) {
|
||||
get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('nntp');
|
||||
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
|
||||
get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ function xmldb_auth_none_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/none to auth_none.
|
||||
upgrade_fix_config_auth_plugin_names('none');
|
||||
upgrade_fix_config_auth_plugin_defaults('none');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'none');
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ if ($ADMIN->fulltree) {
|
||||
new lang_string('auth_nonedescription', 'auth_none')));
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('none');
|
||||
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
|
||||
get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ if ($ADMIN->fulltree) {
|
||||
$warning = $OUTPUT->notification(get_string('createaccountswarning', 'auth_oauth2'), 'warning');
|
||||
$settings->add(new admin_setting_heading('auth_oauth2/pluginname', '', $warning));
|
||||
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('oauth2');
|
||||
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
|
||||
get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ function xmldb_auth_pam_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/pam to auth_pam.
|
||||
upgrade_fix_config_auth_plugin_names('pam');
|
||||
upgrade_fix_config_auth_plugin_defaults('pam');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'pam');
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ if ($ADMIN->fulltree) {
|
||||
new lang_string('auth_pamdescription', 'auth_pam')));
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('pam');
|
||||
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
|
||||
get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ function xmldb_auth_pop3_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/pop3 to auth_pop3.
|
||||
upgrade_fix_config_auth_plugin_names('pop3');
|
||||
upgrade_fix_config_auth_plugin_defaults('pop3');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'pop3');
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ if ($ADMIN->fulltree) {
|
||||
get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('pop3');
|
||||
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
|
||||
get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ function xmldb_auth_shibboleth_upgrade($oldversion) {
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/shibboleth to auth_shibboleth.
|
||||
upgrade_fix_config_auth_plugin_names('shibboleth');
|
||||
upgrade_fix_config_auth_plugin_defaults('shibboleth');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'shibboleth');
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ if ($ADMIN->fulltree) {
|
||||
get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
|
||||
|
||||
// Display locking / mapping of profile fields.
|
||||
$authplugin = get_auth_plugin($this->name);
|
||||
$authplugin = get_auth_plugin('shibboleth');
|
||||
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
|
||||
'', true, false, $authplugin->get_custom_user_profile_fields());
|
||||
|
||||
|
@ -3,10 +3,11 @@ information provided here is intended especially for developers.
|
||||
|
||||
=== 3.3 ===
|
||||
|
||||
* Authentication plugins have been migrated to use the admin settings API.
|
||||
Plugins should use a settings.php file to manage configurations rather than using the config.html files.
|
||||
See how the helper function upgrade_fix_config_auth_plugin_names() can be used to convert the legacy settings to the
|
||||
new ones.
|
||||
* Authentication plugins have been migrated to use the admin settings API. Plugins should use a settings.php file to
|
||||
manage configurations rather than using the old config.html files. See how the helper function
|
||||
upgrade_fix_config_auth_plugin_names() can be used to convert the legacy settings to the new ones. Another helper
|
||||
function upgrade_fix_config_auth_plugin_defaults() can be used to populate the settings with default values so that
|
||||
they are not falsely reported as newly added ones.
|
||||
* The function 'print_auth_lock_options' has been replaced by 'display_auth_lock_options' which uses the admin settings API.
|
||||
See auth_manual as an exmple of how it can be used. More information can be found in MDL-12689.
|
||||
* The list of supported identity providers (SSO IdP) returned by the 'loginpage_idp_list' method (used to render the
|
||||
|
@ -2569,3 +2569,53 @@ function upgrade_fix_config_auth_plugin_names($plugin) {
|
||||
unset_config($name, 'auth/'.$plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the auth plugin settings with defaults if needed.
|
||||
*
|
||||
* As a result of fixing the auth plugins config storage, many settings would
|
||||
* be falsely reported as new ones by admin/upgradesettings.php. We do not want
|
||||
* to confuse admins so we try to reduce the bewilderment by pre-populating the
|
||||
* config_plugins table with default values. This should be done only for
|
||||
* disabled auth methods. The enabled methods have their settings already
|
||||
* stored, so reporting actual new settings for them is valid.
|
||||
*
|
||||
* @param string $plugin the auth plugin name such as 'cas', 'manual' or 'mnet'
|
||||
*/
|
||||
function upgrade_fix_config_auth_plugin_defaults($plugin) {
|
||||
global $CFG;
|
||||
|
||||
$pluginman = core_plugin_manager::instance();
|
||||
$enabled = $pluginman->get_enabled_plugins('auth');
|
||||
|
||||
if (isset($enabled[$plugin])) {
|
||||
// Do not touch settings of enabled auth methods.
|
||||
return;
|
||||
}
|
||||
|
||||
// We can't directly use {@link core\plugininfo\auth::load_settings()} here
|
||||
// because the plugins are not fully upgraded yet. Instead, we emulate what
|
||||
// that method does. We fetch a temporary instance of the plugin's settings
|
||||
// page to get access to the settings and their defaults. Note we are not
|
||||
// adding that temporary instance into the admin tree. Yes, this is a hack.
|
||||
|
||||
$plugininfo = $pluginman->get_plugin_info('auth_'.$plugin);
|
||||
$adminroot = admin_get_root();
|
||||
$ADMIN = $adminroot;
|
||||
$auth = $plugininfo;
|
||||
|
||||
$section = $plugininfo->get_settings_section_name();
|
||||
$settingspath = $plugininfo->full_path('settings.php');
|
||||
|
||||
if (file_exists($settingspath)) {
|
||||
$settings = new admin_settingpage($section, 'Emulated settings page for auth_'.$plugin, 'moodle/site:config');
|
||||
include($settingspath);
|
||||
|
||||
if ($settings) {
|
||||
// Consistently with what admin/cli/upgrade.php does, apply the default settings twice.
|
||||
// I assume this is done for theoretical cases when a default value depends on an other.
|
||||
admin_apply_default_settings($settings, false);
|
||||
admin_apply_default_settings($settings, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user