-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.php
More file actions
executable file
·783 lines (672 loc) · 23.5 KB
/
lib.php
File metadata and controls
executable file
·783 lines (672 loc) · 23.5 KB
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
<?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/>.
/**
* Library of interface functions and constants for module clickmeeting
*
* All the core Moodle functions, neeeded to allow the module to work
* integrated in Moodle should be placed here.
* All the clickmeeting specific functions, needed to implement all the module
* logic, should go to locallib.php. This will help to save some memory when
* Moodle is performing actions across all modules.
*
* @package mod_clickmeeting
* @copyright 2024 Clickmeeting
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$clickmeetingauthtypes = [
'1' => 'open',
'2' => 'password',
'3' => 'token',
];
/**
* Returns the information on whether the module supports a feature
*
* @see plugin_supports() in lib/moodlelib.php
* @param string $feature FEATURE_xx constant for requested feature
* @return mixed true if the feature is supported, null if unknown
*/
function clickmeeting_supports($feature) {
switch ($feature) {
case FEATURE_BACKUP_MOODLE2:
return true;
case FEATURE_MOD_INTRO:
return false;
default:
return null;
}
}
/**
* Returns random string
*
* @param int $length Strings length
* @return string Generated string
*/
function clickmeeting_get_random_string($length = 6) {
return substr(md5(rand()), 0, $length);
}
/**
* Checks if time slot is available
*
* @param string $starttime
* @param int $duration
* @param int $id
* @return boolean
*/
function clickmeeting_check_conference_availability($starttime, $duration, $id = 0) {
$apiurl = get_config('clickmeeting', 'apiurl');
$datetime = new DateTime($starttime);
$utctimezone = new DateTimeZone('UTC');
$datetime->setTimezone($utctimezone);
$starttime = $datetime->format('Y-m-d H:i:s');
$params = [
'start_time' => $starttime,
'duration' => $duration,
'id' => $id,
];
$curl = clickmeeting_init_curl();
$curl->post($apiurl.'conference/availability', $params);
return 200 === $curl->get_info()['http_code'];
}
/**
*
* @return string
*/
function clickmeeting_get_api_key() {
global $DB, $CFG, $USER;
require_once($CFG->dirroot.'/user/profile/lib.php');
$user = $DB->get_record('user', ['id' => $USER->id]);
profile_load_data($user);
if (isset($user->profile_field_clickmeetingapikey) && !empty($user->profile_field_clickmeetingapikey)) {
return $user->profile_field_clickmeetingapikey;
}
return get_config('clickmeeting', 'apikey');
}
/**3
* Returns api results
*
* @param array $params
* @return string
*/
function clickmeeting_add_conference($params) {
$apiurl = get_config('clickmeeting', 'apiurl');
$curlhandle = clickmeeting_init_curl();
$result = $curlhandle->post($apiurl.'conferences', $params);
return $result;
}
/**
* Returns api results
*
* @param int $conferenceid
* @param array $params
* @return string
*/
function clickmeeting_edit_conference($conferenceid, $params) {
$apiurl = get_config('clickmeeting', 'apiurl');
$curlhandle = clickmeeting_init_curl();
$result = $curlhandle->put($apiurl.'conferences/'.$conferenceid, [], ['CURLOPT_POSTFIELDS' => http_build_query($params, '', '&')]);
return $result;
}
/**
* Returns api results
*
* @param int $conferenceid
* @param string $title
* @return string
*/
function clickmeeting_edit_conference_title($conferenceid, $title) {
$apiurl = get_config('clickmeeting', 'apiurl');
$params = [
'name' => $title,
];
$curlhandle = clickmeeting_init_curl();
$result = $curlhandle->put($apiurl.'conferences/'.$conferenceid, [], ['CURLOPT_POSTFIELDS' => http_build_query($params, '', '&')]);
return $result;
}
/**
* Returns api results
*
* @param int $conferenceid
* @return string
*/
function clickmeeting_delete_conference($conferenceid) {
$apiurl = get_config('clickmeeting', 'apiurl');
$curlhandle = clickmeeting_init_curl();
$result = $curlhandle->delete($apiurl.'conferences/'.$conferenceid);
return $result;
}
/**
* Returns access tokens
*
* @param int $roomid
* @return string
*/
function clickmeeting_generate_token($roomid) {
$apiurl = get_config('clickmeeting', 'apiurl');
$params = [];
$params['how_many'] = 1;
$curlhandle = clickmeeting_init_curl();
$result = $curlhandle->post($apiurl.'conferences/'.$roomid.'/tokens', $params);
$decoder = json_decode($result, true);
return $decoder['access_tokens'][0]['token'];
}
/**
* Checks if conference is password protected
*
* @param stdClass $clickmeeting
* @return boolean
*/
function clickmeeting_is_token_protected(stdClass $clickmeeting) {
return in_array($clickmeeting->access_type, [3, 'token']);
}
/**
* Checks if conference is password protected
*
* @param stdClass $clickmeeting
* @return boolean
*/
function clickmeeting_is_password_protected(stdClass $clickmeeting) {
return in_array($clickmeeting->access_type, [2, 'password']);
}
/**
* Returns api results
*
* @param int $roomid
* @param string $email
* @param string $nickname
* @param string $role
* @param string $auth
* @param string $authtype
* @return string
*/
function clickmeeting_get_login_url($roomid, $email, $nickname, $role, $auth, $authtype) {
global $clickmeetingauthtypes;
$apiurl = get_config('clickmeeting', 'apiurl');
$params = [];
$params['email'] = $email;
$params['nickname'] = $nickname;
$params['role'] = $role;
if ('1' !== $authtype) {
$params[$clickmeetingauthtypes[$authtype]] = $auth;
}
$curlhandle = clickmeeting_init_curl();
$result = $curlhandle->post($apiurl.'conferences/'.$roomid.'/room/autologin_hash', $params);
$decoded = json_decode($result, true);
return !empty($decoded['autologin_hash'])
? $decoded['autologin_hash']
: '';
}
/**
* Checks if attendee could join conference
*
* @param string $roomid
* @return boolean
*/
function clickmeeting_is_room_historical($roomid) {
$apiurl = get_config('clickmeeting', 'apiurl');
$curlhandle = clickmeeting_init_curl();
$result = $curlhandle->get($apiurl . 'conferences/' . $roomid);
$response = json_decode($result, true);
if (!empty($response['code']) && '404' === $response['code']) {
return true;
}
if (empty($response['conference'])) {
return true;
}
return 'inactive' === $response['conference']['status'];
}
/**
* Saves a new instance of the clickmeeting into the database
*
* Given an object containing all the necessary data,
* (defined by the form in mod_form.php) this function
* will create a new instance and return the id number
* of the new instance.
*
* @param stdClass $clickmeeting
* @param mod_clickmeeting_mod_form|null $mform
* @return int The id of the newly inserted clickmeeting record
*/
function clickmeeting_add_instance(stdClass $clickmeeting, mod_clickmeeting_mod_form $mform = null) {
global $DB, $COURSE, $USER;
global $clickmeetingowner;
$clickmeetingowner = $USER->id;
$section = required_param('section', PARAM_INT);
$cw = get_fast_modinfo($COURSE)->get_section_info($section);
$clickmeeting->timecreated = time();
$clickmeeting->timemodified = time();
$clickmeeting->start_time = date('Y-m-d H:i:s', $clickmeeting->timestart);
$clickmeeting->user_id = $USER->id;
if (!clickmeeting_check_conference_availability($clickmeeting->start_time, $clickmeeting->duration)) {
throw new \moodle_exception('startdate_booked', 'clickmeeting');
}
$transaction = $DB->start_delegated_transaction();
$result = $DB->insert_record('clickmeeting', $clickmeeting);
if (false != $result) {
$password = clickmeeting_generate_password(8);
$params = [];
$timezone = date_default_timezone_get();
$params['name'] = $clickmeeting->name;
$params['room_type'] = $clickmeeting->room_type;
$params['permanent_room'] = '0';
$params['access_type'] = $clickmeeting->access_type;
$params['lobby_description'] = $clickmeeting->lobby_msg;
$params['starts_at'] = $clickmeeting->start_time;
$params['duration'] = $clickmeeting->duration;
$params['timezone'] = $timezone;
$params['password'] = $password;
$r = json_decode(clickmeeting_add_conference($params), true);
$error = '';
if (!empty($r['code'])) {
foreach ($r['errors'] as $err) {
$error .= $err['message'].'<br />';
}
throw new \moodle_exception($error, 'error');
}
if (isset($r['room'])) {
$r = $r['room'];
// insert info about new conference into database
$conference = new stdClass();
$conference->clickmeeting_id = $result;
$conference->conference_id = $r['id'];
$conference->room_url = $r['room_url'];
$conference->embed_room = $r['embed_room_url'];
$conference->room_pin = $r['room_pin'];
$conference->password = $password;
$DB->insert_record('clickmeeting_conferences', $conference);
}
$transaction->allow_commit();
}
return $result;
}
/**
* Updates an instance of the clickmeeting in the database
*
* Given an object containing all the necessary data,
* (defined by the form in mod_form.php) this function
* will update an existing instance with new data.
*
* @param stdClass $clickmeeting
* @param mod_clickmeeting_mod_form|null $mform
* @return boolean
*/
function clickmeeting_update_instance(stdClass $clickmeeting, mod_clickmeeting_mod_form $mform = null) {
global $DB, $COURSE, $USER, $clickmeetingowner;
$section = required_param('section', PARAM_INT);
$cw = get_fast_modinfo($COURSE)->get_section_info($section);
$timezone = date_default_timezone_get();
$transaction = $DB->start_delegated_transaction();
$clickmeeting->timemodified = time();
$clickmeeting->id = $clickmeeting->instance;
$clickmeeting->start_time = date('Y-m-d H:i:s', $clickmeeting->timestart);
$clickmeetingowner = $clickmeeting->user_id;
$conference = $DB->get_record('clickmeeting_conferences', ['clickmeeting_id' => $clickmeeting->id]);
if (!clickmeeting_check_conference_availability($clickmeeting->start_time, $clickmeeting->duration, $conference->conference_id)) {
throw new \moodle_exception('startdate_booked', 'clickmeeting');
}
if (!$DB->update_record('clickmeeting', $clickmeeting)) {
throw new \moodle_exception('update_error', 'clickmeeting');
}
$params['name'] = $clickmeeting->name;
$params['room_type'] = $clickmeeting->room_type;
$params['duration'] = $clickmeeting->duration;
$params['permanent_room'] = '0';
$params['access_type'] = $clickmeeting->access_type;
$params['lobby_description'] = $clickmeeting->lobby_msg;
$params['starts_at'] = $clickmeeting->start_time;
$params['timezone'] = $timezone;
$params['password'] = $conference->password;
if (clickmeeting_is_room_historical($conference->conference_id)) {
$r = json_decode(clickmeeting_add_conference($params), true);
if (isset($r['room'])) {
$r = $r['room'];
$conference->conference_id = $r['id'];
$conference->room_url = $r['room_url'];
$conference->embed_room = $r['embed_room_url'];
$conference->room_pin = $r['room_pin'];
$DB->update_record('clickmeeting_conferences', $conference);
}
} else {
$r = json_decode(clickmeeting_edit_conference($conference->conference_id, $params), true);
}
if (!empty($r['code'])) {
$error = '';
foreach ($r['errors'] as $err) {
$error .= $err['message'].'<br />';
}
throw new \moodle_exception($error, 'error');
}
$transaction->allow_commit();
return true;
}
/**
* Removes an instance of the clickmeeting from the database
*
* Given an ID of an instance of this module,
* this function will permanently delete the instance
* and any data that depends on it.
*
* @param int $id Id of the module instance
* @return boolean Success/Failure
*/
function clickmeeting_delete_instance($id) {
global $DB, $COURSE, $clickmeetingowner;
if (! $clickmeeting = $DB->get_record('clickmeeting', ['id' => $id])) {
return false;
}
$clickmeetingowner = $clickmeeting->user_id;
if (0 < $DB->count_records('clickmeeting_conferences', ['clickmeeting_id' => $clickmeeting->id])) {
$conferenceid = $DB->get_field('clickmeeting_conferences', 'conference_id', ['clickmeeting_id' => $clickmeeting->id]);
} else {
return false;
}
$apiresult = clickmeeting_delete_conference($conferenceid);
if ('"200 OK"' != $apiresult) {
// jezeli nie znajdujemy conferencji w clickmeetingu to nie trzeba jej tam usuwac
if ('"404 Not Found"' == $apiresult) {
throw new \moodle_exception('api_404_error', 'clickmeeting');
}
}
if (0 < $DB->count_records('clickmeeting_conferences', ['clickmeeting_id' => $clickmeeting->id])) {
$DB->delete_records('clickmeeting_conferences', ['clickmeeting_id' => $clickmeeting->id]);
}
$DB->delete_records('clickmeeting', ['id' => $clickmeeting->id]);
return true;
}
/**
* Returns a small object with summary information about what a
* user has done with a given particular instance of this module
* Used for user activity reports.
* $return->time = the time they did it
* $return->info = a short text description
*
* @return stdClass|null
*/
function clickmeeting_user_outline() {
$return = new stdClass();
$return->time = 0;
$return->info = '';
return $return;
}
/**
* Prints a detailed representation of what a user has done with
* a given particular instance of this module, for user activity reports.
*
* @param stdClass $course the current course record
* @param stdClass $user the record of the user we are generating report for
* @param cm_info $mod course module info
* @param stdClass $clickmeeting the module instance record
*/
function clickmeeting_user_complete($course, $user, $mod, $clickmeeting) {
}
/**
* Given a course and a time, this module should find recent activity
* that has occurred in clickmeeting activities and print it out.
* Return true if there was output, or false is there was none.
*
* @return boolean
*/
function clickmeeting_print_recent_activity() {
return false; // True if anything was printed, otherwise false
}
/**
* Prepares the recent activity data
*
* This callback function is supposed to populate the passed array with
* custom activity records. These records are then rendered into HTML via
* {@see clickmeeting_print_recent_mod_activity}.
*
* @param array $activities sequentially indexed array of objects with the 'cmid' property
* @param int $index the index in the $activities to use for the next record
* @param int $timestart append activity since this time
* @param int $courseid the id of the course we produce the report for
* @param int $cmid course module id
* @param int|null $userid check for a particular user's activity only, defaults to 0 (all users)
* @param int|null $groupid check for a particular group's activity only, defaults to 0 (all groups)
*/
function clickmeeting_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid = 0, $groupid = 0) {
}
/**
* Prints single activity item prepared by {@see clickmeeting_get_recent_mod_activity}
*
* @param string $activity
* @param int $courseid the id of the course we produce the report for
* @param string $detail
* @param string $modnames
* @param boolean $viewfullnames
*/
function clickmeeting_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames) {
}
/**
* Function to be run periodically according to the moodle cron
* This function searches for things that need to be done, such
* as sending out mail, toggling flags etc ...
*
* @return boolean
**/
function clickmeeting_cron() {
return true;
}
/**
* Returns all other caps used in the module
*
* @return array
*/
function clickmeeting_get_extra_capabilities() {
return [];
}
/**
* Is a given scale used by the instance of clickmeeting?
*
* This function returns if a scale is being used by one clickmeeting
* if it has support for grading and scales. Commented code should be
* modified if necessary. See forum, glossary or journal modules
* as reference.
*
* @param int $clickmeetingid
* @param int $scaleid
* @return bool
*/
function clickmeeting_scale_used($clickmeetingid, $scaleid) {
global $DB;
return $scaleid && $DB->record_exists('clickmeeting', ['id' => $clickmeetingid, 'grade' => -$scaleid]);
}
/**
* Checks if scale is being used by any instance of clickmeeting.
*
* This is used to find out if scale used anywhere.
*
* @param int $scaleid
* @return boolean
*/
function clickmeeting_scale_used_anywhere($scaleid) {
global $DB;
try {
if ($scaleid && $DB->record_exists('clickmeeting', ['grade' => -$scaleid])) {
return true;
}
} catch (dml_exception $e) {
return false;
}
return false;
}
/**
* Creates or updates grade item for the give clickmeeting instance
*
* Needed by grade_update_mod_grades() in lib/gradelib.php
*
* @param stdClass $clickmeeting
*/
function clickmeeting_grade_item_update(stdClass $clickmeeting) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
$item = [];
$item['itemname'] = clean_param($clickmeeting->name, PARAM_NOTAGS);
$item['gradetype'] = GRADE_TYPE_VALUE;
$item['grademax'] = 0;
$item['grademin'] = 0;
$conferenceid = $DB->get_field('clickmeeting_conferences', 'conference_id', ['clickmeeting_id' => $clickmeeting->id]);
clickmeeting_edit_conference_title($conferenceid, $clickmeeting->name);
grade_update('mod/clickmeeting', $clickmeeting->course, 'mod', 'clickmeeting', $clickmeeting->id, 0, null, $item);
}
/**
* Returns easy to read password
*
* @param int $length
* @return string
*/
function clickmeeting_generate_password($length) {
$availablecharacters = '34679ACFGHJKMNPRSTUWXY';
$password = '';
for ($i = 0; $i < $length; $i++) {
$index = mt_rand(0, (strlen($availablecharacters) - 1));
$password .= $availablecharacters[$index];
$availablecharacters = str_replace($availablecharacters[$index], '', $availablecharacters);
}
return $password;
}
/**
* Update clickmeeting grades in the gradebook
*
* Needed by grade_update_mod_grades() in lib/gradelib.php
*
* @param stdClass $clickmeeting instance object with extra cmidnumber and modname property
* @param int $userid update grade of specific user only, 0 means all participants
*/
function clickmeeting_update_grades(stdClass $clickmeeting, $userid = 0) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
$grades = []; // populate array of grade objects indexed by userid
grade_update('mod/clickmeeting', $clickmeeting->course, 'mod', 'clickmeeting', $clickmeeting->id, 0, $grades);
}
/**
* Returns the lists of all browsable file areas within the given module context
*
* The file area 'intro' for the activity introduction field is added automatically
* by {@see file_browser::get_file_info_context_module}
*
* @param stdClass $course
* @param stdClass $cm
* @param stdClass $context
* @return array
*/
function clickmeeting_get_file_areas($course, $cm, $context) {
return [];
}
/**
* File browsing support for clickmeeting file areas
*
* @param file_browser $browser
* @param array $areas
* @param stdClass $course
* @param stdClass $cm
* @param stdClass $context
* @param string $filearea
* @param int $itemid
* @param string $filepath
* @param string $filename
* @return file_info
*/
function clickmeeting_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename) {
return null;
}
/**
* Serves the files from the clickmeeting file areas
*
* @package mod_clickmeeting
* @category files
*
* @param stdClass $course the course object
* @param stdClass $cm the course module object
* @param stdClass $context the clickmeeting's context
* @param string $filearea the name of the file area
* @param array $args extra arguments (itemid, path)
* @param bool $forcedownload whether or not force download
* @param array $options additional options affecting the file serving
*/
function clickmeeting_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options = []) {
global $DB, $CFG;
if ($context->contextlevel != CONTEXT_MODULE) {
send_file_not_found();
}
require_login($course, true, $cm);
send_file_not_found();
}
/**
* Extends the global navigation tree by adding clickmeeting nodes if there is a relevant content
*
* This can be called by an AJAX request so do not rely on $PAGE as it might not be set up properly.
*
* @param navigation_node $navref
* @param stdClass $course
* @param stdClass $module
* @param cm_info $cm
*/
function clickmeeting_extend_navigation(navigation_node $navref, stdClass $course, stdClass $module, cm_info $cm) {
}
/**
* Extends the settings navigation with the clickmeeting settings
*
* This function is called when the context for the page is a clickmeeting module. This is not called by AJAX
* so it is safe to rely on the $PAGE.
*
* @param settings_navigation $settingsnav
* @param navigation_node $clickmeetingnode
*/
function clickmeeting_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $clickmeetingnode=null) {
}
/**
* Initialize curl hande for clickmeeting api
*
* @return \curl
*/
function clickmeeting_init_curl() {
$curlhandle = new \curl();
$curlhandle->setHeader(['X-Api-Key: ' . clickmeeting_get_api_key()]);
$curlhandle->setopt([
'CURLOPT_TIMEOUT' => 100,
'CURLOPT_RETURNTRANSFER' => true,
]);
if ('develop' === '{{env}}') { // hack for local development
$curlhandle->setopt([
'CURLOPT_SSL_VERIFYPEER' => false,
'CURLOPT_SSL_VERIFYHOST' => false,
]);
}
return $curlhandle;
}
/**
* Mark the activity completed (if required) and trigger the course_module_viewed event.
*
* @param stdClass $clickmeeting clickmeeting object
* @param stdClass $course course object
* @param stdClass $cm course module object
* @param stdClass $context context object
*/
function clickmeeting_page_view($clickmeeting, $course, $cm, $context) {
$params = array(
'context' => $context,
'objectid' => $clickmeeting->id,
);
$event = mod_clickmeeting\event\course_module_viewed::create($params);
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('course', $course);
$event->add_record_snapshot('clickmeeting', $clickmeeting);
$event->trigger();
// Completion.
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
}