foreach ($allplugins['repository'] as $repositorytype) {
$repositorytype->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
}
-}
/// Web services
$ADMIN->add('modules', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
'admin'), new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
$ADMIN->add('webservicesettings', $temp);
/// links to protocol pages
- $webservices_available = get_plugin_list('webservice');
- $active_webservices = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
- foreach ($webservices_available as $webservice => $location) {
- if (file_exists("$location/settings.php")) {
- $name = new lang_string('pluginname', 'webservice_'.$webservice);
- $settings = new admin_settingpage('webservicesetting'.$webservice, $name, 'moodle/site:config', !in_array($webservice, $active_webservices) or empty($CFG->enablewebservices));
- include("$location/settings.php");
- if ($settings) {
- $ADMIN->add('webservicesettings', $settings);
- }
- }
+ foreach ($allplugins['webservice'] as $webservice) {
+ $webservice->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
}
/// manage token page link
$ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', new lang_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
$temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
}
$ADMIN->add('webservicesettings', $temp);
+}
// Question type settings
if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
}
}
}
+
+/**
+ * Class for webservice protocols
+ */
+class plugininfo_webservice extends plugininfo_base {
+
+ public function get_settings_section_name() {
+ return 'webservicesetting' . $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
+ $webservice = $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);
+ }
+ }
+
+ public function is_enabled() {
+ global $CFG;
+ if (empty($CFG->enablewebservices)) {
+ return false;
+ }
+ $active_webservices = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
+ if (in_array($this->name, $active_webservices)) {
+ return true;
+ }
+ return false;
+ }
+
+ public function get_uninstall_url() {
+ return new moodle_url('/admin/webservice/protocols.php',
+ array('sesskey' => sesskey(), 'action' => 'uninstall', 'webservice' => $this->name));
+ }
+}
\ No newline at end of file