-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.php
212 lines (190 loc) · 6.44 KB
/
lib.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?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/>.
/**
* Enrolment method "SEMCO" - Library
*
* @package enrol_semco
* @copyright 2022 Alexander Bias, lern.link GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Enrolment method "SEMCO"
*
* @package enrol_semco
* @copyright 2022 Alexander Bias, lern.link GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class enrol_semco_plugin extends enrol_plugin {
/**
* Returns localised name of enrol instance.
*
* @param object $instance
* @return string
*/
public function get_instance_name($instance) {
// If a SEMCO booking ID is stored in customchar1.
if (!empty($instance->customchar1)) {
// Return the instance name with the booking ID.
return get_string('instance_namewithbookingid', 'enrol_semco', $instance->customchar1);
// Otherwise (this should not happen however).
} else {
// Return the instance name with the booking ID.
return get_string('instance_namewithoutbookingid', 'enrol_semco');
}
}
/**
* Does this plugin assign protected roles or can they be manually removed?
*
* @return bool
*/
public function roles_protected() {
return true;
}
/**
* Does this plugin allow manual enrolments?
*
* @param stdClass $instance course enrol instance
* @return bool
*/
public function allow_enrol(stdClass $instance) {
// We return false here as we do not want to allow any manual enrolments in the GUI at all.
// However, the plugin still implements the enrol/semco:enrol capability to control if the webservice user
// is allowed to do the enrolments or not.
return false;
}
/**
* Does this plugin allow manual unenrolment of all users?
*
* @param stdClass $instance course enrol instance
* @return bool
*/
public function allow_unenrol(stdClass $instance) {
// We return false here as we do not want to allow any unmanual enrolments in the GUI at all.
// However, the plugin still implements the enrol/semco:unenrol capability to control if the webservice user
// is allowed to do the unenrolments or not.
return false;
}
/**
* Does this plugin allow manual unenrolment of a specific user?
*
* @param stdClass $instance course enrol instance
* @param stdClass $ue record from user_enrolments table, specifies user
*
* @return bool
*/
public function allow_unenrol_user(stdClass $instance, stdClass $ue) {
// We return false here as we do not want to allow any unmanual enrolments in the GUI at all.
// However, the plugin still implements the enrol/semco:unenrol capability to control if the webservice user
// is allowed to do the unenrolments or not.
return false;
}
/**
* Does this plugin allow manual changes in user_enrolments table?
*
* @param stdClass $instance course enrol instance
* @return bool
*/
public function allow_manage(stdClass $instance) {
return false;
}
/**
* Does this plugin support some way to user to self enrol?
*
* @param stdClass $instance course enrol instance
*
* @return bool
*/
public function show_enrolme_link(stdClass $instance) {
return false;
}
/**
* If we would say that we use the standard editing UI, Moodle would search for the enrol/semco:config capability
* which we do not define. On the other hand, everything works fine if we return false here.
*
* @return boolean
*/
public function use_standard_editing_ui() {
return false;
}
/**
* Return whether or not, given the current state, it is possible to add a new instance
* of this enrolment plugin to the course.
*
* @param int $courseid
* @return boolean
*/
public function can_add_instance($courseid) {
return false;
}
/**
* Return whether or not, given the current state, it is possible to edit an instance
* of this enrolment plugin in the course. Used by the standard editing UI
* to generate a link to the edit instance form if editing is allowed.
*
* @param stdClass $instance
* @return boolean
*/
public function can_edit_instance($instance) {
return false;
}
/**
* Is it possible to delete enrol instance via standard UI?
*
* @param object $instance
* @return bool
*/
public function can_delete_instance($instance) {
return false;
}
/**
* Is it possible to hide/show enrol instance via standard UI?
*
* @param stdClass $instance
* @return bool
*/
public function can_hide_show_instance($instance) {
return false;
}
/**
* Returns edit icons for the page with list of instances
*
* @param stdClass $instance
* @return array
*/
public function get_action_icons(stdClass $instance) {
return [];
}
/**
* Returns true if the plugin has one or more bulk operations that can be performed on
* user enrolments.
*
* @param course_enrolment_manager $manager
* @return bool
*/
public function has_bulk_operations(course_enrolment_manager $manager) {
return false;
}
}
/**
* Callback to add head elements (for releases up to Moodle 4.3).
*/
function enrol_semco_before_standard_top_of_body_html() {
global $CFG;
// Require local library.
require_once($CFG->dirroot.'/enrol/semco/locallib.php');
// Call and return callback implementation.
return enrol_semco_callbackimpl_before_standard_top_of_body_html();
}