-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexternallib.php
84 lines (78 loc) · 3.2 KB
/
externallib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* External functions for managing enrol_manual.
*
* @package local_ws_enrol_manual
* @copyright 2024 Lafayette College ITS
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_external\external_api;
use core_external\external_function_parameters;
use core_external\external_single_structure;
use core_external\external_multiple_structure;
use core_external\external_value;
/**
* External functions for managing enrol_manual.
*
* @package local_ws_enrol_manual
* @copyright 2024 Lafayette College ITS
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class local_ws_enrol_manual_external extends external_api {
/**
* Returns description of method parameters
*
* @return external_function_parameters
*/
public static function add_instance_parameters() {
return new external_function_parameters([
'params' => new external_single_structure([
'courseid' => new external_value(PARAM_INT, 'The course id', VALUE_REQUIRED),
'status' => new external_value(PARAM_INT, 'Enable manual enrolments', VALUE_DEFAULT, 0),
'roleid' => new external_value(PARAM_INT, 'Default role', VALUE_REQUIRED),
'enrolperiod' => new external_value(PARAM_INT, 'Default enrolment duration', VALUE_DEFAULT, 0),
'expirynotify' => new external_value(PARAM_INT, 'Notify before enrolment expires', VALUE_DEFAULT, 0),
'expirythreshold' => new external_value(PARAM_INT, 'Notification threshold', VALUE_DEFAULT, 86400),
'customint1' => new external_value(PARAM_INT, 'Send course welcome message', VALUE_DEFAULT, 1),
'customtext1' => new external_value(PARAM_RAW, 'Custom welcome message', VALUE_DEFAULT, null),
])
]);
}
/**
* Add a manual enrol instance to a course.
*
* @param array $params the parameters.
*/
public static function add_instance($params) {
$params = self::validate_parameters(self::add_instance_parameters(), ['params' => $params]);
return [
'id' => local_ws_enrol_manual\manage::add_instance($params),
];
}
/**
* Returns description of add_instance_returns() result value.
*
* @return \external_description
*/
public static function add_instance_returns() {
return new external_single_structure(
[
'id' => new external_value(PARAM_INT, 'id of the created instance')
]
);
}
}