Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   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   * Intermediator for handling requests from the BigBlueButton server.
  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    Darko Miletic  (darko.miletic [at] gmail [dt] com)
  25   */
  26  
  27  // We should not have any require login or MOODLE_INTERNAL Check in this file.
  28  // phpcs:disable moodle.Files.MoodleInternal.MoodleInternalGlobalState,moodle.Files.RequireLogin.Missing
  29  require(__DIR__ . '/../../config.php');
  30  
  31  use Firebase\JWT\Key;
  32  use mod_bigbluebuttonbn\broker;
  33  use mod_bigbluebuttonbn\instance;
  34  use mod_bigbluebuttonbn\local\config;
  35  use mod_bigbluebuttonbn\meeting;
  36  
  37  global $PAGE, $USER, $CFG, $SESSION, $DB;
  38  
  39  $params = $_REQUEST;
  40  
  41  $broker = new broker();
  42  $error = $broker->validate_parameters($params);
  43  if (!empty($error)) {
  44      header('HTTP/1.0 400 Bad Request. ' . $error);
  45      return;
  46  }
  47  
  48  $action = $params['action'];
  49  
  50  $instance = instance::get_from_instanceid($params['bigbluebuttonbn']);
  51  if (empty($instance)) {
  52      header('HTTP/1.0 410 Gone. The activity may have been deleted');
  53      return;
  54  }
  55  
  56  $PAGE->set_context($instance->get_context());
  57  
  58  try {
  59      switch (strtolower($action)) {
  60          case 'recording_ready':
  61              broker::process_recording_ready($instance, $params);
  62              return;
  63          case 'meeting_events':
  64              // When meeting_events callback is implemented by BigBlueButton, Moodle receives a POST request
  65              // which is processed in the function using super globals.
  66              broker::process_meeting_events($instance);
  67              return;
  68      }
  69      header("HTTP/1.0 400 Bad request. The action '{$action}' does not exist");
  70  } catch (Exception $e) {
  71      header('HTTP/1.0 500 Internal Server Error. ' . $e->getMessage());
  72  }