From e8d169320bed101f76e145f076d34a9cbc7f2920 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 27 Sep 2012 09:45:50 +0800 Subject: [PATCH] MDL-35661 Loading of plugin settings for message processors (plugininfo_message) --- admin/settings/plugins.php | 17 ++--------------- lib/pluginlib.php | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index bca18107ecd..42ab58d29c9 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -31,21 +31,8 @@ if ($hassiteconfig) { $ADMIN->add('modules', new admin_category('messageoutputs', new lang_string('messageoutputs', 'message'))); $ADMIN->add('messageoutputs', new admin_page_managemessageoutputs()); $ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs()); - require_once($CFG->dirroot.'/message/lib.php'); - $processors = get_message_processors(); - foreach ($processors as $processor) { - $processorname = $processor->name; - if (!$processor->available) { - continue; - } - if ($processor->hassettings) { - $strprocessorname = new lang_string('pluginname', 'message_'.$processorname); - $settings = new admin_settingpage('messagesetting'.$processorname, $strprocessorname, 'moodle/site:config', !$processor->enabled); - include($CFG->dirroot.'/message/output/'.$processor->name.'/settings.php'); - if ($settings) { - $ADMIN->add('messageoutputs', $settings); - } - } + foreach ($allplugins['message'] as $processor) { + $processor->load_settings($ADMIN, 'messageoutputs', $hassiteconfig); } // authentication plugins diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 88ef2585306..910686c915c 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -2510,15 +2510,31 @@ class plugininfo_enrol extends plugininfo_base { */ class plugininfo_message extends plugininfo_base { - public function get_settings_url() { + public function get_settings_section_name() { + return 'messagesetting' . $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 + if (!$hassiteconfig) { + return; + } + $section = $this->get_settings_section_name(); + + $settings = null; $processors = get_message_processors(); if (isset($processors[$this->name])) { $processor = $processors[$this->name]; if ($processor->available && $processor->hassettings) { - return new moodle_url('settings.php', array('section' => 'messagesetting'.$processor->name)); + $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 } } - return parent::get_settings_url(); + if ($settings) { + $ADMIN->add($parentnodename, $settings); + } } /** @@ -2539,7 +2555,7 @@ class plugininfo_message extends plugininfo_base { public function get_uninstall_url() { $processors = get_message_processors(); if (isset($processors[$this->name])) { - return new moodle_url('message.php', array('uninstall' => $processors[$this->name]->id, 'sesskey' => sesskey())); + return new moodle_url('/admin/message.php', array('uninstall' => $processors[$this->name]->id, 'sesskey' => sesskey())); } else { return parent::get_uninstall_url(); } -- 2.11.4.GIT