forked from ncstate-delta/moodle-mod_zoom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.php
102 lines (89 loc) · 4.69 KB
/
settings.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
<?php
// This file is part of the Zoom plugin for 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/>.
/**
* Settings.
*
* @package mod_zoom
* @copyright 2015 UC Regents
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
require_once($CFG->dirroot.'/mod/zoom/locallib.php');
require_once($CFG->dirroot.'/mod/zoom/classes/webservice.php');
$settings = new admin_settingpage('modsettingzoom', get_string('pluginname', 'mod_zoom'));
// Test connection if it is setup and user is on the settings page.
if (!CLI_SCRIPT && $PAGE->url == $CFG->wwwroot . '/' . $CFG->admin .
'/settings.php?section=modsettingzoom') {
$status = 'connectionok';
$notifyclass = 'notifysuccess';
$service = new mod_zoom_webservice();
if (!$service->user_getbyemail($USER->email)) {
$error = $service->lasterror;
if (strpos($error, 'Api key and secret are required') !== false) {
$status = 'zoomerr_apisettings_missing';
$notifyclass = 'notifymessage';
} else if (strpos($error, 'Invalid api key or secret') !== false) {
$status = 'zoomerr_apisettings_invalid';
$notifyclass = 'notifyproblem';
} else if (strpos($error, '404 Not Found') !== false) {
$status = 'zoomerr_apiurl_404';
$notifyclass = 'notifyproblem';
} else if (strpos($error, "Couldn't resolve host") !== false) {
$status = 'zoomerr_apiurl_unresolved';
$notifyclass = 'notifyproblem';
} else if (strpos($error, "The requested URL returned error:") !== false) {
$status = 'zoomerr_apiurl_error';
$notifyclass = 'notifyproblem';
debugging('Zoom error: ' . $error, DEBUG_NORMAL);
}
}
$statusmessage = $OUTPUT->notification(get_string('connectionstatus', 'zoom') .
': ' . get_string($status, 'zoom'), $notifyclass);
$connectionstatus = new admin_setting_heading('mod_zoom/connectionstatus',
$statusmessage, '');
$settings->add($connectionstatus);
}
$apiurl = new admin_setting_configtext('mod_zoom/apiurl', get_string('apiurl', 'mod_zoom'),
get_string('apiurl_desc', 'mod_zoom'), 'https://api.zoom.us/v1/', PARAM_URL);
$settings->add($apiurl);
$apikey = new admin_setting_configtext('mod_zoom/apikey', get_string('apikey', 'mod_zoom'),
get_string('apikey_desc', 'mod_zoom'), '', PARAM_ALPHANUMEXT);
$settings->add($apikey);
$apisecret = new admin_setting_configtext('mod_zoom/apisecret', get_string('apisecret', 'mod_zoom'),
get_string('apisecret_desc', 'mod_zoom'), '', PARAM_ALPHANUMEXT);
$settings->add($apisecret);
$zoomurl = new admin_setting_configtext('mod_zoom/zoomurl', get_string('zoomurl', 'mod_zoom'),
get_string('zoomurl_desc', 'mod_zoom'), '', PARAM_URL);
$settings->add($zoomurl);
$jointimechoices = array(0, 5, 10, 15, 20, 30, 45, 60);
$jointimeselect = array();
foreach ($jointimechoices as $minutes) {
$jointimeselect[$minutes] = $minutes . ' ' . get_string('mins');
}
$firstabletojoin = new admin_setting_configselect('mod_zoom/firstabletojoin',
get_string('firstjoin', 'mod_zoom'), get_string('firstjoin_desc', 'mod_zoom'),
15, $jointimeselect);
$settings->add($firstabletojoin);
$logintypes = array(ZOOM_SNS_SSO => get_string('login_sso', 'mod_zoom'),
ZOOM_SNS_ZOOM => get_string('login_zoom', 'mod_zoom'),
ZOOM_SNS_API => get_string('login_api', 'mod_zoom'),
ZOOM_SNS_FACEBOOK => get_string('login_facebook', 'mod_zoom'),
ZOOM_SNS_GOOGLE => get_string('login_google', 'mod_zoom'));
$settings->add(new admin_setting_configmultiselect('mod_zoom/logintypes',
get_string('logintypes', 'mod_zoom'), get_string('logintypesexplain', 'mod_zoom'),
array(ZOOM_SNS_SSO), $logintypes));
}