Commit | Line | Data |
---|---|---|
2bdd5ff4 DW |
1 | <?php |
2 | // This file is part of Moodle - http://moodle.org/ | |
3 | // | |
4 | // Moodle is free software: you can redistribute it and/or modify | |
5 | // it under the terms of the GNU General Public License as published by | |
6 | // the Free Software Foundation, either version 3 of the License, or | |
7 | // (at your option) any later version. | |
8 | // | |
9 | // Moodle is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | // | |
14 | // You should have received a copy of the GNU General Public License | |
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | /** | |
18 | * LTI source plugin info. | |
19 | * | |
20 | * @package mod_lti | |
21 | * @copyright 2013 Damyon Wiese | |
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
23 | */ | |
24 | namespace mod_lti\plugininfo; | |
25 | ||
e9033d11 | 26 | use core\plugininfo\base; |
2bdd5ff4 DW |
27 | |
28 | defined('MOODLE_INTERNAL') || die(); | |
29 | ||
30 | ||
31 | class ltisource extends base { | |
e9033d11 MN |
32 | /** |
33 | * Returns the node name used in admin settings menu for this plugin settings (if applicable) | |
34 | * | |
35 | * @return null|string node name or null if plugin does not create settings node (default) | |
36 | */ | |
37 | public function get_settings_section_name() { | |
38 | return 'ltisourcesetting'.$this->name; | |
39 | } | |
40 | ||
41 | /** | |
42 | * Loads plugin settings to the settings tree | |
43 | * | |
44 | * This function usually includes settings.php file in plugins folder. | |
45 | * Alternatively it can create a link to some settings page (instance of admin_externalpage) | |
46 | * | |
47 | * @param \part_of_admin_tree $adminroot | |
48 | * @param string $parentnodename | |
49 | * @param bool $hassiteconfig whether the current user has moodle/site:config capability | |
50 | */ | |
51 | public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) { | |
52 | global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them. | |
53 | $ADMIN = $adminroot; // May be used in settings.php. | |
54 | $plugininfo = $this; // Also can be used inside settings.php. | |
55 | ||
56 | if (!$this->is_installed_and_upgraded()) { | |
57 | return; | |
58 | } | |
59 | if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) { | |
60 | return; | |
61 | } | |
62 | $section = $this->get_settings_section_name(); | |
63 | $settings = new \admin_settingpage($section, $this->displayname, | |
64 | 'moodle/site:config', $this->is_enabled() === false); | |
65 | ||
66 | include($this->full_path('settings.php')); // This may also set $settings to null. | |
67 | ||
68 | if ($settings) { | |
69 | $ADMIN->add($parentnodename, $settings); | |
70 | } | |
71 | } | |
a0dbba83 MG |
72 | |
73 | /** | |
74 | * Should there be a way to uninstall the plugin via the administration UI. | |
75 | * | |
76 | * @return bool | |
77 | */ | |
78 | public function is_uninstall_allowed() { | |
79 | return true; | |
80 | } | |
2bdd5ff4 | 81 | } |