Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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\instance;
29
use mod_bigbluebuttonbn\local\config;
30
use mod_bigbluebuttonbn\local\exceptions\server_not_available_exception;
31
use mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy;
32
use mod_bigbluebuttonbn\logger;
33
use mod_bigbluebuttonbn\output\view_page;
34
use mod_bigbluebuttonbn\plugin;
35
 
36
require(__DIR__ . '/../../config.php');
37
global $OUTPUT, $PAGE;
38
 
39
// Get the bbb instance from either the cmid (id), or the instanceid (bn).
40
$id = optional_param('id', 0, PARAM_INT);
41
if ($id) {
42
    $instance = instance::get_from_cmid($id);
43
} else {
44
    $bn = optional_param('bn', 0, PARAM_INT);
45
    if ($bn) {
46
        $instance = instance::get_from_instanceid($bn);
47
    }
48
}
49
 
50
if (!$instance) {
51
    throw new moodle_exception('view_error_url_missing_parameters', plugin::COMPONENT);
52
}
53
 
54
$cm = $instance->get_cm();
55
$course = $instance->get_course();
56
$bigbluebuttonbn = $instance->get_instance_data();
57
 
58
require_login($course, true, $cm);
59
 
60
$groupid = groups_get_activity_group($cm, true) ?: null;
61
if ($groupid) {
62
    $instance->set_group_id($groupid);
63
}
64
 
65
logger::log_instance_viewed($instance);
66
 
67
// Require a working server.
68
bigbluebutton_proxy::require_working_server($instance);
69
 
70
// Mark viewed by user (if required).
71
$completion = new completion_info($course);
72
$completion->set_module_viewed($cm);
73
 
74
// Print the page header.
75
$PAGE->set_url($instance->get_view_url());
76
$PAGE->set_title($cm->name);
77
$PAGE->set_cacheable(false);
78
$PAGE->set_heading($course->fullname);
79
 
80
// Output starts.
81
$renderer = $PAGE->get_renderer('mod_bigbluebuttonbn');
82
 
83
try {
84
    $renderedinfo = $renderer->render(new view_page($instance));
85
} catch (server_not_available_exception $e) {
86
    bigbluebutton_proxy::handle_server_not_available($instance);
87
}
88
 
89
echo $OUTPUT->header();
90
 
91
// Valid credentials have not been setup, then we output a message to teachers and admin.
92
if (config::server_credentials_invalid()) {
93
    if (has_capability('moodle/site:config', context_system::instance())) {
94
        $settingslink = new moodle_url('/admin/settings.php', ['section' => 'modsettingbigbluebuttonbn']);
95
        echo $OUTPUT->notification(get_string('settings_credential_warning', 'bigbluebuttonbn',
96
            ['settingslink' => $settingslink->out()]), 'notifywarning');
97
    } else if (has_capability('moodle/course:manageactivities', context_course::instance($course->id))) {
98
        echo $OUTPUT->notification(get_string('settings_credential_warning_no_capability', 'bigbluebuttonbn'), 'notifywarning');
99
    }
100
}
101
 
102
// Validate if the user is in a role allowed to join.
103
if (!$instance->can_join() && $instance->get_type() != instance::TYPE_RECORDING_ONLY) {
104
    if (isguestuser()) {
105
        notice(get_string('view_noguests', plugin::COMPONENT), get_login_url());
106
    } else {
107
        notice(
108
            get_string('view_nojoin', plugin::COMPONENT),
109
            new moodle_url('/course/view.php', ['id' => $course->id])
110
        );
111
    }
112
}
113
 
114
echo $renderedinfo;
115
 
116
// Output finishes.
117
echo $OUTPUT->footer();
118
 
119
// Shows version as a comment.
120
echo '<!-- ' . $instance->get_origin_data()->originTag . ' -->' . "\n";