|
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
|
|
|
* View a BigBlueButton room. |
|
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 Jesus Federico (jesus [at] blindsidenetworks [dt] com) |
|
24
|
|
|
* @author Fred Dixon (ffdixon [at] blindsidenetworks [dt] com) |
|
25
|
|
|
* @author Darko Miletic (darko.miletic [at] gmail [dt] com) |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
use mod_bigbluebuttonbn\plugin; |
|
29
|
|
|
|
|
30
|
|
|
require(__DIR__.'/../../config.php'); |
|
31
|
|
|
require_once(__DIR__.'/locallib.php'); |
|
32
|
|
|
require_once(__DIR__.'/viewlib.php'); |
|
33
|
|
|
|
|
34
|
|
|
$id = required_param('id', PARAM_INT); |
|
35
|
|
|
$bn = optional_param('bn', 0, PARAM_INT); |
|
36
|
|
|
$group = optional_param('group', 0, PARAM_INT); |
|
37
|
|
|
|
|
38
|
|
|
$viewinstance = bigbluebuttonbn_view_validator($id, $bn); // In locallib. |
|
39
|
|
|
if (!$viewinstance) { |
|
40
|
|
|
print_error('view_error_url_missing_parameters', plugin::COMPONENT); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
$cm = $viewinstance['cm']; |
|
44
|
|
|
$course = $viewinstance['course']; |
|
45
|
|
|
$bigbluebuttonbn = $viewinstance['bigbluebuttonbn']; |
|
46
|
|
|
|
|
47
|
|
|
require_login($course, true, $cm); |
|
48
|
|
|
|
|
49
|
|
|
// In locallib. |
|
50
|
|
|
bigbluebuttonbn_event_log(\mod_bigbluebuttonbn\event\events::$events['view'], $bigbluebuttonbn); |
|
51
|
|
|
|
|
52
|
|
|
// Additional info related to the course. |
|
53
|
|
|
$bbbsession['course'] = $course; |
|
54
|
|
|
$bbbsession['coursename'] = $course->fullname; |
|
55
|
|
|
$bbbsession['cm'] = $cm; |
|
56
|
|
|
$bbbsession['bigbluebuttonbn'] = $bigbluebuttonbn; |
|
57
|
|
|
// In locallib. |
|
58
|
|
|
bigbluebuttonbn_view_bbbsession_set($PAGE->context, $bbbsession); |
|
59
|
|
|
|
|
60
|
|
|
// Validates if the BigBlueButton server is working. |
|
61
|
|
|
$serverversion = bigbluebuttonbn_get_server_version(); // In locallib. |
|
62
|
|
|
if ($serverversion === null) { |
|
63
|
|
|
$errmsg = 'view_error_unable_join_student'; |
|
64
|
|
|
$errurl = '/course/view.php'; |
|
65
|
|
|
$errurlparams = ['id' => $bigbluebuttonbn->course]; |
|
66
|
|
|
if ($bbbsession['administrator']) { |
|
67
|
|
|
$errmsg = 'view_error_unable_join'; |
|
68
|
|
|
$errurl = '/admin/settings.php'; |
|
69
|
|
|
$errurlparams = ['section' => 'modsettingbigbluebuttonbn']; |
|
70
|
|
|
} else if ($bbbsession['moderator']) { |
|
71
|
|
|
$errmsg = 'view_error_unable_join_teacher'; |
|
72
|
|
|
} |
|
73
|
|
|
print_error($errmsg, plugin::COMPONENT, new moodle_url($errurl, $errurlparams)); |
|
74
|
|
|
} |
|
75
|
|
|
$bbbsession['serverversion'] = (string) $serverversion; |
|
76
|
|
|
|
|
77
|
|
|
// Mark viewed by user (if required). |
|
78
|
|
|
$completion = new completion_info($course); |
|
79
|
|
|
$completion->set_module_viewed($cm); |
|
80
|
|
|
|
|
81
|
|
|
// Print the page header. |
|
82
|
|
|
$PAGE->set_url('/mod/bigbluebuttonbn/view.php', ['id' => $cm->id]); |
|
83
|
|
|
$PAGE->set_title($bigbluebuttonbn->name); |
|
84
|
|
|
$PAGE->set_cacheable(false); |
|
85
|
|
|
$PAGE->set_heading($course->fullname); |
|
86
|
|
|
|
|
87
|
|
|
/** @var core_renderer $OUTPUT */ |
|
88
|
|
|
$OUTPUT; |
|
89
|
|
|
|
|
90
|
|
|
// Validate if the user is in a role allowed to join. |
|
91
|
|
|
if (!has_any_capability(['moodle/category:manage', 'mod/bigbluebuttonbn:join'], $PAGE->context)) { |
|
92
|
|
|
echo $OUTPUT->header(); |
|
93
|
|
|
echo $OUTPUT->confirm( |
|
94
|
|
|
sprintf( |
|
95
|
|
|
'<p>%s</p>%s', |
|
96
|
|
|
get_string(isguestuser() ? 'view_noguests' : 'view_nojoin', plugin::COMPONENT), |
|
97
|
|
|
get_string('liketologin') |
|
98
|
|
|
), |
|
99
|
|
|
get_login_url(), |
|
100
|
|
|
new moodle_url('/course/view.php', ['id' => $course->id]) |
|
101
|
|
|
); |
|
102
|
|
|
echo $OUTPUT->footer(); |
|
103
|
|
|
exit; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
$activitystatus = bigbluebuttonbn_view_session_config($bbbsession, $id, $bn); |
|
107
|
|
|
|
|
108
|
|
|
// Output starts. |
|
109
|
|
|
echo $OUTPUT->header(); |
|
110
|
|
|
|
|
111
|
|
|
bigbluebuttonbn_view_groups($bbbsession); |
|
112
|
|
|
|
|
113
|
|
|
bigbluebuttonbn_view_render($bbbsession, $activitystatus); |
|
114
|
|
|
|
|
115
|
|
|
// Output finishes. |
|
116
|
|
|
echo $OUTPUT->footer(); |
|
117
|
|
|
|
|
118
|
|
|
// Shows version as a comment. |
|
119
|
|
|
echo '<!-- '.$bbbsession['originTag'].' -->'."\n"; |
|
120
|
|
|
|
|
121
|
|
|
// Initialize session variable used across views. |
|
122
|
|
|
$SESSION->bigbluebuttonbn_bbbsession = $bbbsession; |