Differences Between: [Versions 400 and 402]
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 for BigBlueButton interaction. 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 */ 25 26 use core\notification; 27 use mod_bigbluebuttonbn\instance; 28 use mod_bigbluebuttonbn\local\exceptions\server_not_available_exception; 29 use mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy; 30 use mod_bigbluebuttonbn\logger; 31 use mod_bigbluebuttonbn\meeting; 32 use mod_bigbluebuttonbn\plugin; 33 use mod_bigbluebuttonbn\recording; 34 35 require_once(dirname(dirname(dirname(__FILE__))) . '/config.php'); 36 37 global $SESSION, $PAGE, $CFG, $DB, $USER, $OUTPUT; 38 39 $action = required_param('action', PARAM_TEXT); 40 $id = optional_param('id', 0, PARAM_INT); 41 $bn = optional_param('bn', 0, PARAM_INT); 42 $rid = optional_param('rid', '', PARAM_TEXT); 43 $rtype = optional_param('rtype', 'presentation', PARAM_TEXT); 44 $errors = optional_param('errors', '', PARAM_TEXT); 45 $timeline = optional_param('timeline', 0, PARAM_INT); 46 $index = optional_param('index', 0, PARAM_INT); 47 $group = optional_param('group', -1, PARAM_INT); 48 49 // Get the bbb instance from either the cmid (id), or the instanceid (bn). 50 if ($id) { 51 $instance = instance::get_from_cmid($id); 52 } else { 53 if ($bn) { 54 $instance = instance::get_from_instanceid($bn); 55 } 56 } 57 58 if (!$instance) { 59 $courseid = optional_param('courseid', 1, PARAM_INT); 60 \core\notification::error(get_string('general_error_not_found', 'mod_bigbluebuttonbn', $id)); 61 redirect(new moodle_url('/course/view.php', ['id' => $courseid])); 62 } 63 64 $cm = $instance->get_cm(); 65 $course = $instance->get_course(); 66 $bigbluebuttonbn = $instance->get_instance_data(); 67 $context = $instance->get_context(); 68 69 require_login($course, true, $cm); 70 71 // Note : this uses the group optional_param as a value to decide which groupid. 72 $groupid = groups_get_activity_group($cm, true) ?: null; 73 if ($groupid) { 74 $instance->set_group_id($groupid); 75 } 76 77 // Print the page header. 78 $PAGE->set_context($context); 79 $PAGE->set_url('/mod/bigbluebuttonbn/bbb_view.php', ['id' => $cm->id, 'bigbluebuttonbn' => $bigbluebuttonbn->id]); 80 $PAGE->set_title(format_string($bigbluebuttonbn->name)); 81 $PAGE->set_cacheable(false); 82 $PAGE->set_heading($course->fullname); 83 $PAGE->blocks->show_only_fake_blocks(); 84 85 switch (strtolower($action)) { 86 case 'logout': 87 if (isset($errors) && $errors != '') { 88 $errors = (array) json_decode(urldecode($errors)); 89 $msgerrors = ''; 90 foreach ($errors as $error) { 91 $msgerrors .= html_writer::tag('p', $error->{'message'}, ['class' => 'alert alert-danger']) . "\n"; 92 } 93 throw new moodle_exception('view_error_bigbluebutton', 'bigbluebuttonbn', 94 $CFG->wwwroot . '/mod/bigbluebuttonbn/view.php?id=' . $id, $msgerrors, $errors); 95 } 96 97 if (empty($bigbluebuttonbn)) { 98 echo get_string('view_message_tab_close', 'bigbluebuttonbn'); 99 die(); 100 } 101 // Moodle event logger: Create an event for meeting left. 102 logger::log_meeting_left_event($instance); 103 104 // Update the cache. 105 $meeting = new meeting($instance); 106 $meeting->update_cache(); 107 108 // Check the origin page. 109 $select = "userid = ? AND log = ?"; 110 $params = [ 111 'userid' => $USER->id, 112 'log' => logger::EVENT_JOIN, 113 ]; 114 $accesses = $DB->get_records_select('bigbluebuttonbn_logs', $select, $params, 'id ASC', 'id, meta', 1); 115 $lastaccess = end($accesses); 116 if (!empty($lastaccess->meta)) { 117 $lastaccess = json_decode($lastaccess->meta); 118 // If the user acceded from Timeline it should be redirected to the Dashboard. 119 if (isset($lastaccess->origin) && $lastaccess->origin == logger::ORIGIN_TIMELINE) { 120 redirect($CFG->wwwroot . '/my/'); 121 } 122 } 123 break; 124 case 'join': 125 if (empty($bigbluebuttonbn)) { 126 throw new moodle_exception('view_error_unable_join', 'bigbluebuttonbn'); 127 break; 128 } 129 // Check the origin page. 130 $origin = logger::ORIGIN_BASE; 131 if ($timeline) { 132 $origin = logger::ORIGIN_TIMELINE; 133 } else if ($index) { 134 $origin = logger::ORIGIN_INDEX; 135 } 136 137 try { 138 $url = meeting::join_meeting($instance, $origin); 139 redirect($url); 140 } catch (server_not_available_exception $e) { 141 bigbluebutton_proxy::handle_server_not_available($instance); 142 } 143 // We should never reach this point. 144 break; 145 146 case 'play': 147 $recording = recording::get_record(['id' => $rid]); 148 if ($href = $recording->get_remote_playback_url($rtype)) { 149 logger::log_recording_played_event($instance, $rid); 150 redirect(urldecode($href)); 151 } else { 152 notification::add(get_string('recordingurlnotfound', 'mod_bigbluebuttonbn'), notification::ERROR); 153 redirect($instance->get_view_url()); 154 } 155 // We should never reach this point. 156 break; 157 } 158 // When we reach this point, we can close the tab or window where BBB was opened. 159 echo $OUTPUT->header(); 160 // Behat does not like when we close the Windows as it is expecting to locate 161 // on click part of the pages (bug with selenium raising an exception). So this is a workaround. 162 if (!defined('BEHAT_SITE_RUNNING')) { 163 $PAGE->requires->js_call_amd('mod_bigbluebuttonbn/rooms', 'setupWindowAutoClose'); 164 } 165 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body