Permalink
Browse files

MDL-32009 messaging: Refator get_settings_url plugintype method

No need to duplicate checks since we have them in one place.
  • Loading branch information...
1 parent 23778a4 commit 26d859e0ecd49ee32b5b0d414c9a119281db9b48 Ruslan Kabalin committed Mar 9, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/pluginlib.php
View
@@ -1529,16 +1529,28 @@ public function get_uninstall_url() {
*/
class plugintype_message extends plugintype_base implements plugin_information {
+ private $processors;
+
+ protected function __construct() {
+ global $CFG;
+ require_once($CFG->dirroot . '/message/lib.php');
+ $this->processors = get_message_processors();
+ }
+
/**
* @see plugin_information::get_settings_url()
*/
public function get_settings_url() {
- if (file_exists($this->full_path('settings.php')) or file_exists($this->full_path('settingstree.php'))) {
- return new moodle_url('/admin/settings.php', array('section' => 'messagesetting' . $this->name));
+ if (isset($this->processors[$this->name])) {
+ $processor = $this->processors[$this->name];
} else {
return parent::get_settings_url();
}
+
+ if ($processor->available && $processor->hassettings) {
+ return new moodle_url('settings.php', array('section' => 'messagesetting'.$processor->name));
+ }
}
}

0 comments on commit 26d859e

Please sign in to comment.