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
 * Configure provider instance order settings.
19
 *
20
 * @package     core_ai
21
 * @copyright   Meirza <meirza.arson@moodle.com>
22
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require_once(__DIR__ . '../../config.php');
26
 
27
require_login(autologinguest: false);
28
require_capability('moodle/site:config', context_system::instance());
29
 
30
require_sesskey();
31
 
32
$PAGE->set_url('/ai/configure_providers.php');
33
 
34
$action = optional_param('action', '', PARAM_ALPHA);
35
$id = optional_param('id', '', PARAM_INT);
36
 
37
$manager = \core\di::get(\core_ai\manager::class);
38
$providerrecord = $manager->get_provider_records(filter: ['id' => $id]);
39
 
40
$returnurl = new moodle_url('/admin/settings.php?section=aiprovider');
41
 
42
if (empty($providerrecord) || !$providerrecord) {
43
    throw new moodle_exception('error:providernotfound', 'core_ai', $returnurl);
44
}
45
 
46
if (empty($action) || !in_array($action, \core\plugininfo\aiprovider::get_provider_actions())) {
47
    throw new moodle_exception('error:actionnotfound', 'core_ai', $returnurl, $action);
48
}
49
 
50
switch ($action) {
51
    case \core\plugininfo\aiprovider::UP:
52
        $manager->change_provider_order($id, \core\plugininfo\aiprovider::MOVE_UP);
53
        break;
54
    case \core\plugininfo\aiprovider::DOWN:
55
        $manager->change_provider_order($id, \core\plugininfo\aiprovider::MOVE_DOWN);
56
        break;
57
}
58
 
59
redirect($returnurl);