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
namespace tool_admin_presets\external;
18
 
19
use core_adminpresets\manager;
20
use core_external\external_api;
21
use core_external\external_function_parameters;
22
use core_external\external_value;
23
 
24
/**
25
 * External function tool_admin_presets_delete_preset
26
 *
27
 * @package    tool_admin_presets
28
 * @copyright  2024 David Carrillo <davidmc@moodle.com>
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
31
class delete_preset extends external_api {
32
 
33
    /**
34
     * Describes the parameters.
35
     *
36
     * @return external_function_parameters
37
     */
38
    public static function execute_parameters(): external_function_parameters {
39
        return new external_function_parameters([
40
            'id' => new external_value(PARAM_INT),
41
        ]);
42
    }
43
 
44
    /**
45
     * External function to delete custom presets.
46
     *
47
     * @param int $id
48
     */
49
    public static function execute(int $id): void {
50
        // Parameter validation.
51
        [
52
            'id' => $id,
53
        ] = self::validate_parameters(self::execute_parameters(), [
54
            'id' => $id,
55
        ]);
56
 
57
        // Validate context.
58
        $context = \context_system::instance();
59
        self::validate_context($context);
60
 
61
        require_capability('moodle/site:config', $context);
62
 
63
        (new manager())->delete_preset($id);
64
    }
65
 
66
    /**
67
     * Describes the data returned from the external function.
68
     */
69
    public static function execute_returns(): void {
70
    }
71
}