Skip to content
Snippets Groups Projects

allow seperate settings for subplugins

5 files
+ 131
75
Compare changes
  • Side-by-side
  • Inline

Files

+ 39
0
@@ -32,4 +32,43 @@ class lareport extends base {
public function is_uninstall_allowed() {
return true;
}
/**
* Include the settings.php file from sub plugins if they provide it.
* This is a copy of very similar implementations from various other subplugin areas.
*
* @return \moodle_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.
$plugininfo = $this; // Also can be used inside settings.php.
if (!$this->is_installed_and_upgraded()) {
return;
}
if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) {
return;
}
$section = $this->get_settings_section_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.
if ($settings) {
$ADMIN->add($parentnodename, $settings);
}
}
/**
* Get the settings section name.
* It's used to get the setting links in the Atto sub-plugins table.
*
* @return null|string the settings section name.
*/
public function get_settings_section_name() {
return 'lareport_' . $this->name . '_settings';
}
}
\ No newline at end of file
Loading