MDL-35661 Loading of plugin settings for auth plugins (plugininfo_auth)

This commit is contained in:
Marina Glancy 2012-09-19 09:15:05 +08:00
parent 870d42809a
commit cbe9f609f8
2 changed files with 27 additions and 24 deletions

View File

@ -73,27 +73,10 @@ if ($hassiteconfig) {
$temp->add(new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
$ADMIN->add('authsettings', $temp);
$auths = get_plugin_list('auth');
$authsenabled = get_enabled_auth_plugins();
foreach ($auths as $authname => $authdir) {
$strauthname = new lang_string('pluginname', "auth_{$authname}");
// do not show disabled auths in tree, keep only settings link on manage page
$enabled = in_array($authname, $authsenabled);
if (file_exists($authdir.'/settings.php')) {
// TODO: finish implementation of common settings - locking, etc.
$settings = new admin_settingpage('authsetting'.$authname, $strauthname, 'moodle/site:config', !$enabled);
include($authdir.'/settings.php');
if ($settings) {
$ADMIN->add('authsettings', $settings);
}
} else {
$ADMIN->add('authsettings', new admin_externalpage('authsetting'.$authname, $strauthname, "$CFG->wwwroot/$CFG->admin/auth_config.php?auth=$authname", 'moodle/site:config', !$enabled));
}
foreach ($allplugins['auth'] as $auth) {
$auth->load_settings($ADMIN, 'authsettings', $hassiteconfig);
}
// Enrolment plugins
$ADMIN->add('modules', new admin_category('enrolments', new lang_string('enrolments', 'enrol')));
$temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol'));

View File

@ -2393,11 +2393,31 @@ class plugininfo_auth extends plugininfo_base {
return isset($enabled[$this->name]);
}
public function get_settings_url() {
if (file_exists($this->full_path('settings.php'))) {
return new moodle_url('/admin/settings.php', array('section' => 'authsetting' . $this->name));
} else {
return new moodle_url('/admin/auth_config.php', array('auth' => $this->name));
public function get_settings_section_name() {
return 'authsetting' . $this->name;
}
public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
global $CFG, $USER, $DB, $OUTPUT, $PAGE; // in case settings.php wants to refer to them
$ADMIN = $adminroot; // may be used in settings.php
$auth = $this; // also to be used inside settings.php
$section = $this->get_settings_section_name();
$settings = null;
if ($hassiteconfig) {
if (file_exists($this->full_path('settings.php'))) {
// TODO: finish implementation of common settings - locking, etc.
$settings = new admin_settingpage($section, $this->displayname,
'moodle/site:config', $this->is_enabled() === false);
include($this->full_path('settings.php')); // this may also set $settings to null
} else {
$settingsurl = new moodle_url('/admin/auth_config.php', array('auth' => $this->name));
$settings = new admin_externalpage($section, $this->displayname,
$settingsurl, 'moodle/site:config', $this->is_enabled() === false);
}
}
if ($settings) {
$ADMIN->add($parentnodename, $settings);
}
}
}