forked from blindsidenetworks-ps/moodle-mod_bigbluebuttonbn
-
Notifications
You must be signed in to change notification settings - Fork 1
/
view.php
161 lines (141 loc) · 6.19 KB
/
view.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
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
<?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/>.
/**
* View a BigBlueButton room.
*
* @package mod_bigbluebuttonbn
* @copyright 2010 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
* @author Fred Dixon (ffdixon [at] blindsidenetworks [dt] com)
* @author Darko Miletic (darko.miletic [at] gmail [dt] com)
*/
use mod_bigbluebuttonbn\plugin;
require(__DIR__.'/../../config.php');
require_once(__DIR__.'/locallib.php');
require_once(__DIR__.'/viewlib.php');
$id = required_param('id', PARAM_INT);
$bn = optional_param('bn', 0, PARAM_INT);
$group = optional_param('group', 0, PARAM_INT);
$viewinstance = bigbluebuttonbn_view_validator($id, $bn); // In locallib.
if (!$viewinstance) {
print_error('view_error_url_missing_parameters', plugin::COMPONENT);
}
$cm = $viewinstance['cm'];
$course = $viewinstance['course'];
$bigbluebuttonbn = $viewinstance['bigbluebuttonbn'];
require_login($course, true, $cm);
// In locallib.
bigbluebuttonbn_event_log(\mod_bigbluebuttonbn\event\events::$events['view'], $bigbluebuttonbn);
// Additional info related to the course.
$bbbsession['course'] = $course;
$bbbsession['coursename'] = $course->fullname;
$bbbsession['cm'] = $cm;
$bbbsession['bigbluebuttonbn'] = $bigbluebuttonbn;
// In locallib.
bigbluebuttonbn_view_bbbsession_set($PAGE->context, $bbbsession);
// Validates if the BigBlueButton server is working.
// FIXME
if($bigbluebuttonbn->server > 0) {
$serverversion = bigbluebuttonbn_get_server_version($bigbluebuttonbn->server); // In locallib.
if ($serverversion === null) {
$errmsg = 'view_error_unable_join_student';
$errurl = '/course/view.php';
$errurlparams = ['id' => $bigbluebuttonbn->course];
if (0 && $bbbsession['administrator']) {
$errmsg = 'view_error_unable_join';
$errurl = '/admin/settings.php';
$errurlparams = ['section' => 'modsettingbigbluebuttonbn'];
} else if ($bbbsession['moderator']) {
$errmsg = 'view_error_unable_join_teacher';
}
print_error($errmsg, plugin::COMPONENT, new moodle_url($errurl, $errurlparams));
}
$bbbsession['serverversion'] = (string) $serverversion;
} else {
$bbbsession['serverversion'] = 2;
}
// Mark viewed by user (if required).
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
// Print the page header.
$PAGE->set_url('/mod/bigbluebuttonbn/view.php', ['id' => $cm->id]);
$PAGE->set_title($bigbluebuttonbn->name);
$PAGE->set_cacheable(false);
$PAGE->set_heading($course->fullname);
/** @var core_renderer $OUTPUT */
$OUTPUT;
bigbluebuttonbn_check_stop($id,true);
// Validate if the user is in a role allowed to join.
if (!has_any_capability(['moodle/category:manage', 'mod/bigbluebuttonbn:join'], $PAGE->context)) {
echo $OUTPUT->header();
echo $OUTPUT->confirm(
sprintf(
'<p>%s</p>%s',
get_string(isguestuser() ? 'view_noguests' : 'view_nojoin', plugin::COMPONENT),
get_string('liketologin')
),
get_login_url(),
new moodle_url('/course/view.php', ['id' => $course->id])
);
echo $OUTPUT->footer();
exit;
}
$activitystatus = bigbluebuttonbn_view_session_config($bbbsession, $id);
// Output starts.
echo $OUTPUT->header();
if(isset($course->startdate) && intval($course->startdate) > 0 && intval($course->startdate) > time()) {
echo "<h3 class='alert-warning'>",get_string('meeting_course_start','bigbluebuttonbn'),"</h3>";
}
if(isset($course->enddate) && intval($course->enddate) > 0 && intval($course->enddate) < time()) {
echo "<h3 class='alert-warning'>",get_string('meeting_course_end','bigbluebuttonbn'),"</h3>";
}
bigbluebuttonbn_view_groups($bbbsession);
bigbluebuttonbn_view_render($bbbsession, $activitystatus);
if (has_capability('mod/bigbluebuttonbn:managerecordings', $PAGE->context)) {
$recimpnum = $DB->count_records_sql("select count(id) from {bigbluebuttonbn_logs}
where courseid=? and bigbluebuttonbnid = ? and log=?",
[$COURSE->id,$bbbsession['bigbluebuttonbn']->id,'Import']);
if(!$recimpnum && $USER->id > 1 ) {
$copy = $DB->get_recordset_sql("
select distinct on(cid,bid,b.meetingid)
c.id as cid,c.shortname,cm.id as cmid,b.id as bid, b.name as bname, b.meetingid
from {bigbluebuttonbn} as b
inner join {course} as c on c.id = b.course
inner join {course_modules} as cm on cm.module = ? and cm.instance=b.id and cm.course = b.course
inner join {bigbluebuttonbn} as b2 on b.meetingid = b2.meetingid and b.course < b2.course
where b.meetingid = ? and b.course < ? order by cid,bid,b.meetingid",
[$bbbsession['cm']->module,$bbbsession['bigbluebuttonbn']->meetingid,$COURSE->id]);
if(is_array($copy) && count($copy)) {
foreach($copy as $c) {
#pre_print_r($c);
$recnum = $DB->count_records_sql("select count(id) from {bigbluebuttonbn_rec} where meetingid=?",
[$c->meetingid.'-'.$c->cid.'-'.$c->bid]);
if($recnum > 0)
echo "<p>Имеются записи в курсе "{$c->shortname}" <a href=\"{$CFG->wwwroot}/mod/bigbluebuttonbn/view.php?id={$c->cmid}\"> $c->bname </a>,".
" при необходимости, импортируйте записи из него.</p>";
break;
}
}
}
echo '<p><a href="'.$CFG->wwwroot.'/mod/bigbluebuttonbn/viewinfo.php?id='.$cm->id.'">Users info</a></p>';
}
// Output finishes.
echo $OUTPUT->footer();
// Shows version as a comment.
echo '<!-- '.$bbbsession['originTag'].' -->'."\n";
// Initialize session variable used across views.
$SESSION->bigbluebuttonbn_bbbsession = $bbbsession;