1 |
efrain |
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 |
* Subplugin info class.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_customcert
|
|
|
21 |
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
namespace mod_customcert\plugininfo;
|
|
|
25 |
|
|
|
26 |
use core\plugininfo\base;
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Subplugin info class.
|
|
|
30 |
*
|
|
|
31 |
* @package mod_customcert
|
|
|
32 |
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
|
|
33 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
34 |
*/
|
|
|
35 |
class customcertelement extends base {
|
|
|
36 |
|
|
|
37 |
/**
|
|
|
38 |
* Do not allow users to uninstall these plugins as it could cause customcerts to break.
|
|
|
39 |
*
|
|
|
40 |
* @return bool
|
|
|
41 |
*/
|
|
|
42 |
public function is_uninstall_allowed() {
|
|
|
43 |
return false;
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Loads plugin settings to the settings tree.
|
|
|
48 |
*
|
|
|
49 |
* @param \part_of_admin_tree $adminroot
|
|
|
50 |
* @param string $parentnodename
|
|
|
51 |
* @param bool $hassiteconfig whether the current user has moodle/site:config capability
|
|
|
52 |
*/
|
|
|
53 |
public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
|
|
|
54 |
global $CFG, $USER, $DB, $OUTPUT, $PAGE;
|
|
|
55 |
$ADMIN = $adminroot;
|
|
|
56 |
$plugininfo = $this;
|
|
|
57 |
|
|
|
58 |
if (!$this->is_installed_and_upgraded()) {
|
|
|
59 |
return;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
if (!$hassiteconfig || !file_exists($this->full_path('settings.php'))) {
|
|
|
63 |
return;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
$section = $this->get_settings_section_name();
|
|
|
67 |
$settings = new \admin_settingpage($section, $this->displayname, 'moodle/site:config', false);
|
|
|
68 |
|
|
|
69 |
include($this->full_path('settings.php'));
|
|
|
70 |
$ADMIN->add($parentnodename, $settings);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
/**
|
|
|
74 |
* Get the settings section name.
|
|
|
75 |
*
|
|
|
76 |
* @return null|string the settings section name.
|
|
|
77 |
*/
|
|
|
78 |
public function get_settings_section_name() {
|
|
|
79 |
if (file_exists($this->full_path('settings.php'))) {
|
|
|
80 |
return 'customcertelement_' . $this->name;
|
|
|
81 |
} else {
|
|
|
82 |
return null;
|
|
|
83 |
}
|
|
|
84 |
}
|
|
|
85 |
}
|