Esempio n. 1
0
function bigbluebuttonbn_view_joining($bbbsession, $context, $streamline)
{
    global $CFG, $DB;
    $joining = false;
    // If user is administrator, moderator or if is viewer and no waiting is required
    if ($bbbsession['flag']['administrator'] || $bbbsession['flag']['moderator'] || !$bbbsession['flag']['wait']) {
        //
        // Join directly
        //
        $metadata = array("meta_origin" => $bbbsession['origin'], "meta_originVersion" => $bbbsession['originVersion'], "meta_originServerName" => $bbbsession['originServerName'], "meta_originServerCommonName" => $bbbsession['originServerCommonName'], "meta_originTag" => $bbbsession['originTag'], "meta_context" => $bbbsession['context'], "meta_contextActivity" => $bbbsession['contextActivity'], "meta_contextActivityDescription" => $bbbsession['contextActivityDescription'], "meta_recording" => $bbbsession['textflag']['record']);
        $response = bigbluebuttonbn_getCreateMeetingArray($bbbsession['meetingname'], $bbbsession['meetingid'], $bbbsession['welcome'], $bbbsession['modPW'], $bbbsession['viewerPW'], $bbbsession['salt'], $bbbsession['url'], $bbbsession['logoutURL'], $bbbsession['textflag']['record'], $bbbsession['timeduration'], $bbbsession['voicebridge'], $metadata);
        if (!$response) {
            // If the server is unreachable, then prompts the user of the necessary action
            if ($bbbsession['flag']['administrator']) {
                print_error('view_error_unable_join', 'streamline', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn');
            } else {
                if ($bbbsession['flag']['moderator']) {
                    print_error('view_error_unable_join_teacher', 'streamline', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn');
                } else {
                    print_error('view_error_unable_join_student', 'streamline', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn');
                }
            }
        } else {
            if ($response['returncode'] == "FAILED") {
                // The meeting was not created
                $error_key = bigbluebuttonbn_get_error_key($response['messageKey'], 'view_error_create');
                if (!$error_key) {
                    print_error($response['message'], 'streamline');
                } else {
                    print_error($error_key, 'streamline');
                }
            } else {
                if ($response['hasBeenForciblyEnded'] == "true") {
                    print_error(get_string('index_error_forciblyended', 'streamline'));
                } else {
                    ///////////////Everything is ok /////////////////////
                    /// Moodle event logger: Create an event for meeting created
                    if ($CFG->version < '2014051200') {
                        //This is valid before v2.7
                        add_to_log($bbbsession['courseid'], 'streamline', 'meeting created', '', $streamline->name, $bbbsession['cm']->id);
                    } else {
                        //This is valid after v2.7
                        $event = \mod_streamline\event\bigbluebuttonbn_meeting_created::create(array('context' => $context, 'objectid' => $streamline->id));
                        $event->trigger();
                    }
                    /// Internal logger: Instert a record with the meeting created
                    bigbluebuttonbn_log($bbbsession, 'Create');
                    if (groups_get_activity_groupmode($bbbsession['cm']) > 0 && count(groups_get_activity_allowed_groups($bbbsession['cm'])) > 1) {
                        print "<br>" . get_string('view_groups_selection', 'streamline') . "&nbsp;&nbsp;<input type='button' onClick='M.mod_streamline.joinURL()' value='" . get_string('view_groups_selection_join', 'streamline') . "'>";
                    } else {
                        $joining = true;
                        if ($bbbsession['flag']['administrator'] || $bbbsession['flag']['moderator']) {
                            print "<br />" . get_string('view_login_moderator', 'streamline') . "<br /><br />";
                        } else {
                            print "<br />" . get_string('view_login_viewer', 'streamline') . "<br /><br />";
                        }
                        print "<center><img src='pix/loading.gif' /></center>";
                    }
                    /// Moodle event logger: Create an event for meeting joined
                    if ($CFG->version < '2014051200') {
                        //This is valid before v2.7
                        add_to_log($bbbsession['courseid'], 'streamline', 'meeting joined', '', $streamline->name, $bbbsession['cm']->id);
                    } else {
                        //This is valid after v2.7
                        $event = \mod_streamline\event\bigbluebuttonbn_meeting_joined::create(array('context' => $context, 'objectid' => $streamline->id));
                        $event->trigger();
                    }
                }
            }
        }
    } else {
        //
        // "Viewer" && Waiting for moderator is required;
        //
        $joining = true;
        print "<div align='center'>";
        if (bigbluebuttonbn_wrap_simplexml_load_file(bigbluebuttonbn_getIsMeetingRunningURL($bbbsession['meetingid'], $bbbsession['url'], $bbbsession['salt'])) == "true") {
            /// Since the meeting is already running, we just join the session
            print "<br />" . get_string('view_login_viewer', 'streamline') . "<br /><br />";
            print "<center><img src='pix/loading.gif' /></center>";
            /// Moodle event logger: Create an event for meeting joined
            if ($CFG->version < '2014051200') {
                //This is valid before v2.7
                add_to_log($bbbsession['courseid'], 'streamline', 'meeting joined', '', $streamline->name, $bbbsession['cm']->id);
            } else {
                //This is valid after v2.7
                $event = \mod_streamline\event\bigbluebuttonbn_meeting_joined::create(array('context' => $context, 'objectid' => $streamline->id));
                $event->trigger();
            }
        } else {
            /// Since the meeting is not running, the spining wheel is shown
            print "<br />" . get_string('view_wait', 'streamline') . "<br /><br />";
            print '<center><img src="pix/polling.gif"></center>';
        }
        print "</div>";
    }
    return $joining;
}
Esempio n. 2
0
        header("HTTP/1.0 401 Unauthorized");
    } else {
        $salt = trim($CFG->BigBlueButtonSaltKey);
        $url = trim(trim($CFG->ServerURLforBigBlueButton), '/') . '/';
        try {
            $ismeetingrunning = streamline_isMeetingRunning($meetingID, $url, $salt) ? 'true' : 'false';
            if ($ismeetingrunning === 'true') {
                ///log the join event
                if ($streamline = $DB->get_record('streamline', array('id' => $id), '*', MUST_EXIST)) {
                    $course = $DB->get_record('course', array('id' => $streamline->course), '*', MUST_EXIST);
                    $cm = get_coursemodule_from_instance('streamline', $streamline->id, $course->id, false, MUST_EXIST);
                    /// Moodle event logger: Create an event for meeting joined
                    if ($CFG->version < '2014051200') {
                        //This is valid before v2.7
                        add_to_log($course->id, 'streamline', 'meeting joined', '', $streamline->name, $cm->id);
                    } else {
                        //This is valid after v2.7
                        $context = context_module::instance($cm->id);
                        $event = \mod_streamline\event\bigbluebuttonbn_meeting_joined::create(array('context' => $context, 'objectid' => $streamline->id));
                        $event->trigger();
                    }
                }
            }
            echo $callback . '({ "status": "' . $ismeetingrunning . '" });';
        } catch (Exception $e) {
            header("HTTP/1.0 502 Bad Gateway. " . $e->getMessage());
        }
    }
} else {
    header("HTTP/1.0 400 Bad Request. " . $error);
}