|
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
|
|
|
* Library calls for Moodle and BigBlueButton. |
|
19
|
|
|
* |
|
20
|
|
|
* @package mod_bigbluebuttonbn |
|
21
|
|
|
* @copyright 2010 onwards, Blindside Networks Inc |
|
22
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
23
|
|
|
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com) |
|
24
|
|
|
* @author Fred Dixon (ffdixon [at] blindsidenetworks [dt] com) |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
defined('MOODLE_INTERNAL') || die; |
|
28
|
|
|
|
|
29
|
|
|
global $CFG; |
|
30
|
|
|
|
|
31
|
|
|
require_once($CFG->dirroot.'/calendar/lib.php'); |
|
32
|
|
|
require_once($CFG->dirroot.'/message/lib.php'); |
|
33
|
|
|
require_once($CFG->dirroot.'/mod/lti/OAuth.php'); |
|
34
|
|
|
require_once($CFG->dirroot.'/tag/lib.php'); |
|
35
|
|
|
require_once($CFG->libdir.'/accesslib.php'); |
|
36
|
|
|
require_once($CFG->libdir.'/completionlib.php'); |
|
37
|
|
|
require_once($CFG->libdir.'/datalib.php'); |
|
38
|
|
|
require_once($CFG->libdir.'/enrollib.php'); |
|
39
|
|
|
require_once($CFG->libdir.'/filelib.php'); |
|
40
|
|
|
require_once($CFG->libdir.'/formslib.php'); |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
if (file_exists(dirname(__FILE__).'/vendor/firebase/php-jwt/src/JWT.php')) { |
|
44
|
|
|
require_once(dirname(__FILE__).'/vendor/firebase/php-jwt/src/JWT.php'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
if (!isset($CFG->bigbluebuttonbn)) { |
|
48
|
|
|
$CFG->bigbluebuttonbn = array(); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
if (file_exists(dirname(__FILE__).'/config.php')) { |
|
52
|
|
|
require_once(dirname(__FILE__).'/config.php'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/* |
|
56
|
|
|
* DURATIONCOMPENSATION: Feature removed by configuration |
|
57
|
|
|
*/ |
|
58
|
|
|
$CFG->bigbluebuttonbn['scheduled_duration_enabled'] = 0; |
|
59
|
|
|
/* |
|
60
|
|
|
* Remove this block when restored |
|
61
|
|
|
*/ |
|
62
|
|
|
|
|
63
|
|
|
/** @var BIGBLUEBUTTONBN_DEFAULT_SERVER_URL string of default bigbluebutton server url */ |
|
64
|
|
|
const BIGBLUEBUTTONBN_DEFAULT_SERVER_URL = 'http://test-install.blindsidenetworks.com/bigbluebutton/'; |
|
65
|
|
|
/** @var BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET string of default bigbluebutton server shared secret */ |
|
66
|
|
|
const BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET = '8cd8ef52e8e101574e400365b55e11a6'; |
|
67
|
|
|
/** @var BIGBLUEBUTTONBN_LOG_EVENT_ADD string of event add for bigbluebuttonbn_logs */ |
|
68
|
|
|
const BIGBLUEBUTTONBN_LOG_EVENT_ADD = 'Add'; |
|
69
|
|
|
/** @var BIGBLUEBUTTONBN_LOG_EVENT_EDIT string of event edit for bigbluebuttonbn_logs */ |
|
70
|
|
|
const BIGBLUEBUTTONBN_LOG_EVENT_EDIT = 'Edit'; |
|
71
|
|
|
/** @var BIGBLUEBUTTONBN_LOG_EVENT_CREATE string of event create for bigbluebuttonbn_logs */ |
|
72
|
|
|
const BIGBLUEBUTTONBN_LOG_EVENT_CREATE = 'Create'; |
|
73
|
|
|
/** @var BIGBLUEBUTTONBN_LOG_EVENT_JOIN string of event join for bigbluebuttonbn_logs */ |
|
74
|
|
|
const BIGBLUEBUTTONBN_LOG_EVENT_JOIN = 'Join'; |
|
75
|
|
|
/** @var BIGBLUEBUTTONBN_LOG_EVENT_LOGOUT string of event logout for bigbluebuttonbn_logs */ |
|
76
|
|
|
const BIGBLUEBUTTONBN_LOG_EVENT_LOGOUT = 'Logout'; |
|
77
|
|
|
/** @var BIGBLUEBUTTONBN_LOG_EVENT_IMPORT string of event import for bigbluebuttonbn_logs */ |
|
78
|
|
|
const BIGBLUEBUTTONBN_LOG_EVENT_IMPORT = 'Import'; |
|
79
|
|
|
/** @var BIGBLUEBUTTONBN_LOG_EVENT_DELETE string of event delete for bigbluebuttonbn_logs */ |
|
80
|
|
|
const BIGBLUEBUTTONBN_LOG_EVENT_DELETE = 'Delete'; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Indicates API features that the forum supports. |
|
84
|
|
|
* |
|
85
|
|
|
* @uses FEATURE_IDNUMBER |
|
86
|
|
|
* @uses FEATURE_GROUPS |
|
87
|
|
|
* @uses FEATURE_GROUPINGS |
|
88
|
|
|
* @uses FEATURE_GROUPMEMBERSONLY |
|
89
|
|
|
* @uses FEATURE_MOD_INTRO |
|
90
|
|
|
* @uses FEATURE_BACKUP_MOODLE2 |
|
91
|
|
|
* @uses FEATURE_COMPLETION_TRACKS_VIEWS |
|
92
|
|
|
* @uses FEATURE_COMPLETION_HAS_RULES |
|
93
|
|
|
* @uses FEATURE_GRADE_HAS_GRADE |
|
94
|
|
|
* @uses FEATURE_GRADE_OUTCOMES |
|
95
|
|
|
* @uses FEATURE_SHOW_DESCRIPTION |
|
96
|
|
|
* @param string $feature |
|
97
|
|
|
* @return mixed True if yes (some features may use other values) |
|
98
|
|
|
*/ |
|
99
|
|
|
function bigbluebuttonbn_supports($feature) { |
|
100
|
|
|
if (!$feature) { |
|
101
|
|
|
return null; |
|
102
|
|
|
} |
|
103
|
|
|
$features = array( |
|
104
|
|
|
(string) FEATURE_IDNUMBER => true, |
|
105
|
|
|
(string) FEATURE_GROUPS => true, |
|
106
|
|
|
(string) FEATURE_GROUPINGS => true, |
|
107
|
|
|
(string) FEATURE_GROUPMEMBERSONLY => true, |
|
108
|
|
|
(string) FEATURE_MOD_INTRO => true, |
|
109
|
|
|
(string) FEATURE_BACKUP_MOODLE2 => true, |
|
110
|
|
|
(string) FEATURE_COMPLETION_TRACKS_VIEWS => true, |
|
111
|
|
|
(string) FEATURE_GRADE_HAS_GRADE => false, |
|
112
|
|
|
(string) FEATURE_GRADE_OUTCOMES => false, |
|
113
|
|
|
(string) FEATURE_SHOW_DESCRIPTION => true, |
|
114
|
|
|
); |
|
115
|
|
|
if (isset($features[(string) $feature])) { |
|
116
|
|
|
return $features[$feature]; |
|
117
|
|
|
} |
|
118
|
|
|
return null; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Given an object containing all the necessary data, |
|
123
|
|
|
* (defined by the form in mod_form.php) this function |
|
124
|
|
|
* will create a new instance and return the id number |
|
125
|
|
|
* of the new instance. |
|
126
|
|
|
* |
|
127
|
|
|
* @param object $bigbluebuttonbn An object from the form in mod_form.php |
|
128
|
|
|
* @return int The id of the newly inserted bigbluebuttonbn record |
|
129
|
|
|
*/ |
|
130
|
|
|
function bigbluebuttonbn_add_instance($bigbluebuttonbn) { |
|
131
|
|
|
global $DB; |
|
132
|
|
|
// Excecute preprocess. |
|
133
|
|
|
bigbluebuttonbn_process_pre_save($bigbluebuttonbn); |
|
134
|
|
|
// Pre-set initial values. |
|
135
|
|
|
$bigbluebuttonbn->presentation = bigbluebuttonbn_get_media_file($bigbluebuttonbn); |
|
136
|
|
|
// Insert a record. |
|
137
|
|
|
$bigbluebuttonbn->id = $DB->insert_record('bigbluebuttonbn', $bigbluebuttonbn); |
|
138
|
|
|
// Encode meetingid. |
|
139
|
|
|
$bigbluebuttonbn->meetingid = bigbluebuttonbn_encode_meetingid($bigbluebuttonbn->id); |
|
140
|
|
|
// Set the meetingid column in the bigbluebuttonbn table. |
|
141
|
|
|
$DB->set_field('bigbluebuttonbn', 'meetingid', $bigbluebuttonbn->meetingid, array('id' => $bigbluebuttonbn->id)); |
|
142
|
|
|
// Log insert action. |
|
143
|
|
|
bigbluebuttonbn_log($bigbluebuttonbn, BIGBLUEBUTTONBN_LOG_EVENT_ADD); |
|
144
|
|
|
// Complete the process. |
|
145
|
|
|
bigbluebuttonbn_process_post_save($bigbluebuttonbn); |
|
146
|
|
|
return $bigbluebuttonbn->id; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Given an object containing all the necessary data, |
|
151
|
|
|
* (defined by the form in mod_form.php) this function |
|
152
|
|
|
* will update an existing instance with new data. |
|
153
|
|
|
* |
|
154
|
|
|
* @param object $bigbluebuttonbn An object from the form in mod_form.php |
|
155
|
|
|
* @return bool Success/Fail |
|
156
|
|
|
*/ |
|
157
|
|
|
function bigbluebuttonbn_update_instance($bigbluebuttonbn) { |
|
158
|
|
|
global $DB; |
|
159
|
|
|
// Excecute preprocess. |
|
160
|
|
|
bigbluebuttonbn_process_pre_save($bigbluebuttonbn); |
|
161
|
|
|
// Pre-set initial values. |
|
162
|
|
|
$bigbluebuttonbn->id = $bigbluebuttonbn->instance; |
|
163
|
|
|
$bigbluebuttonbn->presentation = bigbluebuttonbn_get_media_file($bigbluebuttonbn); |
|
164
|
|
|
// Update a record. |
|
165
|
|
|
$DB->update_record('bigbluebuttonbn', $bigbluebuttonbn); |
|
166
|
|
|
// Get the meetingid column in the bigbluebuttonbn table. |
|
167
|
|
|
$bigbluebuttonbn->meetingid = (string)$DB->get_field('bigbluebuttonbn', 'meetingid', array('id' => $bigbluebuttonbn->id)); |
|
168
|
|
|
// Log update action. |
|
169
|
|
|
bigbluebuttonbn_log($bigbluebuttonbn, BIGBLUEBUTTONBN_LOG_EVENT_EDIT); |
|
170
|
|
|
// Complete the process. |
|
171
|
|
|
bigbluebuttonbn_process_post_save($bigbluebuttonbn); |
|
172
|
|
|
return true; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* Given an ID of an instance of this module, |
|
177
|
|
|
* this function will permanently delete the instance |
|
178
|
|
|
* and any data that depends on it. |
|
179
|
|
|
* |
|
180
|
|
|
* @param int $id Id of the module instance |
|
181
|
|
|
* |
|
182
|
|
|
* @return bool Success/Failure |
|
183
|
|
|
*/ |
|
184
|
|
|
function bigbluebuttonbn_delete_instance($id) { |
|
185
|
|
|
global $DB; |
|
186
|
|
|
$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $id)); |
|
187
|
|
|
if (!$bigbluebuttonbn) { |
|
188
|
|
|
return false; |
|
189
|
|
|
} |
|
190
|
|
|
// TODO: End the meeting if it is running. |
|
191
|
|
|
|
|
192
|
|
|
// Perform delete. |
|
193
|
|
|
if (!$DB->delete_records('bigbluebuttonbn', array('id' => $bigbluebuttonbn->id))) { |
|
194
|
|
|
return false; |
|
195
|
|
|
} |
|
196
|
|
|
if (!$DB->delete_records('event', array('modulename' => 'bigbluebuttonbn', 'instance' => $bigbluebuttonbn->id))) { |
|
197
|
|
|
return false; |
|
198
|
|
|
} |
|
199
|
|
|
// Log action performed. |
|
200
|
|
|
return bigbluebuttonbn_delete_instance_log($bigbluebuttonbn); |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* Given an ID of an instance of this module, |
|
205
|
|
|
* this function will permanently delete the data that depends on it. |
|
206
|
|
|
* |
|
207
|
|
|
* @param object $bigbluebuttonbn Id of the module instance |
|
208
|
|
|
* |
|
209
|
|
|
* @return bool Success/Failure |
|
210
|
|
|
*/ |
|
211
|
|
|
function bigbluebuttonbn_delete_instance_log($bigbluebuttonbn) { |
|
212
|
|
|
global $DB; |
|
213
|
|
|
$sql = "SELECT * FROM {bigbluebuttonbn_logs} "; |
|
214
|
|
|
$sql .= "WHERE bigbluebuttonbnid = ? AND log = ? AND ". $DB->sql_compare_text('meta') . " = ?"; |
|
215
|
|
|
$logs = $DB->get_records_sql($sql, array($bigbluebuttonbn->id, BIGBLUEBUTTONBN_LOG_EVENT_CREATE, "{\"record\":true}")); |
|
216
|
|
|
$meta = "{\"has_recordings\":" . empty($logs) ? "true" : "false" . "}"; |
|
217
|
|
|
bigbluebuttonbn_log($bigbluebuttonbn, BIGBLUEBUTTONBN_LOG_EVENT_DELETE, [], $meta); |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* Return a small object with summary information about what a |
|
222
|
|
|
* user has done with a given particular instance of this module |
|
223
|
|
|
* Used for user activity reports. |
|
224
|
|
|
* $return->time = the time they did it |
|
225
|
|
|
* $return->info = a short text description. |
|
226
|
|
|
* |
|
227
|
|
|
* @param object $course |
|
228
|
|
|
* @param object $user |
|
229
|
|
|
* @param object $mod |
|
230
|
|
|
* @param object $bigbluebuttonbn |
|
231
|
|
|
* |
|
232
|
|
|
* @return bool |
|
233
|
|
|
*/ |
|
234
|
|
|
function bigbluebuttonbn_user_outline($course, $user, $mod, $bigbluebuttonbn) { |
|
|
|
|
|
|
235
|
|
|
global $DB; |
|
236
|
|
|
$completed = $DB->count_records('bigbluebuttonbn_logs', array('courseid' => $course->id, |
|
237
|
|
|
'bigbluebuttonbnid' => $bigbluebuttonbn->id, 'userid' => $user->id, 'log' => 'Join', ), '*'); |
|
238
|
|
|
if ($completed > 0) { |
|
239
|
|
|
return fullname($user).' '.get_string('view_message_has_joined', 'bigbluebuttonbn').' '. |
|
240
|
|
|
get_string('view_message_session_for', 'bigbluebuttonbn').' '.(string) $completed.' '. |
|
241
|
|
|
get_string('view_message_times', 'bigbluebuttonbn'); |
|
242
|
|
|
} |
|
243
|
|
|
return ''; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* Print a detailed representation of what a user has done with |
|
248
|
|
|
* a given particular instance of this module, for user activity reports. |
|
249
|
|
|
* |
|
250
|
|
|
* @param object $course |
|
251
|
|
|
* @param object $user |
|
252
|
|
|
* @param object $mod |
|
253
|
|
|
* @param object $bigbluebuttonbn |
|
254
|
|
|
* |
|
255
|
|
|
* @return bool |
|
256
|
|
|
*/ |
|
257
|
|
|
function bigbluebuttonbn_user_complete($course, $user, $mod, $bigbluebuttonbn) { |
|
|
|
|
|
|
258
|
|
|
global $DB; |
|
259
|
|
|
$completed = $DB->count_records('bigbluebuttonbn_logs', array('courseid' => $course->id, |
|
260
|
|
|
'bigbluebuttonbnid' => $bigbluebuttonbn->id, 'userid' => $user->id, 'log' => 'Join', ), |
|
261
|
|
|
'*', IGNORE_MULTIPLE); |
|
262
|
|
|
return $completed > 0; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* Returns all other caps used in module. |
|
267
|
|
|
* |
|
268
|
|
|
* @return string[] |
|
269
|
|
|
*/ |
|
270
|
|
|
function bigbluebuttonbn_get_extra_capabilities() { |
|
271
|
|
|
return array('moodle/site:accessallgroups'); |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
/** |
|
275
|
|
|
* This function is used by the reset_course_userdata function in moodlelib. |
|
276
|
|
|
* @param $data the data submitted from the reset course. |
|
277
|
|
|
* @return array status array |
|
278
|
|
|
*/ |
|
279
|
|
|
function bigbluebuttonbn_reset_userdata($data) { |
|
|
|
|
|
|
280
|
|
|
// Any changes to the list of dates that needs to be rolled should be same during course restore and course reset. |
|
281
|
|
|
// See MDL-9367. |
|
282
|
|
|
return array(); |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
/** |
|
286
|
|
|
* List of view style log actions. |
|
287
|
|
|
* |
|
288
|
|
|
* @return string[] |
|
289
|
|
|
*/ |
|
290
|
|
|
function bigbluebuttonbn_get_view_actions() { |
|
291
|
|
|
return array('view', 'view all'); |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
/** |
|
295
|
|
|
* List of update style log actions. |
|
296
|
|
|
* |
|
297
|
|
|
* @return string[] |
|
298
|
|
|
*/ |
|
299
|
|
|
function bigbluebuttonbn_get_post_actions() { |
|
300
|
|
|
return array('update', 'add', 'delete'); |
|
301
|
|
|
} |
|
302
|
|
|
|
|
303
|
|
|
/** |
|
304
|
|
|
* Print an overview of all bigbluebuttonbn instances for the courses. |
|
305
|
|
|
* |
|
306
|
|
|
* @param array $courses |
|
307
|
|
|
* @param array $htmlarray Passed by reference |
|
308
|
|
|
* |
|
309
|
|
|
* @return void |
|
310
|
|
|
*/ |
|
311
|
|
|
function bigbluebuttonbn_print_overview($courses, &$htmlarray) { |
|
312
|
|
|
if (empty($courses) || !is_array($courses)) { |
|
313
|
|
|
return array(); |
|
314
|
|
|
} |
|
315
|
|
|
$bns = get_all_instances_in_courses('bigbluebuttonbn', $courses); |
|
316
|
|
|
foreach ($bns as $bn) { |
|
317
|
|
|
$now = time(); |
|
318
|
|
|
if ($bn->openingtime and (!$bn->closingtime or $bn->closingtime > $now)) { |
|
319
|
|
|
// A bigbluebuttonbn is scheduled. |
|
320
|
|
|
if (empty($htmlarray[$bn->course]['bigbluebuttonbn'])) { |
|
321
|
|
|
$htmlarray[$bn->course]['bigbluebuttonbn'] = ''; |
|
322
|
|
|
} |
|
323
|
|
|
$htmlarray[$bn->course]['bigbluebuttonbn'] = bigbluebuttonbn_print_overview_element($bn, $now); |
|
324
|
|
|
} |
|
325
|
|
|
} |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
/** |
|
329
|
|
|
* Print an overview of a bigbluebuttonbn instance. |
|
330
|
|
|
* |
|
331
|
|
|
* @param array $bigbluebuttonbn |
|
332
|
|
|
* @param int $now |
|
333
|
|
|
* |
|
334
|
|
|
* @return string |
|
335
|
|
|
*/ |
|
336
|
|
|
function bigbluebuttonbn_print_overview_element($bigbluebuttonbn, $now) { |
|
337
|
|
|
global $CFG; |
|
338
|
|
|
$start = 'started_at'; |
|
339
|
|
|
if ($bigbluebuttonbn->openingtime > $now) { |
|
340
|
|
|
$start = 'starts_at'; |
|
341
|
|
|
} |
|
342
|
|
|
$classes = ''; |
|
343
|
|
|
if ($bigbluebuttonbn->visible) { |
|
344
|
|
|
$classes = 'class="dimmed" '; |
|
345
|
|
|
} |
|
346
|
|
|
$str = '<div class="bigbluebuttonbn overview">'."\n"; |
|
347
|
|
|
$str .= ' <div class="name">'.get_string('modulename', 'bigbluebuttonbn').': '."\n"; |
|
348
|
|
|
$str .= ' <a '.$classes.'href="'.$CFG->wwwroot.'/mod/bigbluebuttonbn/view.php?id='.$bigbluebuttonbn->coursemodule. |
|
349
|
|
|
'">'.$bigbluebuttonbn->name.'</a>'."\n"; |
|
350
|
|
|
$str .= ' </div>'."\n"; |
|
351
|
|
|
$str .= ' <div class="info">'.get_string($start, 'bigbluebuttonbn').': '.userdate($bigbluebuttonbn->openingtime). |
|
352
|
|
|
'</div>'."\n"; |
|
353
|
|
|
$str .= ' <div class="info">'.get_string('ends_at', 'bigbluebuttonbn').': '.userdate($bigbluebuttonbn->closingtime) |
|
354
|
|
|
.'</div>'."\n"; |
|
355
|
|
|
$str .= '</div>'."\n"; |
|
356
|
|
|
return $str; |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
/** |
|
360
|
|
|
* Given a course_module object, this function returns any |
|
361
|
|
|
* "extra" information that may be needed when printing |
|
362
|
|
|
* this activity in a course listing. |
|
363
|
|
|
* See get_array_of_activities() in course/lib.php. |
|
364
|
|
|
* |
|
365
|
|
|
* @param object $coursemodule |
|
366
|
|
|
* |
|
367
|
|
|
* @return null|cached_cm_info |
|
368
|
|
|
*/ |
|
369
|
|
|
function bigbluebuttonbn_get_coursemodule_info($coursemodule) { |
|
370
|
|
|
global $DB; |
|
371
|
|
|
$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $coursemodule->instance), |
|
372
|
|
|
'id, name, intro, introformat'); |
|
373
|
|
|
if (!$bigbluebuttonbn) { |
|
374
|
|
|
return null; |
|
375
|
|
|
} |
|
376
|
|
|
$info = new cached_cm_info(); |
|
377
|
|
|
$info->name = $bigbluebuttonbn->name; |
|
378
|
|
|
if ($coursemodule->showdescription) { |
|
379
|
|
|
// Convert intro to html. Do not filter cached version, filters run at display time. |
|
380
|
|
|
$info->content = format_module_intro('bigbluebuttonbn', $bigbluebuttonbn, $coursemodule->id, false); |
|
381
|
|
|
} |
|
382
|
|
|
return $info; |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
/** |
|
386
|
|
|
* Runs any processes that must run before a bigbluebuttonbn insert/update. |
|
387
|
|
|
* |
|
388
|
|
|
* @param object $bigbluebuttonbn BigBlueButtonBN form data |
|
389
|
|
|
* |
|
390
|
|
|
* @return void |
|
391
|
|
|
**/ |
|
392
|
|
|
function bigbluebuttonbn_process_pre_save(&$bigbluebuttonbn) { |
|
393
|
|
|
bigbluebuttonbn_process_pre_save_instance($bigbluebuttonbn); |
|
394
|
|
|
bigbluebuttonbn_process_pre_save_checkboxes($bigbluebuttonbn); |
|
395
|
|
|
bigbluebuttonbn_process_pre_save_common($bigbluebuttonbn); |
|
396
|
|
|
$bigbluebuttonbn->participants = htmlspecialchars_decode($bigbluebuttonbn->participants); |
|
397
|
|
|
} |
|
398
|
|
|
|
|
399
|
|
|
/** |
|
400
|
|
|
* Runs process for defining the instance (insert/update). |
|
401
|
|
|
* |
|
402
|
|
|
* @param object $bigbluebuttonbn BigBlueButtonBN form data |
|
403
|
|
|
* |
|
404
|
|
|
* @return void |
|
405
|
|
|
**/ |
|
406
|
|
|
function bigbluebuttonbn_process_pre_save_instance(&$bigbluebuttonbn) { |
|
407
|
|
|
$bigbluebuttonbn->timemodified = time(); |
|
408
|
|
|
if ((integer)$bigbluebuttonbn->instance == 0) { |
|
409
|
|
|
$bigbluebuttonbn->timecreated = time(); |
|
410
|
|
|
$bigbluebuttonbn->timemodified = 0; |
|
411
|
|
|
// As it is a new activity, assign passwords. |
|
412
|
|
|
$bigbluebuttonbn->moderatorpass = bigbluebuttonbn_random_password(12); |
|
413
|
|
|
$bigbluebuttonbn->viewerpass = bigbluebuttonbn_random_password(12, $bigbluebuttonbn->moderatorpass); |
|
414
|
|
|
} |
|
415
|
|
|
} |
|
416
|
|
|
|
|
417
|
|
|
/** |
|
418
|
|
|
* Runs process for assigning default value to checkboxes. |
|
419
|
|
|
* |
|
420
|
|
|
* @param object $bigbluebuttonbn BigBlueButtonBN form data |
|
421
|
|
|
* |
|
422
|
|
|
* @return void |
|
423
|
|
|
**/ |
|
424
|
|
|
function bigbluebuttonbn_process_pre_save_checkboxes(&$bigbluebuttonbn) { |
|
425
|
|
|
if (!isset($bigbluebuttonbn->wait)) { |
|
426
|
|
|
$bigbluebuttonbn->wait = 0; |
|
427
|
|
|
} |
|
428
|
|
|
if (!isset($bigbluebuttonbn->record)) { |
|
429
|
|
|
$bigbluebuttonbn->record = 0; |
|
430
|
|
|
} |
|
431
|
|
|
if (!isset($bigbluebuttonbn->recordings_html)) { |
|
432
|
|
|
$bigbluebuttonbn->recordings_html = 0; |
|
433
|
|
|
} |
|
434
|
|
|
if (!isset($bigbluebuttonbn->recordings_deleted)) { |
|
435
|
|
|
$bigbluebuttonbn->recordings_deleted = 0; |
|
436
|
|
|
} |
|
437
|
|
|
if (!isset($bigbluebuttonbn->recordings_imported)) { |
|
438
|
|
|
$bigbluebuttonbn->recordings_imported = 0; |
|
439
|
|
|
} |
|
440
|
|
|
if (!isset($bigbluebuttonbn->recordings_preview)) { |
|
441
|
|
|
$bigbluebuttonbn->recordings_preview = 0; |
|
442
|
|
|
} |
|
443
|
|
|
} |
|
444
|
|
|
|
|
445
|
|
|
/** |
|
446
|
|
|
* Runs process for wipping common settings when 'recordings only'. |
|
447
|
|
|
* |
|
448
|
|
|
* @param object $bigbluebuttonbn BigBlueButtonBN form data |
|
449
|
|
|
* |
|
450
|
|
|
* @return void |
|
451
|
|
|
**/ |
|
452
|
|
|
function bigbluebuttonbn_process_pre_save_common(&$bigbluebuttonbn) { |
|
453
|
|
|
// Make sure common settings are removed when 'recordings only'. |
|
454
|
|
|
if ($bigbluebuttonbn->type == BIGBLUEBUTTONBN_TYPE_RECORDING_ONLY) { |
|
455
|
|
|
$bigbluebuttonbn->groupmode = 0; |
|
456
|
|
|
$bigbluebuttonbn->groupingid = 0; |
|
457
|
|
|
} |
|
458
|
|
|
} |
|
459
|
|
|
|
|
460
|
|
|
/** |
|
461
|
|
|
* Runs any processes that must be run after a bigbluebuttonbn insert/update. |
|
462
|
|
|
* |
|
463
|
|
|
* @param object $bigbluebuttonbn BigBlueButtonBN form data |
|
464
|
|
|
* |
|
465
|
|
|
* @return void |
|
466
|
|
|
**/ |
|
467
|
|
|
function bigbluebuttonbn_process_post_save(&$bigbluebuttonbn) { |
|
468
|
|
|
if (isset($bigbluebuttonbn->notification) && $bigbluebuttonbn->notification) { |
|
469
|
|
|
bigbluebuttonbn_process_post_save_notification($bigbluebuttonbn); |
|
470
|
|
|
} |
|
471
|
|
|
bigbluebuttonbn_process_post_save_event($bigbluebuttonbn); |
|
472
|
|
|
bigbluebuttonbn_process_post_save_completion($bigbluebuttonbn); |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
/** |
|
476
|
|
|
* Generates a message on insert/update which is sent to all users enrolled. |
|
477
|
|
|
* |
|
478
|
|
|
* @param object $bigbluebuttonbn BigBlueButtonBN form data |
|
479
|
|
|
* |
|
480
|
|
|
* @return void |
|
481
|
|
|
**/ |
|
482
|
|
|
function bigbluebuttonbn_process_post_save_notification(&$bigbluebuttonbn) { |
|
483
|
|
|
$action = get_string('mod_form_field_notification_msg_modified', 'bigbluebuttonbn'); |
|
484
|
|
|
if (isset($bigbluebuttonbn->add) && !empty($bigbluebuttonbn->add)) { |
|
485
|
|
|
$action = get_string('mod_form_field_notification_msg_created', 'bigbluebuttonbn'); |
|
486
|
|
|
} |
|
487
|
|
|
$context = context_course::instance($bigbluebuttonbn->course); |
|
488
|
|
|
\mod_bigbluebuttonbn\locallib\notifier::notification_process($context, $bigbluebuttonbn, $action); |
|
489
|
|
|
} |
|
490
|
|
|
|
|
491
|
|
|
/** |
|
492
|
|
|
* Generates an event after a bigbluebuttonbn insert/update. |
|
493
|
|
|
* |
|
494
|
|
|
* @param object $bigbluebuttonbn BigBlueButtonBN form data |
|
495
|
|
|
* |
|
496
|
|
|
* @return void |
|
497
|
|
|
**/ |
|
498
|
|
|
function bigbluebuttonbn_process_post_save_event(&$bigbluebuttonbn) { |
|
499
|
|
|
global $DB; |
|
500
|
|
|
$eventid = $DB->get_field('event', 'id', array('modulename' => 'bigbluebuttonbn', |
|
501
|
|
|
'instance' => $bigbluebuttonbn->id)); |
|
502
|
|
|
// Delete the event from calendar when/if openingtime is NOT set. |
|
503
|
|
|
if (!isset($bigbluebuttonbn->openingtime) || !$bigbluebuttonbn->openingtime) { |
|
504
|
|
|
if ($eventid) { |
|
505
|
|
|
$calendarevent = calendar_event::load($eventid); |
|
506
|
|
|
$calendarevent->delete(); |
|
507
|
|
|
} |
|
508
|
|
|
return; |
|
509
|
|
|
} |
|
510
|
|
|
// Add evento to the calendar as openingtime is set. |
|
511
|
|
|
$event = new stdClass(); |
|
512
|
|
|
$event->eventtype = BIGBLUEBUTTON_EVENT_MEETING_START; |
|
513
|
|
|
$event->type = CALENDAR_EVENT_TYPE_ACTION; |
|
514
|
|
|
$event->name = $bigbluebuttonbn->name . ' (' . get_string('starts_at', 'bigbluebuttonbn') . ')'; |
|
515
|
|
|
$event->description = format_module_intro('bigbluebuttonbn', $bigbluebuttonbn, $bigbluebuttonbn->coursemodule); |
|
516
|
|
|
$event->courseid = $bigbluebuttonbn->course; |
|
517
|
|
|
$event->groupid = 0; |
|
518
|
|
|
$event->userid = 0; |
|
519
|
|
|
$event->modulename = 'bigbluebuttonbn'; |
|
520
|
|
|
$event->instance = $bigbluebuttonbn->id; |
|
521
|
|
|
$event->timestart = $bigbluebuttonbn->openingtime; |
|
522
|
|
|
$event->timeduration = 0; |
|
523
|
|
|
if ($bigbluebuttonbn->closingtime) { |
|
524
|
|
|
$event->timeduration = $bigbluebuttonbn->closingtime - $bigbluebuttonbn->openingtime; |
|
525
|
|
|
} |
|
526
|
|
|
$event->timesort = $event->timestart + $event->timeduration; |
|
527
|
|
|
$event->visible = instance_is_visible('bigbluebuttonbn', $bigbluebuttonbn); |
|
528
|
|
|
$event->priority = null; |
|
529
|
|
|
// Update the event in calendar when/if eventid was found. |
|
530
|
|
|
if ($eventid) { |
|
531
|
|
|
$event->id = $eventid; |
|
532
|
|
|
$calendarevent = calendar_event::load($eventid); |
|
533
|
|
|
$calendarevent->update($event); |
|
534
|
|
|
return; |
|
535
|
|
|
} |
|
536
|
|
|
calendar_event::create($event); |
|
537
|
|
|
} |
|
538
|
|
|
|
|
539
|
|
|
function bigbluebuttonbn_process_post_save_completion($bigbluebuttonbn) { |
|
540
|
|
|
if (!empty($bigbluebuttonbn->completionexpected)) { |
|
541
|
|
|
\core_completion\api::update_completion_date_event( |
|
542
|
|
|
$bigbluebuttonbn->coursemodule, |
|
543
|
|
|
'bigbluebuttonbn', |
|
544
|
|
|
$bigbluebuttonbn->id, $bigbluebuttonbn->completionexpected |
|
545
|
|
|
); |
|
546
|
|
|
} |
|
547
|
|
|
} |
|
548
|
|
|
/** |
|
549
|
|
|
* Get a full path to the file attached as a preuploaded presentation |
|
550
|
|
|
* or if there is none, set the presentation field will be set to blank. |
|
551
|
|
|
* |
|
552
|
|
|
* @param object $bigbluebuttonbn BigBlueButtonBN form data |
|
553
|
|
|
* |
|
554
|
|
|
* @return string |
|
555
|
|
|
*/ |
|
556
|
|
|
function bigbluebuttonbn_get_media_file(&$bigbluebuttonbn) { |
|
557
|
|
|
if (!isset($bigbluebuttonbn->presentation) || $bigbluebuttonbn->presentation == '') { |
|
558
|
|
|
return ''; |
|
559
|
|
|
} |
|
560
|
|
|
$context = context_module::instance($bigbluebuttonbn->coursemodule); |
|
561
|
|
|
// Set the filestorage object. |
|
562
|
|
|
$fs = get_file_storage(); |
|
563
|
|
|
// Save the file if it exists that is currently in the draft area. |
|
564
|
|
|
file_save_draft_area_files($bigbluebuttonbn->presentation, $context->id, 'mod_bigbluebuttonbn', 'presentation', 0); |
|
565
|
|
|
// Get the file if it exists. |
|
566
|
|
|
$files = $fs->get_area_files($context->id, 'mod_bigbluebuttonbn', 'presentation', 0, |
|
567
|
|
|
'itemid, filepath, filename', false); |
|
568
|
|
|
// Check that there is a file to process. |
|
569
|
|
|
$filesrc = ''; |
|
570
|
|
|
if (count($files) == 1) { |
|
571
|
|
|
// Get the first (and only) file. |
|
572
|
|
|
$file = reset($files); |
|
573
|
|
|
$filesrc = '/'.$file->get_filename(); |
|
574
|
|
|
} |
|
575
|
|
|
return $filesrc; |
|
576
|
|
|
} |
|
577
|
|
|
|
|
578
|
|
|
/** |
|
579
|
|
|
* Serves the bigbluebuttonbn attachments. Implements needed access control ;-). |
|
580
|
|
|
* |
|
581
|
|
|
* @category files |
|
582
|
|
|
* |
|
583
|
|
|
* @param stdClass $course course object |
|
584
|
|
|
* @param stdClass $cm course module object |
|
585
|
|
|
* @param stdClass $context context object |
|
586
|
|
|
* @param string $filearea file area |
|
587
|
|
|
* @param array $args extra arguments |
|
588
|
|
|
* @param bool $forcedownload whether or not force download |
|
589
|
|
|
* @param array $options additional options affecting the file serving |
|
590
|
|
|
* |
|
591
|
|
|
* @return false|null false if file not found, does not return if found - justsend the file |
|
592
|
|
|
*/ |
|
593
|
|
|
function bigbluebuttonbn_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) { |
|
594
|
|
|
if (!bigbluebuttonbn_pluginfile_valid($context, $filearea)) { |
|
595
|
|
|
return false; |
|
596
|
|
|
} |
|
597
|
|
|
$file = bigbluebuttonbn_pluginfile_file($course, $cm, $context, $filearea, $args); |
|
598
|
|
|
if (empty($file)) { |
|
599
|
|
|
return false; |
|
600
|
|
|
} |
|
601
|
|
|
// Finally send the file. |
|
602
|
|
|
send_stored_file($file, 0, 0, $forcedownload, $options); // download MUST be forced - security! |
|
603
|
|
|
} |
|
604
|
|
|
|
|
605
|
|
|
/** |
|
606
|
|
|
* Helper for validating pluginfile. |
|
607
|
|
|
* @param stdClass $context context object |
|
608
|
|
|
* @param string $filearea file area |
|
609
|
|
|
* |
|
610
|
|
|
* @return false|null false if file not valid |
|
611
|
|
|
*/ |
|
612
|
|
|
function bigbluebuttonbn_pluginfile_valid($context, $filearea) { |
|
613
|
|
|
if ($context->contextlevel != CONTEXT_MODULE) { |
|
614
|
|
|
return false; |
|
615
|
|
|
} |
|
616
|
|
|
if ($filearea !== 'presentation') { |
|
617
|
|
|
return false; |
|
618
|
|
|
} |
|
619
|
|
|
if (!array_key_exists($filearea, bigbluebuttonbn_get_file_areas())) { |
|
620
|
|
|
return false; |
|
621
|
|
|
} |
|
622
|
|
|
return true; |
|
623
|
|
|
} |
|
624
|
|
|
|
|
625
|
|
|
/** |
|
626
|
|
|
* Helper for getting pluginfile. |
|
627
|
|
|
* |
|
628
|
|
|
* @param stdClass $course course object |
|
629
|
|
|
* @param stdClass $cm course module object |
|
630
|
|
|
* @param stdClass $context context object |
|
631
|
|
|
* @param string $filearea file area |
|
632
|
|
|
* @param array $args extra arguments |
|
633
|
|
|
* |
|
634
|
|
|
* @return object |
|
635
|
|
|
*/ |
|
636
|
|
|
function bigbluebuttonbn_pluginfile_file($course, $cm, $context, $filearea, $args) { |
|
637
|
|
|
$filename = bigbluebuttonbn_pluginfile_filename($course, $cm, $context, $args); |
|
638
|
|
|
if (!$filename) { |
|
|
|
|
|
|
639
|
|
|
return false; |
|
640
|
|
|
} |
|
641
|
|
|
$fullpath = "/$context->id/mod_bigbluebuttonbn/$filearea/0/".$filename; |
|
642
|
|
|
$fs = get_file_storage(); |
|
643
|
|
|
$file = $fs->get_file_by_hash(sha1($fullpath)); |
|
644
|
|
|
if (!$file || $file->is_directory()) { |
|
645
|
|
|
return false; |
|
646
|
|
|
} |
|
647
|
|
|
return $file; |
|
648
|
|
|
} |
|
649
|
|
|
|
|
650
|
|
|
/** |
|
651
|
|
|
* Helper for getting pluginfile name. |
|
652
|
|
|
* |
|
653
|
|
|
* @param stdClass $course course object |
|
654
|
|
|
* @param stdClass $cm course module object |
|
655
|
|
|
* @param stdClass $context context object |
|
656
|
|
|
* @param array $args extra arguments |
|
657
|
|
|
* |
|
658
|
|
|
* @return array |
|
659
|
|
|
*/ |
|
660
|
|
|
function bigbluebuttonbn_pluginfile_filename($course, $cm, $context, $args) { |
|
661
|
|
|
global $DB; |
|
662
|
|
|
if (count($args) > 1) { |
|
663
|
|
|
if (!$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $cm->instance))) { |
|
664
|
|
|
return; |
|
665
|
|
|
} |
|
666
|
|
|
$cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'presentation_cache'); |
|
667
|
|
|
$noncekey = sha1($bigbluebuttonbn->id); |
|
668
|
|
|
$presentationnonce = $cache->get($noncekey); |
|
669
|
|
|
$noncevalue = $presentationnonce['value']; |
|
670
|
|
|
$noncecounter = $presentationnonce['counter']; |
|
671
|
|
|
if ($args['0'] != $noncevalue) { |
|
672
|
|
|
return; |
|
673
|
|
|
} |
|
674
|
|
|
// The nonce value is actually used twice because BigBlueButton reads the file two times. |
|
675
|
|
|
$noncecounter += 1; |
|
676
|
|
|
$cache->set($noncekey, array('value' => $noncevalue, 'counter' => $noncecounter)); |
|
677
|
|
|
if ($noncecounter == 2) { |
|
678
|
|
|
$cache->delete($noncekey); |
|
679
|
|
|
} |
|
680
|
|
|
return $args['1']; |
|
681
|
|
|
} |
|
682
|
|
|
require_course_login($course, true, $cm); |
|
683
|
|
|
if (!has_capability('mod/bigbluebuttonbn:join', $context)) { |
|
684
|
|
|
return; |
|
685
|
|
|
} |
|
686
|
|
|
return implode('/', $args); |
|
687
|
|
|
} |
|
688
|
|
|
|
|
689
|
|
|
/** |
|
690
|
|
|
* Returns an array of file areas. |
|
691
|
|
|
* |
|
692
|
|
|
* @category files |
|
693
|
|
|
* |
|
694
|
|
|
* @return array a list of available file areas |
|
695
|
|
|
*/ |
|
696
|
|
|
function bigbluebuttonbn_get_file_areas() { |
|
697
|
|
|
$areas = array(); |
|
698
|
|
|
$areas['presentation'] = get_string('mod_form_block_presentation', 'bigbluebuttonbn'); |
|
699
|
|
|
return $areas; |
|
700
|
|
|
} |
|
701
|
|
|
|
|
702
|
|
|
/** |
|
703
|
|
|
* Mark the activity completed (if required) and trigger the course_module_viewed event. |
|
704
|
|
|
* |
|
705
|
|
|
* @param stdClass $bigbluebuttonbn bigbluebuttonbn object |
|
706
|
|
|
* @param stdClass $course course object |
|
707
|
|
|
* @param stdClass $cm course module object |
|
708
|
|
|
* @param stdClass $context context object |
|
709
|
|
|
* @since Moodle 3.0 |
|
710
|
|
|
*/ |
|
711
|
|
|
function bigbluebuttonbn_view($bigbluebuttonbn, $course, $cm, $context) { |
|
712
|
|
|
|
|
713
|
|
|
// Trigger course_module_viewed event. |
|
714
|
|
|
$params = array( |
|
715
|
|
|
'context' => $context, |
|
716
|
|
|
'objectid' => $bigbluebuttonbn->id |
|
717
|
|
|
); |
|
718
|
|
|
|
|
719
|
|
|
$event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_activity_viewed::create($params); |
|
720
|
|
|
$event->add_record_snapshot('course_modules', $cm); |
|
721
|
|
|
$event->add_record_snapshot('course', $course); |
|
722
|
|
|
$event->add_record_snapshot('bigbluebuttonbn', $bigbluebuttonbn); |
|
723
|
|
|
$event->trigger(); |
|
724
|
|
|
|
|
725
|
|
|
// Completion. |
|
726
|
|
|
$completion = new completion_info($course); |
|
727
|
|
|
$completion->set_module_viewed($cm); |
|
728
|
|
|
} |
|
729
|
|
|
|
|
730
|
|
|
/** |
|
731
|
|
|
* Check if the module has any update that affects the current user since a given time. |
|
732
|
|
|
* |
|
733
|
|
|
* @param cm_info $cm course module data |
|
734
|
|
|
* @param int $from the time to check updates from |
|
735
|
|
|
* @param array $filter if we need to check only specific updates |
|
736
|
|
|
* @return stdClass an object with the different type of areas indicating if they were updated or not |
|
737
|
|
|
* @since Moodle 3.2 |
|
738
|
|
|
*/ |
|
739
|
|
|
function bigbluebuttonbn_check_updates_since(cm_info $cm, $from, $filter = array()) { |
|
740
|
|
|
$updates = course_check_module_updates_since($cm, $from, array('content'), $filter); |
|
741
|
|
|
return $updates; |
|
742
|
|
|
} |
|
743
|
|
|
|
|
744
|
|
|
/** |
|
745
|
|
|
* This function receives a calendar event and returns the action associated with it, or null if there is none. |
|
746
|
|
|
* |
|
747
|
|
|
* This is used by block_myoverview in order to display the event appropriately. If null is returned then the event |
|
748
|
|
|
* is not displayed on the block. |
|
749
|
|
|
* |
|
750
|
|
|
* @param calendar_event $event |
|
751
|
|
|
* @param \core_calendar\action_factory $factory |
|
752
|
|
|
* @return \core_calendar\local\event\entities\action_interface|null |
|
753
|
|
|
*/ |
|
754
|
|
|
function mod_bigbluebuttonbn_core_calendar_provide_event_action(calendar_event $event, |
|
755
|
|
|
\core_calendar\action_factory $factory) { |
|
756
|
|
|
$cm = get_fast_modinfo($event->courseid)->instances['bigbluebuttonbn'][$event->instance]; |
|
757
|
|
|
|
|
758
|
|
|
$completion = new \completion_info($cm->get_course()); |
|
759
|
|
|
|
|
760
|
|
|
$completiondata = $completion->get_data($cm, false); |
|
761
|
|
|
|
|
762
|
|
|
if ($completiondata->completionstate != COMPLETION_INCOMPLETE) { |
|
763
|
|
|
return null; |
|
764
|
|
|
} |
|
765
|
|
|
|
|
766
|
|
|
return $factory->create_instance( |
|
767
|
|
|
get_string('view'), |
|
768
|
|
|
new \mod_bigbluebuttonbn('/mod/bigbluebuttonbn/view.php', ['id' => $cm->id]), |
|
769
|
|
|
1, |
|
770
|
|
|
true |
|
771
|
|
|
); |
|
772
|
|
|
} |
|
773
|
|
|
|
|
774
|
|
|
/** |
|
775
|
|
|
* Get icon mapping for font-awesome. |
|
776
|
|
|
*/ |
|
777
|
|
|
function mod_bigbluebuttonbn_get_fontawesome_icon_map() { |
|
778
|
|
|
return [ |
|
779
|
|
|
'mod_bigbluebuttonbn:i/bigbluebutton' => 'fa-bigbluebutton', |
|
780
|
|
|
]; |
|
781
|
|
|
} |
|
782
|
|
|
|
|
783
|
|
|
/** |
|
784
|
|
|
* This function receives a calendar event and returns the action associated with it, or null if there is none. |
|
785
|
|
|
* |
|
786
|
|
|
* This is used by block_myoverview in order to display the event appropriately. If null is returned then the event |
|
787
|
|
|
* is not displayed on the block. |
|
788
|
|
|
* |
|
789
|
|
|
* @param calendar_event $event |
|
790
|
|
|
* @param \core_calendar\action_factory $factory |
|
791
|
|
|
* @return \core_calendar\local\event\entities\action_interface|null |
|
792
|
|
|
*/ |
|
793
|
|
|
function mod_bigbluebuttonbn_core_calendar_provide_event_action(calendar_event $event, |
|
|
|
|
|
|
794
|
|
|
\core_calendar\action_factory $factory) { |
|
795
|
|
|
global $CFG, $DB; |
|
796
|
|
|
|
|
797
|
|
|
require_once($CFG->dirroot . '/mod/bigbluebuttonbn/locallib.php'); |
|
798
|
|
|
|
|
799
|
|
|
$cm = get_fast_modinfo($event->courseid)->instances['bigbluebuttonbn'][$event->instance]; |
|
800
|
|
|
|
|
801
|
|
|
// Check that the bigbluebuttonbn activity is open. |
|
802
|
|
|
$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $event->instance), '*', MUST_EXIST); |
|
803
|
|
|
$actionable = bigbluebuttonbn_get_availability_status($bigbluebuttonbn); |
|
804
|
|
|
|
|
805
|
|
|
$string = get_string('view_room', 'bigbluebuttonbn'); |
|
806
|
|
|
$url = new \moodle_url('/mod/bigbluebuttonbn/view.php', array('id' => $cm->id)); |
|
807
|
|
|
if (groups_get_activity_groupmode($cm) == NOGROUPS) { |
|
808
|
|
|
// No groups mode. |
|
809
|
|
|
$string = get_string('view_conference_action_join', 'bigbluebuttonbn'); |
|
810
|
|
|
$url = new \moodle_url('/mod/bigbluebuttonbn/view.php', array('id' => $cm->id)); |
|
811
|
|
|
} |
|
812
|
|
|
|
|
813
|
|
|
return $factory->create_instance($string, $url, 1, $actionable); |
|
814
|
|
|
} |
|
815
|
|
|
|
|
816
|
|
|
/** |
|
817
|
|
|
* Register a bigbluebuttonbn event |
|
818
|
|
|
* |
|
819
|
|
|
* @param object $bigbluebuttonbn |
|
820
|
|
|
* @param string $event |
|
821
|
|
|
* @param array $overrides |
|
822
|
|
|
* @param string $meta |
|
823
|
|
|
* |
|
824
|
|
|
* @return bool Success/Failure |
|
825
|
|
|
*/ |
|
826
|
|
|
function bigbluebuttonbn_log($bigbluebuttonbn, $event, array $overrides = [], $meta = null) { |
|
827
|
|
|
global $DB, $USER; |
|
828
|
|
|
$log = new stdClass(); |
|
829
|
|
|
// Default values. |
|
830
|
|
|
$log->courseid = $bigbluebuttonbn->course; |
|
831
|
|
|
$log->bigbluebuttonbnid = $bigbluebuttonbn->id; |
|
832
|
|
|
$log->userid = $USER->id; |
|
833
|
|
|
$log->meetingid = $bigbluebuttonbn->meetingid; |
|
834
|
|
|
$log->timecreated = time(); |
|
835
|
|
|
$log->log = $event; |
|
836
|
|
|
$log->meta = $meta; |
|
837
|
|
|
// Overrides. |
|
838
|
|
|
foreach ($overrides as $key => $value) { |
|
839
|
|
|
$log->$key = $value; |
|
840
|
|
|
} |
|
841
|
|
|
if ($DB->insert_record('bigbluebuttonbn_logs', $log)) { |
|
842
|
|
|
return true; |
|
843
|
|
|
} |
|
844
|
|
|
return false; |
|
845
|
|
|
} |
|
846
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.