MDL-66004 mlbackend_python: Package installed on a separate server

This commit is contained in:
David Monllaó
2019-10-02 08:41:14 +08:00
parent 9528b1ff5b
commit aa5b705607
13 changed files with 691 additions and 187 deletions
+34 -1
View File
@@ -50,6 +50,39 @@ class mlbackend extends base {
* @return null|string node name or null if plugin does not create settings node (default)
*/
public function get_settings_section_name() {
return 'mlbackendsetting' . $this->name;
return 'mlbackendsettings' . $this->name;
}
/**
* Load the global settings for a particular availability plugin (if there are any)
*
* @param \part_of_admin_tree $adminroot
* @param string $parentnodename
* @param bool $hassiteconfig
* @return void
*/
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.
$plugininfo = $this; // Also can be used inside settings.php.
if (!$this->is_installed_and_upgraded()) {
return;
}
if (!$hassiteconfig) {
return;
}
$section = $this->get_settings_section_name();
$settings = null;
if (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);
}
}
}