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
|
|
|
* The mod_bigbluebuttonbn settings/renderer. |
19
|
|
|
* |
20
|
|
|
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com) |
21
|
|
|
* @copyright 2017 - present Blindside Networks Inc |
22
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace mod_bigbluebuttonbn\settings; |
26
|
|
|
|
27
|
|
|
defined('MOODLE_INTERNAL') || die(); |
28
|
|
|
|
29
|
|
|
require_once($CFG->dirroot . '/mod/bigbluebuttonbn/locallib.php'); |
30
|
|
|
require_once($CFG->libdir.'/adminlib.php'); |
31
|
|
|
|
32
|
|
|
class renderer { |
33
|
|
|
|
34
|
|
|
private $settings; |
35
|
|
|
|
36
|
|
|
public function __construct(&$settings) { |
37
|
|
|
$this->settings = $settings; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return |
42
|
|
|
*/ |
43
|
|
|
public function render_group_header($name, $itemname = null, $itemdescription = null) { |
44
|
|
|
if ($itemname == null) { |
45
|
|
|
$itemname = get_string('config_' . $name, 'bigbluebuttonbn'); |
46
|
|
|
} |
47
|
|
|
if ($itemdescription == null) { |
48
|
|
|
$itemdescription = get_string('config_' .$name . '_description', 'bigbluebuttonbn'); |
49
|
|
|
} |
50
|
|
|
$item = new \admin_setting_heading('bigbluebuttonbn_config_' . $name, $itemname, $itemdescription); |
51
|
|
|
$this->settings->add($item); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return |
56
|
|
|
*/ |
57
|
|
|
public function render_group_element($name, $item) { |
58
|
|
|
global $CFG; |
59
|
|
|
if (!isset($CFG->bigbluebuttonbn[$name])) { |
60
|
|
|
$this->settings->add($item); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return Object |
66
|
|
|
*/ |
67
|
|
View Code Duplication |
public function& render_group_element_text($name, $default = null, $type = PARAM_RAW) { |
|
|
|
|
68
|
|
|
$item = new \admin_setting_configtext('bigbluebuttonbn_' . $name, |
69
|
|
|
get_string('config_' . $name, 'bigbluebuttonbn'), |
70
|
|
|
get_string('config_' . $name . '_description', 'bigbluebuttonbn'), |
71
|
|
|
$default, $type); |
72
|
|
|
return $item; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return Object |
77
|
|
|
*/ |
78
|
|
View Code Duplication |
public function& render_group_element_checkbox($name, $default = null) { |
|
|
|
|
79
|
|
|
$item = new \admin_setting_configcheckbox('bigbluebuttonbn_' . $name, |
80
|
|
|
get_string('config_' . $name, 'bigbluebuttonbn'), |
81
|
|
|
get_string('config_' . $name . '_description', 'bigbluebuttonbn'), |
82
|
|
|
$default); |
83
|
|
|
return $item; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return Object |
88
|
|
|
*/ |
89
|
|
View Code Duplication |
public function& render_group_element_configmultiselect($name, $defaultsetting, $choices) { |
|
|
|
|
90
|
|
|
$item = new \admin_setting_configmultiselect('bigbluebuttonbn_' . $name, |
91
|
|
|
get_string('config_' . $name, 'bigbluebuttonbn'), |
92
|
|
|
get_string('config_' . $name . '_description', 'bigbluebuttonbn'), |
93
|
|
|
$defaultsetting, $choices); |
94
|
|
|
return $item; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return boolean |
99
|
|
|
*/ |
100
|
|
|
public static function section_general_shown() { |
101
|
|
|
global $CFG; |
102
|
|
|
return (!isset($CFG->bigbluebuttonbn['server_url']) || |
103
|
|
|
!isset($CFG->bigbluebuttonbn['shared_secret'])); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return boolean |
108
|
|
|
*/ |
109
|
|
|
public static function section_record_meeting_shown() { |
110
|
|
|
global $CFG; |
111
|
|
|
return (!isset($CFG->bigbluebuttonbn['recording_default']) || |
112
|
|
|
!isset($CFG->bigbluebuttonbn['recording_editable']) || |
113
|
|
|
!isset($CFG->bigbluebuttonbn['recording_icons_enabled'])); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return boolean |
118
|
|
|
*/ |
119
|
|
|
public static function section_import_recordings_shown() { |
120
|
|
|
global $CFG; |
121
|
|
|
return (!isset($CFG->bigbluebuttonbn['importrecordings_enabled']) || |
122
|
|
|
!isset($CFG->bigbluebuttonbn['importrecordings_from_deleted_enabled'])); |
123
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return boolean |
128
|
|
|
*/ |
129
|
|
|
public static function section_show_recordings_shown() { |
130
|
|
|
global $CFG; |
131
|
|
|
return (!isset($CFG->bigbluebuttonbn['recordings_html_default']) || |
132
|
|
|
!isset($CFG->bigbluebuttonbn['recordings_html_editable']) || |
133
|
|
|
!isset($CFG->bigbluebuttonbn['recordings_deleted_default']) || |
134
|
|
|
!isset($CFG->bigbluebuttonbn['recordings_deleted_editable']) || |
135
|
|
|
!isset($CFG->bigbluebuttonbn['recordings_imported_default']) || |
136
|
|
|
!isset($CFG->bigbluebuttonbn['recordings_imported_editable'])); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return boolean |
141
|
|
|
*/ |
142
|
|
|
public static function section_wait_moderator_shown() { |
143
|
|
|
global $CFG; |
144
|
|
|
return (!isset($CFG->bigbluebuttonbn['waitformoderator_default']) || |
145
|
|
|
!isset($CFG->bigbluebuttonbn['waitformoderator_editable']) || |
146
|
|
|
!isset($CFG->bigbluebuttonbn['waitformoderator_ping_interval']) || |
147
|
|
|
!isset($CFG->bigbluebuttonbn['waitformoderator_cache_ttl'])); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return boolean |
152
|
|
|
*/ |
153
|
|
|
public static function section_static_voice_bridge_shown() { |
154
|
|
|
global $CFG; |
155
|
|
|
return (!isset($CFG->bigbluebuttonbn['voicebridge_editable'])); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @return boolean |
160
|
|
|
*/ |
161
|
|
|
public static function section_preupload_presentation_shown() { |
162
|
|
|
global $CFG; |
163
|
|
|
return (!isset($CFG->bigbluebuttonbn['preuploadpresentation_enabled'])); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return boolean |
168
|
|
|
*/ |
169
|
|
|
public static function section_user_limit_shown() { |
170
|
|
|
global $CFG; |
171
|
|
|
return (!isset($CFG->bigbluebuttonbn['userlimit_default']) || |
172
|
|
|
!isset($CFG->bigbluebuttonbn['userlimit_editable'])); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @return boolean |
177
|
|
|
*/ |
178
|
|
|
public static function section_scheduled_duration_shown() { |
179
|
|
|
global $CFG; |
180
|
|
|
return (!isset($CFG->bigbluebuttonbn['scheduled_duration_enabled'])); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @return boolean |
185
|
|
|
*/ |
186
|
|
|
public static function section_moderator_default_shown() { |
187
|
|
|
global $CFG; |
188
|
|
|
return (!isset($CFG->bigbluebuttonbn['participant_moderator_default'])); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @return boolean |
193
|
|
|
*/ |
194
|
|
|
public static function section_send_notifications_shown() { |
195
|
|
|
global $CFG; |
196
|
|
|
return (!isset($CFG->bigbluebuttonbn['sendnotifications_enabled'])); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @return boolean |
201
|
|
|
*/ |
202
|
|
|
public static function section_settings_extended_shown() { |
203
|
|
|
global $CFG; |
204
|
|
|
return (!isset($CFG->bigbluebuttonbn['recordingready_enabled']) || |
205
|
|
|
!isset($CFG->bigbluebuttonbn['meetingevents_enabled'])); |
206
|
|
|
} |
207
|
|
|
} |
208
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.