MDL-44084 atto: correct standard plugins list and namespace bug fix
[moodle.git] / lib / editor / atto / classes / plugininfo / atto.php
CommitLineData
adca7326
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 * Subplugin info class.
19 *
20 * @package editor_atto
21 * @copyright 2013 Petr Skoda {@link http://skodak.org}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24namespace editor_atto\plugininfo;
25
26use core\plugininfo\base;
27
28defined('MOODLE_INTERNAL') || die();
29
30
31class atto extends base {
fcb5b5c4
DW
32
33 /**
34 * Yes you can uninstall these plugins if you want.
205c6db5 35 * @return \moodle_url
fcb5b5c4 36 */
adca7326
DW
37 public function is_uninstall_allowed() {
38 return true;
39 }
fcb5b5c4
DW
40
41 /**
42 * Return URL used for management of plugins of this type.
205c6db5 43 * @return \moodle_url
fcb5b5c4
DW
44 */
45 public static function get_manage_url() {
205c6db5 46 return new \moodle_url('/admin/settings.php', array('section'=>'editorsettingsatto'));
fcb5b5c4
DW
47 }
48
49 /**
50 * Include the settings.php file from sub plugins if they provide it.
51 * This is a copy of very similar implementations from various other subplugin areas.
52 *
205c6db5 53 * @return \moodle_url
fcb5b5c4
DW
54 */
55 public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
56 global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them.
57 $ADMIN = $adminroot; // May be used in settings.php.
58 $plugininfo = $this; // Also can be used inside settings.php.
59
60 if (!$this->is_installed_and_upgraded()) {
61 return;
62 }
63
64 if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) {
65 return;
66 }
67
68 $section = $this->get_settings_section_name();
69 $settings = new \admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false);
70 include($this->full_path('settings.php')); // This may also set $settings to null.
71
72 if ($settings) {
73 $ADMIN->add($parentnodename, $settings);
74 }
75 }
6f0a1600
JM
76
77 /**
78 * Get the settings section name.
79 * It's used to get the setting links in the Atto sub-plugins table.
80 *
81 * @return null|string the settings section name.
82 */
83 public function get_settings_section_name() {
84 return 'atto' . $this->name . 'settings';
85 }
adca7326 86}