Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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
 * Manage AI subsystem plugins settings.
19
 *
20
 * @package    core_admin
21
 * @copyright  2024 Matt Porritt <matt.porritt@moodle.com>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require_once('../config.php');
26
require_once($CFG->libdir . '/adminlib.php');
27
 
28
$action = required_param('action', PARAM_ALPHANUMEXT);
29
$type = required_param('type', PARAM_PLUGIN); // Must be provider or placement.
30
$name = required_param('name', PARAM_PLUGIN); // Plugin name, e.g openai.
31
 
32
$syscontext = context_system::instance();
33
$PAGE->set_url('/admin/ai.php');
34
$PAGE->set_context($syscontext);
35
 
36
require_admin();
37
require_sesskey();
38
 
39
$return = new moodle_url('/admin/settings.php', ['section' => "aisettings$type"]);
40
 
41
$plugins = core_plugin_manager::instance()->get_plugins_of_type("ai$type");
42
$sortorder = array_flip(array_keys($plugins));
43
 
44
if (!isset($plugins[$name])) {
45
    throw new moodle_exception('aipluginnotfound', 'core_ai', $return, $name);
46
}
47
 
48
$plugintypename = $plugins[$name]->type . '_' . $plugins[$name]->name;
49
 
50
switch ($action) {
51
    case 'disable':
52
        if ($plugins[$name]->is_enabled()) {
53
            $class = core_plugin_manager::resolve_plugininfo_class("aisettings$type");
54
            $class::enable_plugin($name, false);
55
        }
56
        break;
57
    case 'enable':
58
        if (!$plugins[$name]->is_enabled()) {
59
            $class = core_plugin_manager::resolve_plugininfo_class("aisettings$type");
60
            $class::enable_plugin($name, true);
61
        }
62
        break;
63
}
64
 
65
redirect($return);