function bigbluebuttonbn_event_log_standard($event_type, $bigbluebuttonbn, $context, $cm)
{
    $context = context_module::instance($cm->id);
    $event_properties = array('context' => $context, 'objectid' => $bigbluebuttonbn->id);
    switch ($event_type) {
        case BIGBLUEBUTTON_EVENT_MEETING_JOINED:
            $event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_meeting_joined::create($event_properties);
            break;
        case BIGBLUEBUTTON_EVENT_MEETING_CREATED:
            $event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_meeting_created::create($event_properties);
            break;
        case BIGBLUEBUTTON_EVENT_MEETING_ENDED:
            $event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_meeting_ended::create($event_properties);
            break;
        case BIGBLUEBUTTON_EVENT_MEETING_LEFT:
            $event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_meeting_left::create($event_properties);
            break;
        case BIGBLUEBUTTON_EVENT_RECORDING_PUBLISHED:
            $event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_recording_published::create($event_properties);
            break;
        case BIGBLUEBUTTON_EVENT_RECORDING_UNPUBLISHED:
            $event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_recording_unpublished::create($event_properties);
            break;
        case BIGBLUEBUTTON_EVENT_RECORDING_DELETED:
            $event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_recording_deleted::create($event_properties);
            break;
        case BIGBLUEBUTTON_EVENT_ACTIVITY_VIEWED:
            $event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_activity_viewed::create($event_properties);
            break;
        case BIGBLUEBUTTON_EVENT_ACTIVITY_MANAGEMENT_VIEWED:
            $event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_activity_management_viewed::create($event_properties);
            break;
    }
    $event->trigger();
}
    print_error('You must specify a course_module ID or an instance ID');
}
require_login($course, true, $cm);
if ($CFG->version < '2013111800') {
    //This is valid before v2.6
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
} else {
    //This is valid after v2.6
    $context = context_module::instance($cm->id);
}
if ($CFG->version < '2014051200') {
    //This is valid before v2.7
    add_to_log($course->id, 'bigbluebuttonbn', 'meeting left', '', $bigbluebuttonbn->name, $cm->id);
} else {
    //This is valid after v2.7
    $event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_meeting_left::create(array('context' => $context, 'objectid' => $bigbluebuttonbn->id));
    $event->trigger();
}
$PAGE->set_context($context);
$PAGE->set_url('/mod/bigbluebuttonbn/view_end.php', array('id' => $cm->id));
if ($bigbluebuttonbn->newwindow == 1) {
    echo $OUTPUT->header();
    $PAGE->requires->js_init_call('M.mod_bigbluebuttonbn.viewend_CloseWindow');
    echo $OUTPUT->footer();
} else {
    if (has_capability('mod/bigbluebuttonbn:moderate', $context)) {
        header('Location: ' . $CFG->wwwroot . '/mod/bigbluebuttonbn/index.php?id=' . $bigbluebuttonbn->course);
    } else {
        header('Location: ' . $CFG->wwwroot . '/course/view.php?id=' . $bigbluebuttonbn->course);
    }
}