Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
   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\exceptions\server_not_available_exception;
  30  use mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy;
  31  use mod_bigbluebuttonbn\logger;
  32  use mod_bigbluebuttonbn\output\view_page;
  33  use mod_bigbluebuttonbn\plugin;
  34  
  35  require(__DIR__ . '/../../config.php');
  36  global $OUTPUT, $PAGE;
  37  
  38  // Get the bbb instance from either the cmid (id), or the instanceid (bn).
  39  $id = optional_param('id', 0, PARAM_INT);
  40  if ($id) {
  41      $instance = instance::get_from_cmid($id);
  42  } else {
  43      $bn = optional_param('bn', 0, PARAM_INT);
  44      if ($bn) {
  45          $instance = instance::get_from_instanceid($bn);
  46      }
  47  }
  48  
  49  if (!$instance) {
  50      throw new moodle_exception('view_error_url_missing_parameters', plugin::COMPONENT);
  51  }
  52  
  53  $cm = $instance->get_cm();
  54  $course = $instance->get_course();
  55  $bigbluebuttonbn = $instance->get_instance_data();
  56  
  57  require_login($course, true, $cm);
  58  
  59  $groupid = groups_get_activity_group($cm, true) ?: null;
  60  if ($groupid) {
  61      $instance->set_group_id($groupid);
  62  }
  63  
  64  logger::log_instance_viewed($instance);
  65  
  66  // Require a working server.
  67  bigbluebutton_proxy::require_working_server($instance);
  68  
  69  // Mark viewed by user (if required).
  70  $completion = new completion_info($course);
  71  $completion->set_module_viewed($cm);
  72  
  73  // Print the page header.
  74  $PAGE->set_url($instance->get_view_url());
  75  $PAGE->set_title($cm->name);
  76  $PAGE->set_cacheable(false);
  77  $PAGE->set_heading($course->fullname);
  78  
  79  // Output starts.
  80  $renderer = $PAGE->get_renderer('mod_bigbluebuttonbn');
  81  
  82  try {
  83      $renderedinfo = $renderer->render(new view_page($instance));
  84  } catch (server_not_available_exception $e) {
  85      bigbluebutton_proxy::handle_server_not_available($instance);
  86  }
  87  
  88  echo $OUTPUT->header();
  89  
  90  // Validate if the user is in a role allowed to join.
  91  if (!$instance->can_join() && $instance->get_type() != instance::TYPE_RECORDING_ONLY) {
  92      if (isguestuser()) {
  93          notice(get_string('view_noguests', plugin::COMPONENT), get_login_url());
  94      } else {
  95          notice(
  96              get_string('view_nojoin', plugin::COMPONENT),
  97              new moodle_url('/course/view.php', ['id' => $course->id])
  98          );
  99      }
 100  }
 101  
 102  echo $renderedinfo;
 103  
 104  // Output finishes.
 105  echo $OUTPUT->footer();
 106  
 107  // Shows version as a comment.
 108  echo '<!-- ' . $instance->get_origin_data()->originTag . ' -->' . "\n";