//meetingID, the BBB meetingID
$params['bigbluebuttonbn'] = optional_param('bigbluebuttonbn', 0, PARAM_INT);
$params['signed_parameters'] = optional_param('signed_parameters', '', PARAM_TEXT);
$endpoint = bigbluebuttonbn_get_cfg_server_url();
$shared_secret = bigbluebuttonbn_get_cfg_shared_secret();
$error = '';
if (empty($params['action'])) {
    $error = bigbluebuttonbn_bbb_broker_add_error($error, "Parameter [action] was not included");
} else {
    $error = bigbluebuttonbn_bbb_broker_validate_parameters($params);
    if (empty($error) && $params['action'] != "recording_ready") {
        if ($params['bigbluebuttonbn'] != 0) {
            $bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $params['bigbluebuttonbn']), '*', MUST_EXIST);
            $course = $DB->get_record('course', array('id' => $bigbluebuttonbn->course), '*', MUST_EXIST);
            $cm = get_coursemodule_from_instance('bigbluebuttonbn', $bigbluebuttonbn->id, $course->id, false, MUST_EXIST);
            $context = bigbluebuttonbn_get_context_module($cm->id);
        }
        if (isset($SESSION->bigbluebuttonbn_bbbsession) && !is_null($SESSION->bigbluebuttonbn_bbbsession)) {
            $bbbsession = $SESSION->bigbluebuttonbn_bbbsession;
        } else {
            $error = bigbluebuttonbn_bbb_broker_add_error($error, "No session variable set");
        }
    }
}
header('Content-Type: application/javascript; charset=utf-8');
if (empty($error)) {
    if (!isloggedin() && $PAGE->course->id == SITEID) {
        $userid = guest_user()->id;
    } else {
        $userid = $USER->id;
    }
/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @param object $bigbluebuttonbn An object from the form in mod_form.php
 * @return boolean Success/Fail
 */
function bigbluebuttonbn_update_instance($data, $mform)
{
    global $DB, $CFG;
    $data->id = $data->instance;
    $draftitemid = isset($data->presentation) ? $data->presentation : null;
    $context = bigbluebuttonbn_get_context_module($data->coursemodule);
    bigbluebuttonbn_process_pre_save($data);
    unset($data->presentation);
    $DB->update_record("bigbluebuttonbn", $data);
    bigbluebuttonbn_update_media_file($data->id, $context, $draftitemid);
    bigbluebuttonbn_process_post_save($data);
    return true;
}