MDL-35661 Loading of plugin settings for enrol plugins (plugininfo_enrol)

This commit is contained in:
Marina Glancy
2012-10-09 09:57:57 +08:00
parent cbe9f609f8
commit 79c5c3fa96
3 changed files with 20 additions and 26 deletions
+17 -5
View File
@@ -2445,12 +2445,24 @@ class plugininfo_enrol extends plugininfo_base {
return isset($enabled[$this->name]);
}
public function get_settings_url() {
public function get_settings_section_name() {
return 'enrolsettings' . $this->name;
}
if ($this->is_enabled() or file_exists($this->full_path('settings.php'))) {
return new moodle_url('/admin/settings.php', array('section' => 'enrolsettings' . $this->name));
} else {
return parent::get_settings_url();
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
$enrol = $this; // also can be used inside settings.php
$section = $this->get_settings_section_name();
$settings = null;
if ($hassiteconfig && file_exists($this->full_path('settings.php'))) {
$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
}
if ($settings) {
$ADMIN->add($parentnodename, $settings);
}
}