diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index 5ea166042bd..6d8f95a6a82 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -81,28 +81,10 @@ if ($hassiteconfig) { $ADMIN->add('modules', new admin_category('enrolments', new lang_string('enrolments', 'enrol'))); $temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol')); $temp->add(new admin_setting_manageenrols()); - if (empty($CFG->enrol_plugins_enabled)) { - $enabled = array(); - } else { - $enabled = explode(',', $CFG->enrol_plugins_enabled); - } - $enrols = get_plugin_list('enrol'); $ADMIN->add('enrolments', $temp); - foreach($enrols as $enrol=>$enrolpath) { - if (!file_exists("$enrolpath/settings.php")) { - continue; - } - - $settings = new admin_settingpage('enrolsettings'.$enrol, new lang_string('pluginname', 'enrol_'.$enrol), 'moodle/site:config', !in_array($enrol, $enabled)); - // settings.php may create a subcategory or unset the settings completely - include("$enrolpath/settings.php"); - if ($settings) { - $ADMIN->add('enrolments', $settings); - } - + foreach($allplugins['enrol'] as $enrol) { + $enrol->load_settings($ADMIN, 'enrolments', $hassiteconfig); } - unset($enabled); - unset($enrols); /// Editor plugins diff --git a/enrol/imsenterprise/settings.php b/enrol/imsenterprise/settings.php index 9040b21dd67..1c7f205308e 100644 --- a/enrol/imsenterprise/settings.php +++ b/enrol/imsenterprise/settings.php @@ -27,7 +27,7 @@ defined('MOODLE_INTERNAL') || die(); if ($ADMIN->fulltree) { - require_once('locallib.php'); + require_once($CFG->dirroot.'/enrol/imsenterprise/locallib.php'); $settings->add(new admin_setting_heading('enrol_imsenterprise_settings', '', get_string('pluginname_desc', 'enrol_imsenterprise'))); diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 45de46cd804..c0a5884576f 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -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); } }