|
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
|
|
|
* Renderer. |
|
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 Darko Miletic (darko.miletic [at] gmail [dt] com) |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
namespace mod_bigbluebuttonbn\output; |
|
27
|
|
|
|
|
28
|
|
|
use renderable; |
|
29
|
|
|
use html_table; |
|
30
|
|
|
use html_writer; |
|
31
|
|
|
use stdClass; |
|
32
|
|
|
use coding_exception; |
|
33
|
|
|
use mod_bigbluebuttonbn\plugin; |
|
34
|
|
|
|
|
35
|
|
|
defined('MOODLE_INTERNAL') || die(); |
|
36
|
|
|
|
|
37
|
|
|
require_once($CFG->dirroot.'/mod/bigbluebuttonbn/locallib.php'); |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Class index |
|
41
|
|
|
* @package mod_bigbluebuttonbn |
|
42
|
|
|
* @copyright 2010 onwards, Blindside Networks Inc |
|
43
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
44
|
|
|
* @author Darko Miletic (darko.miletic [at] gmail [dt] com) |
|
45
|
|
|
*/ |
|
46
|
|
|
class index implements renderable { |
|
47
|
|
|
|
|
48
|
|
|
/** @var html_table */ |
|
49
|
|
|
public $table = null; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* index constructor. |
|
53
|
|
|
* @param stdClass $course |
|
54
|
|
|
* @throws coding_exception |
|
55
|
|
|
*/ |
|
56
|
|
|
public function __construct($course) { |
|
57
|
|
|
global $DB, $PAGE; |
|
58
|
|
|
|
|
59
|
|
|
// Get all the appropriate data. |
|
60
|
|
|
if (!$bigbluebuttonbns = get_all_instances_in_course('bigbluebuttonbn', $course)) { |
|
61
|
|
|
notice( |
|
62
|
|
|
get_string('index_error_noinstances', plugin::COMPONENT), |
|
63
|
|
|
plugin::necurl('/course/view.php', ['id' => $course->id]) |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
// Print the list of instances. |
|
68
|
|
|
$timenow = time(); |
|
|
|
|
|
|
69
|
|
|
$strweek = get_string('week'); |
|
70
|
|
|
$strtopic = get_string('topic'); |
|
|
|
|
|
|
71
|
|
|
$headingname = get_string('index_heading_name', plugin::COMPONENT); |
|
72
|
|
|
$headinggroup = get_string('index_heading_group', plugin::COMPONENT); |
|
73
|
|
|
$headingusers = get_string('index_heading_users', plugin::COMPONENT); |
|
74
|
|
|
$headingviewer = get_string('index_heading_viewer', plugin::COMPONENT); |
|
75
|
|
|
$headingmoderator = get_string('index_heading_moderator', plugin::COMPONENT); |
|
76
|
|
|
$headingactions = get_string('index_heading_actions', plugin::COMPONENT); |
|
77
|
|
|
$headingrecording = get_string('index_heading_recording', plugin::COMPONENT); |
|
78
|
|
|
|
|
79
|
|
|
$table = new html_table(); |
|
80
|
|
|
$table->head = array($strweek, $headingname, $headinggroup, $headingusers, $headingviewer, $headingmoderator, |
|
81
|
|
|
$headingrecording, $headingactions); |
|
82
|
|
|
$table->align = array('center', 'left', 'center', 'center', 'center', 'center', 'center'); |
|
83
|
|
|
|
|
84
|
|
|
foreach ($bigbluebuttonbns as $bigbluebuttonbn) { |
|
85
|
|
|
if ($bigbluebuttonbn->visible) { |
|
86
|
|
|
$cm = get_coursemodule_from_id('bigbluebuttonbn', $bigbluebuttonbn->coursemodule, 0, false, MUST_EXIST); |
|
87
|
|
|
// User roles. |
|
88
|
|
|
$participantlist = bigbluebuttonbn_get_participant_list($bigbluebuttonbn, $PAGE->context); |
|
89
|
|
|
$moderator = bigbluebuttonbn_is_moderator($PAGE->context, $participantlist); |
|
90
|
|
|
$administrator = is_siteadmin(); |
|
91
|
|
|
$canmoderate = ($administrator || $moderator); |
|
92
|
|
|
// Add a the data for the bigbluebuttonbn instance. |
|
93
|
|
|
$groupobj = null; |
|
94
|
|
|
if (groups_get_activity_groupmode($cm) > 0) { |
|
95
|
|
|
$groupobj = (object) array('id' => 0, 'name' => get_string('allparticipants')); |
|
96
|
|
|
} |
|
97
|
|
|
$table->data[] = self::bigbluebuttonbn_index_display_room($canmoderate, $course, $bigbluebuttonbn, $groupobj); |
|
98
|
|
|
// Add a the data for the groups belonging to the bigbluebuttonbn instance, if any. |
|
99
|
|
|
$groups = groups_get_activity_allowed_groups($cm); |
|
100
|
|
|
foreach ($groups as $group) { |
|
101
|
|
|
$table->data[] = self::bigbluebuttonbn_index_display_room($canmoderate, $course, $bigbluebuttonbn, $group); |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
$this->table = $table; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Displays the general view. |
|
111
|
|
|
* |
|
112
|
|
|
* @param boolean $moderator |
|
113
|
|
|
* @param object $course |
|
114
|
|
|
* @param object $bigbluebuttonbn |
|
115
|
|
|
* @param object $groupobj |
|
116
|
|
|
* @return array |
|
117
|
|
|
*/ |
|
118
|
|
|
public static function bigbluebuttonbn_index_display_room($moderator, $course, $bigbluebuttonbn, $groupobj = null) { |
|
119
|
|
|
$meetingid = sprintf('%s-%d-%d', $bigbluebuttonbn->meetingid, $course->id, $bigbluebuttonbn->id); |
|
120
|
|
|
$groupname = ''; |
|
121
|
|
|
$urlparams = ['id' => $bigbluebuttonbn->coursemodule]; |
|
122
|
|
|
if ($groupobj) { |
|
123
|
|
|
$meetingid .= sprintf('[%d]', $groupobj->id); |
|
124
|
|
|
$urlparams['group'] = $groupobj->id; |
|
125
|
|
|
$groupname = $groupobj->name; |
|
126
|
|
|
} |
|
127
|
|
|
$meetinginfo = bigbluebuttonbn_get_meeting_info_array($meetingid); |
|
128
|
|
|
if (empty($meetinginfo)) { |
|
129
|
|
|
// The server was unreachable. |
|
130
|
|
|
print_error('index_error_unable_display', plugin::COMPONENT); |
|
131
|
|
|
} |
|
132
|
|
|
if (isset($meetinginfo['messageKey']) && ($meetinginfo['messageKey'] == 'checksumError')) { |
|
133
|
|
|
// There was an error returned. |
|
134
|
|
|
print_error('index_error_checksum', plugin::COMPONENT); |
|
135
|
|
|
} |
|
136
|
|
|
// Output Users in the meeting. |
|
137
|
|
|
$joinurl = html_writer::link( |
|
138
|
|
|
plugin::necurl('/mod/bigbluebuttonbn/view.php', $urlparams), |
|
139
|
|
|
format_string($bigbluebuttonbn->name) |
|
140
|
|
|
); |
|
141
|
|
|
$group = $groupname; |
|
142
|
|
|
$users = ''; |
|
143
|
|
|
$viewerlist = ''; |
|
144
|
|
|
$moderatorlist = ''; |
|
145
|
|
|
$recording = ''; |
|
146
|
|
|
$actions = ''; |
|
147
|
|
|
// The meeting info was returned. |
|
148
|
|
|
if (array_key_exists('running', $meetinginfo) && $meetinginfo['running'] == 'true') { |
|
149
|
|
|
$users = self::bigbluebuttonbn_index_display_room_users($meetinginfo); |
|
150
|
|
|
$viewerlist = self::bigbluebuttonbn_index_display_room_users_attendee_list($meetinginfo, 'VIEWER'); |
|
151
|
|
|
$moderatorlist = self::bigbluebuttonbn_index_display_room_users_attendee_list($meetinginfo, 'MODERATOR'); |
|
152
|
|
|
$recording = self::bigbluebuttonbn_index_display_room_recordings($meetinginfo); |
|
153
|
|
|
$actions = self::bigbluebuttonbn_index_display_room_actions($moderator, $course, $bigbluebuttonbn, $groupobj); |
|
154
|
|
|
} |
|
155
|
|
|
return array($bigbluebuttonbn->section, $joinurl, $group, $users, $viewerlist, $moderatorlist, $recording, $actions); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* Count the number of users in the meeting. |
|
160
|
|
|
* |
|
161
|
|
|
* @param array $meetinginfo |
|
162
|
|
|
* @return integer |
|
163
|
|
|
*/ |
|
164
|
|
|
public static function bigbluebuttonbn_index_display_room_users($meetinginfo) { |
|
165
|
|
|
$users = ''; |
|
166
|
|
|
if (count($meetinginfo['attendees']) && count($meetinginfo['attendees']->attendee)) { |
|
167
|
|
|
$users = count($meetinginfo['attendees']->attendee); |
|
168
|
|
|
} |
|
169
|
|
|
return $users; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Returns attendee list. |
|
174
|
|
|
* |
|
175
|
|
|
* @param array $meetinginfo |
|
176
|
|
|
* @param string $role |
|
177
|
|
|
* @return string |
|
178
|
|
|
*/ |
|
179
|
|
|
public static function bigbluebuttonbn_index_display_room_users_attendee_list($meetinginfo, $role) { |
|
180
|
|
|
$attendeelist = ''; |
|
181
|
|
|
if (count($meetinginfo['attendees']) && count($meetinginfo['attendees']->attendee)) { |
|
182
|
|
|
$attendeecount = 0; |
|
183
|
|
|
foreach ($meetinginfo['attendees']->attendee as $attendee) { |
|
184
|
|
|
if ($attendee->role == $role) { |
|
185
|
|
|
$attendeelist .= ($attendeecount++ > 0 ? ', ' : '').$attendee->fullName; |
|
186
|
|
|
} |
|
187
|
|
|
} |
|
188
|
|
|
} |
|
189
|
|
|
return $attendeelist; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* Returns indication of recording enabled. |
|
194
|
|
|
* |
|
195
|
|
|
* @param array $meetinginfo |
|
196
|
|
|
* @return string |
|
197
|
|
|
*/ |
|
198
|
|
|
public static function bigbluebuttonbn_index_display_room_recordings($meetinginfo) { |
|
199
|
|
|
$recording = ''; |
|
200
|
|
|
if (isset($meetinginfo['recording']) && $meetinginfo['recording'] === 'true') { |
|
201
|
|
|
// If it has been set when meeting created, set the variable on/off. |
|
202
|
|
|
$recording = get_string('index_enabled', 'bigbluebuttonbn'); |
|
203
|
|
|
} |
|
204
|
|
|
return $recording; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* Returns room actions. |
|
209
|
|
|
* |
|
210
|
|
|
* @param boolean $moderator |
|
211
|
|
|
* @param object $course |
|
212
|
|
|
* @param object $bigbluebuttonbn |
|
213
|
|
|
* @param object $groupobj |
|
214
|
|
|
* @return string |
|
215
|
|
|
*/ |
|
216
|
|
|
public static function bigbluebuttonbn_index_display_room_actions($moderator, $course, $bigbluebuttonbn, $groupobj = null) { |
|
217
|
|
|
$actions = ''; |
|
218
|
|
|
if ($moderator) { |
|
219
|
|
|
$actions .= '<form name="form1" method="post" action="">'."\n"; |
|
220
|
|
|
$actions .= ' <INPUT type="hidden" name="id" value="'.$course->id.'">'."\n"; |
|
221
|
|
|
$actions .= ' <INPUT type="hidden" name="a" value="'.$bigbluebuttonbn->id.'">'."\n"; |
|
222
|
|
|
if ($groupobj != null) { |
|
223
|
|
|
$actions .= ' <INPUT type="hidden" name="g" value="'.$groupobj->id.'">'."\n"; |
|
224
|
|
|
} |
|
225
|
|
|
$actions .= ' <INPUT type="submit" name="submit" value="' . |
|
226
|
|
|
get_string('view_conference_action_end', 'bigbluebuttonbn') . |
|
227
|
|
|
'" class="btn btn-primary btn-sm" onclick="return confirm(\'' . |
|
228
|
|
|
get_string('index_confirm_end', 'bigbluebuttonbn') . '\')">' . "\n"; |
|
229
|
|
|
$actions .= '</form>'."\n"; |
|
230
|
|
|
} |
|
231
|
|
|
return $actions; |
|
232
|
|
|
} |
|
233
|
|
|
} |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.