Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of the Zoom plugin for 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
 * Settings.
19
 *
20
 * @package    mod_zoom
21
 * @copyright  2015 UC Regents
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
require_once($CFG->dirroot . '/mod/zoom/locallib.php');
28
require_once($CFG->libdir . '/environmentlib.php');
29
 
30
if ($ADMIN->fulltree) {
31
    require_once($CFG->dirroot . '/mod/zoom/classes/invitation.php');
32
 
33
    $moodlehashideif = version_compare(normalize_version($CFG->release), '3.7.0', '>=');
34
 
35
    $settings = new admin_settingpage('modsettingzoom', get_string('pluginname', 'mod_zoom'));
36
 
37
    // Test whether connection works and display result to user.
38
    if (!CLI_SCRIPT && $PAGE->url == $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=modsettingzoom') {
39
        $status = 'connectionfailed';
40
        $notifyclass = 'notifyproblem';
41
        $errormessage = '';
42
        try {
43
            zoom_get_user(zoom_get_api_identifier($USER));
44
            $status = 'connectionok';
45
            $notifyclass = 'notifysuccess';
46
        } catch (\mod_zoom\webservice_exception $error) {
47
            $errormessage = $error->response;
48
        } catch (moodle_exception $error) {
49
            $errormessage = $error->a;
50
        }
51
 
52
        $statusmessage = $OUTPUT->notification(get_string('connectionstatus', 'mod_zoom') .
53
                ': ' . get_string($status, 'mod_zoom') . $errormessage, $notifyclass);
54
        $connectionstatus = new admin_setting_heading('zoom/connectionstatus', $statusmessage, '');
55
        $settings->add($connectionstatus);
56
    }
57
 
58
    // Connection settings.
59
    $settings->add(new admin_setting_heading(
60
        'zoom/connectionsettings',
61
        get_string('connectionsettings', 'mod_zoom'),
62
        get_string('connectionsettings_desc', 'mod_zoom')
63
    ));
64
 
65
    $accountid = new admin_setting_configtext(
66
        'zoom/accountid',
67
        get_string('accountid', 'mod_zoom'),
68
        get_string('accountid_desc', 'mod_zoom'),
69
        '',
70
        PARAM_ALPHANUMEXT
71
    );
72
    $settings->add($accountid);
73
 
74
    $clientid = new admin_setting_configtext(
75
        'zoom/clientid',
76
        get_string('clientid', 'mod_zoom'),
77
        get_string('clientid_desc', 'mod_zoom'),
78
        '',
79
        PARAM_ALPHANUMEXT
80
    );
81
    $settings->add($clientid);
82
 
83
    $clientsecret = new admin_setting_configpasswordunmask(
84
        'zoom/clientsecret',
85
        get_string('clientsecret', 'mod_zoom'),
86
        get_string('clientsecret_desc', 'mod_zoom'),
87
        ''
88
    );
89
    $settings->add($clientsecret);
90
 
91
    $zoomurl = new admin_setting_configtext(
92
        'zoom/zoomurl',
93
        get_string('zoomurl', 'mod_zoom'),
94
        get_string('zoomurl_desc', 'mod_zoom'),
95
        '',
96
        PARAM_URL
97
    );
98
    $settings->add($zoomurl);
99
 
100
    $apiendpointchoices = [
101
        ZOOM_API_ENDPOINT_GLOBAL => get_string('apiendpoint_global', 'mod_zoom'),
102
        ZOOM_API_ENDPOINT_EU => get_string('apiendpoint_eu', 'mod_zoom'),
103
    ];
104
    $apiendpoint = new admin_setting_configselect(
105
        'zoom/apiendpoint',
106
        get_string('apiendpoint', 'mod_zoom'),
107
        get_string('apiendpoint_desc', 'mod_zoom'),
108
        ZOOM_API_ENDPOINT_GLOBAL,
109
        $apiendpointchoices
110
    );
111
    $settings->add($apiendpoint);
112
 
113
    $proxyhost = new admin_setting_configtext(
114
        'zoom/proxyhost',
115
        get_string('option_proxyhost', 'mod_zoom'),
116
        get_string('option_proxyhost_desc', 'mod_zoom'),
117
        '',
118
        '/^[a-zA-Z0-9.-]+:[0-9]+$|^$/'
119
    );
120
    $settings->add($proxyhost);
121
 
122
    $apiidentifier = new admin_setting_configselect(
123
        'zoom/apiidentifier',
124
        get_string('apiidentifier', 'mod_zoom'),
125
        get_string('apiidentifier_desc', 'mod_zoom'),
126
        'email',
127
        zoom_get_api_identifier_fields()
128
    );
129
    $settings->add($apiidentifier);
130
 
131
    // License settings.
132
    $settings->add(new admin_setting_heading(
133
        'zoom/licensesettings',
134
        get_string('licensesettings', 'mod_zoom'),
135
        get_string('licensesettings_desc', 'mod_zoom')
136
    ));
137
 
138
    $licensescount = new admin_setting_configtext(
139
        'zoom/licensesnumber',
140
        get_string('licensesnumber', 'mod_zoom'),
141
        null,
142
        0,
143
        PARAM_INT
144
    );
145
    $settings->add($licensescount);
146
 
147
    $utmost = new admin_setting_configcheckbox(
148
        'zoom/utmost',
149
        get_string('redefinelicenses', 'mod_zoom'),
150
        get_string('lowlicenses', 'mod_zoom'),
151
        0,
152
        1
153
    );
154
    $settings->add($utmost);
155
 
156
    $instanceusers = new admin_setting_configcheckbox(
157
        'zoom/instanceusers',
158
        get_string('instanceusers', 'mod_zoom'),
159
        get_string('instanceusers_desc', 'mod_zoom'),
160
        0,
161
        1,
162
 
163
    );
164
    $settings->add($instanceusers);
165
 
166
    $recycleonjoin = new admin_setting_configcheckbox(
167
        'zoom/recycleonjoin',
168
        get_string('recycleonjoin', 'mod_zoom'),
169
        get_string('licenseonjoin', 'mod_zoom'),
170
        0,
171
        1
172
    );
173
    $settings->add($recycleonjoin);
174
 
175
    // Global settings.
176
    $settings->add(new admin_setting_heading(
177
        'zoom/globalsettings',
178
        get_string('globalsettings', 'mod_zoom'),
179
        get_string('globalsettings_desc', 'mod_zoom')
180
    ));
181
 
182
    $jointimechoices = [0, 5, 10, 15, 20, 30, 45, 60];
183
    $jointimeselect = [];
184
    foreach ($jointimechoices as $minutes) {
185
        $jointimeselect[$minutes] = $minutes . ' ' . get_string('mins');
186
    }
187
 
188
    $firstabletojoin = new admin_setting_configselect(
189
        'zoom/firstabletojoin',
190
        get_string('firstjoin', 'mod_zoom'),
191
        get_string('firstjoin_desc', 'mod_zoom'),
192
        15,
193
        $jointimeselect
194
    );
195
    $settings->add($firstabletojoin);
196
 
197
    if ($moodlehashideif) {
198
        $displayleadtime = new admin_setting_configcheckbox(
199
            'zoom/displayleadtime',
200
            get_string('displayleadtime', 'mod_zoom'),
201
            get_string('displayleadtime_desc', 'mod_zoom'),
202
            0,
203
            1,
204
 
205
        );
206
        $settings->add($displayleadtime);
207
        $settings->hide_if('zoom/displayleadtime', 'zoom/firstabletojoin', 'eq', 0);
208
    } else {
209
        $displayleadtime = new admin_setting_configcheckbox(
210
            'zoom/displayleadtime',
211
            get_string('displayleadtime', 'mod_zoom'),
212
            get_string('displayleadtime_desc', 'mod_zoom') . '<br />' .
213
                        get_string('displayleadtime_nohideif', 'mod_zoom', get_string('firstjoin', 'mod_zoom')),
214
            0,
215
            1,
216
 
217
        );
218
        $settings->add($displayleadtime);
219
    }
220
 
221
    $displaypassword = new admin_setting_configcheckbox(
222
        'zoom/displaypassword',
223
        get_string('displaypassword', 'mod_zoom'),
224
        get_string('displaypassword_help', 'mod_zoom'),
225
        0,
226
        1,
227
 
228
    );
229
    $settings->add($displaypassword);
230
 
231
    $maskparticipantdata = new admin_setting_configcheckbox(
232
        'zoom/maskparticipantdata',
233
        get_string('maskparticipantdata', 'mod_zoom'),
234
        get_string('maskparticipantdata_help', 'mod_zoom'),
235
        0,
236
        1
237
    );
238
    $settings->add($maskparticipantdata);
239
 
240
    $viewrecordings = new admin_setting_configcheckbox(
241
        'zoom/viewrecordings',
242
        get_string('option_view_recordings', 'mod_zoom'),
243
        '',
244
        0,
245
        1,
246
 
247
    );
248
    $settings->add($viewrecordings);
249
 
250
    // Adding options for the display name using uname parameter in zoom join_url.
251
    $options = [
252
        'fullname' => get_string('displayfullname', 'mod_zoom'),
253
        'firstname' => get_string('displayfirstname', 'mod_zoom'),
254
        'idfullname' => get_string('displayidfullname', 'mod_zoom'),
255
        'id' => get_string('displayid', 'mod_zoom'),
256
    ];
257
    $settings->add(new admin_setting_configselect(
258
        'zoom/unamedisplay',
259
        get_string('unamedisplay', 'mod_zoom'),
260
        get_string('unamedisplay_help', 'mod_zoom'),
261
        'fullname',
262
        $options
263
    ));
264
 
265
    // Supplementary features settings.
266
    $settings->add(new admin_setting_heading(
267
        'zoom/supplementaryfeaturessettings',
268
        get_string('supplementaryfeaturessettings', 'mod_zoom'),
269
        get_string('supplementaryfeaturessettings_desc', 'mod_zoom')
270
    ));
271
 
272
    $webinarchoices = [
273
        ZOOM_WEBINAR_DISABLE => get_string('webinar_disable', 'mod_zoom'),
274
        ZOOM_WEBINAR_SHOWONLYIFLICENSE => get_string('webinar_showonlyiflicense', 'mod_zoom'),
275
        ZOOM_WEBINAR_ALWAYSSHOW => get_string('webinar_alwaysshow', 'mod_zoom'),
276
    ];
277
    $offerwebinar = new admin_setting_configselect(
278
        'zoom/showwebinars',
279
        get_string('webinar', 'mod_zoom'),
280
        get_string('webinar_desc', 'mod_zoom'),
281
        ZOOM_WEBINAR_ALWAYSSHOW,
282
        $webinarchoices
283
    );
284
    $settings->add($offerwebinar);
285
 
286
    $webinardefault = new admin_setting_configcheckbox(
287
        'zoom/webinardefault',
288
        get_string('webinar_by_default', 'mod_zoom'),
289
        get_string('webinar_by_default_desc', 'mod_zoom'),
290
        0,
291
        1,
292
 
293
    );
294
    $settings->add($webinardefault);
295
 
296
    $encryptionchoices = [
297
        ZOOM_ENCRYPTION_DISABLE => get_string('encryptiontype_disable', 'mod_zoom'),
298
        ZOOM_ENCRYPTION_SHOWONLYIFPOSSIBLE => get_string('encryptiontype_showonlyife2epossible', 'mod_zoom'),
299
        ZOOM_ENCRYPTION_ALWAYSSHOW => get_string('encryptiontype_alwaysshow', 'mod_zoom'),
300
    ];
301
    $offerencryption = new admin_setting_configselect(
302
        'zoom/showencryptiontype',
303
        get_string('encryptiontype', 'mod_zoom'),
304
        get_string('encryptiontype_desc', 'mod_zoom'),
305
        ZOOM_ENCRYPTION_SHOWONLYIFPOSSIBLE,
306
        $encryptionchoices
307
    );
308
    $settings->add($offerencryption);
309
 
310
    $schedulingprivilegechoices = [
311
        ZOOM_SCHEDULINGPRIVILEGE_DISABLE => get_string('schedulingprivilege_disable', 'mod_zoom'),
312
        ZOOM_SCHEDULINGPRIVILEGE_ENABLE => get_string('schedulingprivilege_enable', 'mod_zoom'),
313
    ];
314
    $offerschedulingprivilege = new admin_setting_configselect(
315
        'zoom/showschedulingprivilege',
316
        get_string('schedulingprivilege', 'mod_zoom'),
317
        get_string('schedulingprivilege_desc', 'mod_zoom'),
318
        ZOOM_SCHEDULINGPRIVILEGE_ENABLE,
319
        $schedulingprivilegechoices
320
    );
321
    $settings->add($offerschedulingprivilege);
322
 
323
    $alternativehostschoices = [
324
        ZOOM_ALTERNATIVEHOSTS_DISABLE => get_string('alternative_hosts_disable', 'mod_zoom'),
325
        ZOOM_ALTERNATIVEHOSTS_INPUTFIELD => get_string('alternative_hosts_inputfield', 'mod_zoom'),
326
        ZOOM_ALTERNATIVEHOSTS_PICKER => get_string('alternative_hosts_picker', 'mod_zoom'),
327
    ];
328
    $alternativehostsroles = zoom_get_selectable_alternative_hosts_rolestring(context_system::instance());
329
    $offeralternativehosts = new admin_setting_configselect(
330
        'zoom/showalternativehosts',
331
        get_string('alternative_hosts', 'mod_zoom'),
332
        get_string('alternative_hosts_desc', 'mod_zoom', ['roles' => $alternativehostsroles]),
333
        ZOOM_ALTERNATIVEHOSTS_INPUTFIELD,
334
        $alternativehostschoices
335
    );
336
    $settings->add($offeralternativehosts);
337
 
338
    $capacitywarningchoices = [
339
        ZOOM_CAPACITYWARNING_DISABLE => get_string('meetingcapacitywarning_disable', 'mod_zoom'),
340
        ZOOM_CAPACITYWARNING_ENABLE => get_string('meetingcapacitywarning_enable', 'mod_zoom'),
341
    ];
342
    $offercapacitywarning = new admin_setting_configselect(
343
        'zoom/showcapacitywarning',
344
        get_string('meetingcapacitywarning', 'mod_zoom'),
345
        get_string('meetingcapacitywarning_desc', 'mod_zoom'),
346
        ZOOM_CAPACITYWARNING_ENABLE,
347
        $capacitywarningchoices
348
    );
349
    $settings->add($offercapacitywarning);
350
 
351
    $allmeetingschoices = [
352
        ZOOM_ALLMEETINGS_DISABLE => get_string('allmeetings_disable', 'mod_zoom'),
353
        ZOOM_ALLMEETINGS_ENABLE => get_string('allmeetings_enable', 'mod_zoom'),
354
    ];
355
    $offerallmeetings = new admin_setting_configselect(
356
        'zoom/showallmeetings',
357
        get_string('allmeetings', 'mod_zoom'),
358
        get_string('allmeetings_desc', 'mod_zoom'),
359
        ZOOM_ALLMEETINGS_ENABLE,
360
        $allmeetingschoices
361
    );
362
    $settings->add($offerallmeetings);
363
 
364
    $downloadicalchoices = [
365
        ZOOM_DOWNLOADICAL_DISABLE => get_string('downloadical_disable', 'mod_zoom'),
366
        ZOOM_DOWNLOADICAL_ENABLE => get_string('downloadical_enable', 'mod_zoom'),
367
    ];
368
    $offerdownloadical = new admin_setting_configselect(
369
        'zoom/showdownloadical',
370
        get_string('downloadical', 'mod_zoom'),
371
        get_string('downloadical_desc', 'mod_zoom'),
372
        ZOOM_DOWNLOADICAL_ENABLE,
373
        $downloadicalchoices
374
    );
375
    $settings->add($offerdownloadical);
376
 
377
    // Default Zoom settings.
378
    $settings->add(new admin_setting_heading(
379
        'zoom/defaultsettings',
380
        get_string('defaultsettings', 'mod_zoom'),
381
        get_string('defaultsettings_help', 'mod_zoom')
382
    ));
383
 
384
    $defaultrecurring = new admin_setting_configcheckbox(
385
        'zoom/defaultrecurring',
386
        get_string('recurringmeeting', 'mod_zoom'),
387
        get_string('recurringmeeting_help', 'mod_zoom'),
388
        0,
389
        1,
390
 
391
    );
392
    $settings->add($defaultrecurring);
393
 
394
    $defaultshowschedule = new admin_setting_configcheckbox(
395
        'zoom/defaultshowschedule',
396
        get_string('showschedule', 'mod_zoom'),
397
        get_string('showschedule_help', 'mod_zoom'),
398
        1,
399
        1,
400
 
401
    );
402
    $settings->add($defaultshowschedule);
403
 
404
    $defaultregistration = new admin_setting_configcheckbox(
405
        'zoom/defaultregistration',
406
        get_string('registration', 'mod_zoom'),
407
        get_string('registration_help', 'mod_zoom'),
408
        ZOOM_REGISTRATION_OFF,
409
        ZOOM_REGISTRATION_AUTOMATIC,
410
        ZOOM_REGISTRATION_OFF
411
    );
412
    $settings->add($defaultregistration);
413
 
414
    $defaultrequirepasscode = new admin_setting_configcheckbox(
415
        'zoom/requirepasscode',
416
        get_string('requirepasscode', 'mod_zoom'),
417
        get_string('requirepasscode_help', 'mod_zoom'),
418
        1
419
    );
420
    $defaultrequirepasscode->set_locked_flag_options(admin_setting_flag::ENABLED, true);
421
    $settings->add($defaultrequirepasscode);
422
 
423
    $encryptionchoices = [
424
        ZOOM_ENCRYPTION_TYPE_ENHANCED => get_string('option_encryption_type_enhancedencryption', 'mod_zoom'),
425
        ZOOM_ENCRYPTION_TYPE_E2EE => get_string('option_encryption_type_endtoendencryption', 'mod_zoom'),
426
    ];
427
    $defaultencryptiontypeoption = new admin_setting_configselect(
428
        'zoom/defaultencryptiontypeoption',
429
        get_string('option_encryption_type', 'mod_zoom'),
430
        get_string('option_encryption_type_help', 'mod_zoom'),
431
        ZOOM_ENCRYPTION_TYPE_ENHANCED,
432
        $encryptionchoices
433
    );
434
    $settings->add($defaultencryptiontypeoption);
435
 
436
    $defaultwaitingroomoption = new admin_setting_configcheckbox(
437
        'zoom/defaultwaitingroomoption',
438
        get_string('option_waiting_room', 'mod_zoom'),
439
        get_string('option_waiting_room_help', 'mod_zoom'),
440
        1,
441
        1,
442
 
443
    );
444
    $settings->add($defaultwaitingroomoption);
445
 
446
    $defaultjoinbeforehost = new admin_setting_configcheckbox(
447
        'zoom/defaultjoinbeforehost',
448
        get_string('option_jbh', 'mod_zoom'),
449
        get_string('option_jbh_help', 'mod_zoom'),
450
        0,
451
        1,
452
 
453
    );
454
    $settings->add($defaultjoinbeforehost);
455
 
456
    $defaultauthusersoption = new admin_setting_configcheckbox(
457
        'zoom/defaultauthusersoption',
458
        get_string('option_authenticated_users', 'mod_zoom'),
459
        get_string('option_authenticated_users_help', 'mod_zoom'),
460
        0,
461
        1,
462
 
463
    );
464
    $settings->add($defaultauthusersoption);
465
 
466
    $defaultshowsecurity = new admin_setting_configcheckbox(
467
        'zoom/defaultshowsecurity',
468
        get_string('showsecurity', 'mod_zoom'),
469
        get_string('showsecurity_help', 'mod_zoom'),
470
        1,
471
        1,
472
 
473
    );
474
    $settings->add($defaultshowsecurity);
475
 
476
    $defaulthostvideo = new admin_setting_configcheckbox(
477
        'zoom/defaulthostvideo',
478
        get_string('option_host_video', 'mod_zoom'),
479
        get_string('option_host_video_help', 'mod_zoom'),
480
        0,
481
        1,
482
 
483
    );
484
    $settings->add($defaulthostvideo);
485
 
486
    $defaultparticipantsvideo = new admin_setting_configcheckbox(
487
        'zoom/defaultparticipantsvideo',
488
        get_string('option_participants_video', 'mod_zoom'),
489
        get_string('option_participants_video_help', 'mod_zoom'),
490
        0,
491
        1,
492
 
493
    );
494
    $settings->add($defaultparticipantsvideo);
495
 
496
    $audiochoices = [
497
        ZOOM_AUDIO_TELEPHONY => get_string('audio_telephony', 'mod_zoom'),
498
        ZOOM_AUDIO_VOIP => get_string('audio_voip', 'mod_zoom'),
499
        ZOOM_AUDIO_BOTH => get_string('audio_both', 'mod_zoom'),
500
    ];
501
    $defaultaudiooption = new admin_setting_configselect(
502
        'zoom/defaultaudiooption',
503
        get_string('option_audio', 'mod_zoom'),
504
        get_string('option_audio_help', 'mod_zoom'),
505
        ZOOM_AUDIO_BOTH,
506
        $audiochoices
507
    );
508
    $settings->add($defaultaudiooption);
509
 
510
    $defaultmuteuponentryoption = new admin_setting_configcheckbox(
511
        'zoom/defaultmuteuponentryoption',
512
        get_string('option_mute_upon_entry', 'mod_zoom'),
513
        get_string('option_mute_upon_entry_help', 'mod_zoom'),
514
        1,
515
        1,
516
 
517
    );
518
    $settings->add($defaultmuteuponentryoption);
519
 
520
    $autorecordingchoices = [
521
        ZOOM_AUTORECORDING_NONE => get_string('autorecording_none', 'mod_zoom'),
522
        ZOOM_AUTORECORDING_USERDEFAULT => get_string('autorecording_userdefault', 'mod_zoom'),
523
        ZOOM_AUTORECORDING_LOCAL => get_string('autorecording_local', 'mod_zoom'),
524
        ZOOM_AUTORECORDING_CLOUD => get_string('autorecording_cloud', 'mod_zoom'),
525
    ];
526
    $recordingoption = new admin_setting_configselect(
527
        'zoom/recordingoption',
528
        get_string('option_auto_recording', 'mod_zoom'),
529
        get_string('option_auto_recording_help', 'mod_zoom'),
530
        ZOOM_AUTORECORDING_USERDEFAULT,
531
        $autorecordingchoices
532
    );
533
    $settings->add($recordingoption);
534
 
535
    $allowrecordingchangeoption = new admin_setting_configcheckbox(
536
        'zoom/allowrecordingchangeoption',
537
        get_string('option_allow_recording_change', 'mod_zoom'),
538
        get_string('option_allow_recording_change_help', 'mod_zoom'),
539
        1,
540
        1,
541
 
542
    );
543
    $settings->add($allowrecordingchangeoption);
544
 
545
    $defaultshowmedia = new admin_setting_configcheckbox(
546
        'zoom/defaultshowmedia',
547
        get_string('showmedia', 'mod_zoom'),
548
        get_string('showmedia_help', 'mod_zoom'),
549
        1,
550
        1,
551
 
552
    );
553
    $settings->add($defaultshowmedia);
554
 
555
    $defaulttrackingfields = new admin_setting_configtextarea(
556
        'zoom/defaulttrackingfields',
557
        get_string('trackingfields', 'mod_zoom'),
558
        get_string('trackingfields_help', 'mod_zoom'),
559
        ''
560
    );
561
    $defaulttrackingfields->set_updatedcallback('mod_zoom_update_tracking_fields');
562
    $settings->add($defaulttrackingfields);
563
 
564
    $invitationregexhelp = get_string('invitationregex_help', 'mod_zoom');
565
    if (!$moodlehashideif) {
566
        $invitationregexhelp .= "\n\n" . get_string(
567
            'invitationregex_nohideif',
568
            'mod_zoom',
569
            get_string('invitationregexenabled', 'mod_zoom')
570
        );
571
    }
572
 
573
    $settings->add(new admin_setting_heading(
574
        'zoom/invitationregex',
575
        get_string('invitationregex', 'mod_zoom'),
576
        $invitationregexhelp
577
    ));
578
 
579
    $settings->add(new admin_setting_configcheckbox(
580
        'zoom/invitationregexenabled',
581
        get_string('invitationregexenabled', 'mod_zoom'),
582
        get_string('invitationregexenabled_help', 'mod_zoom'),
583
        0,
584
        1,
585
 
586
    ));
587
 
588
    $settings->add(new admin_setting_configcheckbox(
589
        'zoom/invitationremoveinvite',
590
        get_string('invitationremoveinvite', 'mod_zoom'),
591
        get_string('invitationremoveinvite_help', 'mod_zoom'),
592
        0,
593
        1,
594
 
595
    ));
596
    if ($moodlehashideif) {
597
        $settings->hide_if('zoom/invitationremoveinvite', 'zoom/invitationregexenabled', 'eq', 0);
598
    }
599
 
600
    $settings->add(new admin_setting_configcheckbox(
601
        'zoom/invitationremoveicallink',
602
        get_string('invitationremoveicallink', 'mod_zoom'),
603
        get_string('invitationremoveicallink_help', 'mod_zoom'),
604
        0,
605
        1,
606
 
607
    ));
608
    if ($moodlehashideif) {
609
        $settings->hide_if('zoom/invitationremoveicallink', 'zoom/invitationregexenabled', 'eq', 0);
610
    }
611
 
612
    // Allow admin to modify regex for invitation parts if zoom api changes.
613
    foreach (\mod_zoom\invitation::get_default_invitation_regex() as $element => $pattern) {
614
        $name = 'zoom/' . \mod_zoom\invitation::PREFIX . $element;
615
        $visiblename = get_string(\mod_zoom\invitation::PREFIX . $element, 'mod_zoom');
616
        $description = get_string(\mod_zoom\invitation::PREFIX . $element . '_help', 'mod_zoom');
617
        $settings->add(new admin_setting_configtext($name, $visiblename, $description, $pattern));
618
        if ($moodlehashideif) {
619
            $settings->hide_if(
620
                'zoom/' . \mod_zoom\invitation::PREFIX . $element,
621
                'zoom/invitationregexenabled',
622
                'eq',
623
 
624
            );
625
        }
626
    }
627
 
628
    // Extra hideif for elements which can be enabled / disabled individually.
629
    if ($moodlehashideif) {
630
        $settings->hide_if('zoom/invitation_invite', 'zoom/invitationremoveinvite', 'eq', 0);
631
        $settings->hide_if('zoom/invitation_icallink', 'zoom/invitationremoveicallink', 'eq', 0);
632
    }
633
 
634
    // Adding options for grading methods.
635
    $settings->add(new admin_setting_heading(
636
        'zoom/gradingmethod',
637
        get_string('gradingmethod_heading', 'mod_zoom'),
638
        get_string('gradingmethod_heading_help', 'mod_zoom')
639
    ));
640
 
641
    // Grading method upon entry: the user gets the full score when clicking to join the session through Moodle.
642
    // Grading method upon period: the user is graded based on how long they attended the actual session.
643
    $options = [
644
        'entry' => get_string('gradingentry', 'mod_zoom'),
645
        'period' => get_string('gradingperiod', 'mod_zoom'),
646
    ];
647
    $settings->add(new admin_setting_configselect(
648
        'zoom/gradingmethod',
649
        get_string('gradingmethod', 'mod_zoom'),
650
        get_string('gradingmethod_help', 'mod_zoom'),
651
        'entry',
652
        $options
653
    ));
654
}