/**
 * Given an ID of an instance of this module,
 * this function will permanently delete the instance
 * and any data that depends on it.
 *
 * @param int $id Id of the module instance
 * @return boolean Success/Failure
 */
function bigbluebuttonbn_delete_instance($id)
{
    global $CFG;
    if (!($bigbluebuttonbn = get_record('bigbluebuttonbn', 'id', $id))) {
        return false;
    }
    $result = true;
    //
    // End the session associated with this instance (if it's running)
    //
    $meetingID = $bigbluebuttonbn->meetingid;
    $modPW = $bigbluebuttonbn->moderatorpass;
    $url = trim(trim($CFG->bigbluebuttonbnServerURL), '/') . '/';
    $salt = trim($CFG->bigbluebuttonbnSecuritySalt);
    $getArray = BigBlueButtonBN::endMeeting($meetingID, $modPW, $url, $salt);
    if (!delete_records('bigbluebuttonbn', 'id', $bigbluebuttonbn->id)) {
        //echo $endURL = '<a href='.BBBMeeting::endMeeting( $mToken, "mp", getBBBServerIP(), $salt ).'>'."End Meeting".'</a>';
        #switch to remove the meetingname
        #    	  BBBMeeting::endMeeting( $bigbluebuttonbn->, "mp", getBBBServerIP(), $bigbluebuttonbn->salt );
        $result = false;
    }
    return $result;
}
<?php

/**
 * Check to see if the meeting is active. 
 * 
 * Authors:
 *    Fred Dixon  (ffdixon [at] blindsidenetworks [dt] com)
 *    Jesus Federico  (jesus [at] blindsidenetworks [dt] com)    
 * 
 * @package   mod_bigbluebuttonbn
 * @copyright 2010-2012 Blindside Networks 
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later
 */
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once dirname(__FILE__) . '/lib.php';
$name = $_GET['name'];
$salt = trim($CFG->BigBlueButtonBNSecuritySalt);
$url = trim(trim($CFG->BigBlueButtonBNServerURL), '/') . '/';
echo BigBlueButtonBN::getMeetingXML($name, $url, $salt);
 $view_recording_list_actionbar_show = get_string('view_recording_list_actionbar_show', 'bigbluebuttonbn');
 $view_recording_list_actionbar_delete = get_string('view_recording_list_actionbar_delete', 'bigbluebuttonbn');
 if (isset($recordingsbn) && !isset($recordingsbn['messageKey'])) {
     foreach ($recordingsbn as $recording) {
         if ($admin == 'true' || $recording['published'] == 'true') {
             $meta_course = isset($recording['meta_course']) ? str_replace('"', '\\"', $recording['meta_course']) : '';
             $meta_activity = isset($recording['meta_activity']) ? str_replace('"', '\\"', $recording['meta_activity']) : '';
             $meta_description = isset($recording['meta_description']) ? str_replace('"', '\\"', $recording['meta_description']) : '';
             $actionbar = '';
             if ($admin == 'true') {
                 $deleteURL = BigBlueButtonBN::deleteRecordingsURL($recording['recordID'], $url, $salt);
                 if ($recording['published'] == 'true') {
                     $publishURL = BigBlueButtonBN::setPublishRecordingsURL($recording['recordID'], 'false', $url, $salt);
                     $actionbar = "<a id='actionbar-publish-a-" . $recording['recordID'] . "' title='" . $view_recording_list_actionbar_hide . "' href='#'><img id='actionbar-publish-img-" . $recording['recordID'] . "' src='pix/hide.gif' class='iconsmall' onClick='actionCall(\\\"" . $publishURL . "\\\", \\\"publish\\\", \\\"" . $recording['recordID'] . "\\\")'   /></a>";
                 } else {
                     $publishURL = BigBlueButtonBN::setPublishRecordingsURL($recording['recordID'], 'true', $url, $salt);
                     $actionbar = "<a id='actionbar-publish-a-" . $recording['recordID'] . "' title='" . $view_recording_list_actionbar_show . "' href='#'><img id='actionbar-publish-img-" . $recording['recordID'] . "' src='pix/show.gif' class='iconsmall' onClick='actionCall(\\\"" . $publishURL . "\\\", \\\"publish\\\", \\\"" . $recording['recordID'] . "\\\")'   /></a>";
                 }
                 $actionbar .= "<a id='actionbar-delete-a-" . $recording['recordID'] . "' title='" . $view_recording_list_actionbar_delete . "' href='#'><img id='actionbar-delete-img-" . $recording['recordID'] . "' src='pix/delete.gif' class='iconsmall' alt='Delete' onClick='actionCall(\\\"" . $deleteURL . "\\\", \\\"delete\\\", \\\"" . $recording['recordID'] . "\\\")'   /></a>";
             }
             $type = '';
             foreach ($recording['playbacks'] as $playback) {
                 $type .= '<a href=\\"' . $playback['url'] . '\\" target=\\"_new\\">' . $playback['type'] . '</a>&#32;';
             }
             //Make sure the startTime is timestamp
             if (!is_numeric($recording['startTime'])) {
                 $date = new DateTime($recording['startTime']);
                 $recording['startTime'] = date_timestamp_get($date);
             } else {
                 $recording['startTime'] = $recording['startTime'] / 1000;
             }
 function definition()
 {
     global $CFG, $PAGE;
     //Validates if the BigBlueButton server is running
     //BigBlueButton server data
     $url = trim(trim($CFG->BigBlueButtonBNServerURL), '/') . '/';
     $salt = trim($CFG->BigBlueButtonBNSecuritySalt);
     $serverVersion = BigBlueButtonBN::getServerVersion($url);
     //
     if (!isset($serverVersion)) {
         print_error('general_error_unable_connect', 'bigbluebuttonbn', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn');
     } else {
         $xml = BigBlueButtonBN::_wrap_simplexml_load_file(BigBlueButtonBN::getMeetingsURL($url, $salt));
         if ($xml->returncode == 'FAILED') {
             print_error('general_error_unable_connect', 'bigbluebuttonbn', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn');
         }
     }
     $mform =& $this->_form;
     $current_activity =& $this->current;
     $mform->addElement('header', 'general', get_string('mod_form_block_general', 'bigbluebuttonbn'));
     $mform->addElement('text', 'name', get_string('mod_form_field_name', 'bigbluebuttonbn'), 'maxlength="64" size="32"');
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addElement('textarea', 'welcome', get_string('mod_form_field_welcome', 'bigbluebuttonbn'), 'wrap="virtual" rows="5" cols="60"');
     $mform->addHelpButton('welcome', 'mod_form_field_welcome', 'bigbluebuttonbn');
     //$mform->addElement('text', 'voicebridge', get_string('mod_form_field_voicebridge','bigbluebuttonbn'), 'maxlength="5" size="10"' );
     //$mform->setDefault( 'voicebridge', 0 );
     //$mform->addHelpButton('voicebridge', 'mod_form_field_voicebridge', 'bigbluebuttonbn');
     $mform->addElement('checkbox', 'newwindow', get_string('mod_form_field_newwindow', 'bigbluebuttonbn'));
     $mform->setDefault('newwindow', 0);
     $mform->addElement('checkbox', 'wait', get_string('mod_form_field_wait', 'bigbluebuttonbn'));
     $mform->setDefault('wait', 1);
     //-------------------------------------------------------------------------------
     // Second block starts here
     //-------------------------------------------------------------------------------
     if ($current_activity->section > 0) {
         //This is not a general activity, it is part of a week, so it can have schedule
         $mform->addElement('header', 'general', get_string('mod_form_block_schedule', 'bigbluebuttonbn'));
         $mform->addElement('date_time_selector', 'timeavailable', get_string('mod_form_field_availabledate', 'bigbluebuttonbn'), array('optional' => true));
         $mform->setDefault('timeavailable', time());
         $mform->addElement('date_time_selector', 'timedue', get_string('mod_form_field_duedate', 'bigbluebuttonbn'), array('optional' => true));
         $mform->setDefault('timedue', time() + 3600);
     }
     //-------------------------------------------------------------------------------
     // Second block ends here
     //-------------------------------------------------------------------------------
     //-------------------------------------------------------------------------------
     // Third block starts here
     //-------------------------------------------------------------------------------
     if ($serverVersion == '0.8') {
         $mform->addElement('header', 'general', get_string('mod_form_block_record', 'bigbluebuttonbn'));
         $mform->addElement('checkbox', 'record', get_string('mod_form_field_record', 'bigbluebuttonbn'));
         $mform->setDefault('record', 0);
         $mform->addElement('text', 'description', get_string('mod_form_field_description', 'bigbluebuttonbn'), 'maxlength="100" size="32"');
         $mform->addElement('duration', 'timeduration', get_string('mod_form_field_duration', 'bigbluebuttonbn'));
         //Set zero for unlimited
         $mform->setDefault('timeduration', 14400);
         $mform->addHelpButton('timeduration', 'mod_form_field_duration', 'bigbluebuttonbn');
     }
     //-------------------------------------------------------------------------------
     // Third block ends here
     //-------------------------------------------------------------------------------
     //-------------------------------------------------------------------------------
     // add standard elements, common to all modules
     $this->standard_coursemodule_elements();
     //$this->standard_hidden_coursemodule_elements();
     //-------------------------------------------------------------------------------
     // add standard buttons, common to all modules
     $this->add_action_buttons();
     if (isset($current_activity->add)) {
         // If is adding the activity, turn off the schedule by default & Take off the option [visible groups]
         if ($current_activity->section > 0) {
             //This is not a general activity, it is part of a week, so it can have schedule
             $PAGE->requires->js_init_call('M.mod_bigbluebuttonbn.modform_Adding_withSchedule');
         } else {
             $PAGE->requires->js_init_call('M.mod_bigbluebuttonbn.modform_Adding_withoutSchedule');
         }
     } else {
         // Take off the option [visible groups]
         $PAGE->requires->js_init_call('M.mod_bigbluebuttonbn.modform_Editting');
     }
 }
 $viewerList = "-";
 $moderatorList = "-";
 // print_object( $bigbluebuttonbn );
 if (!$bigbluebuttonbn->visible) {
     // Nothing to do
 } else {
     $modPW = get_field('bigbluebuttonbn', 'moderatorpass', 'name', $bigbluebuttonbn->name);
     $attPW = get_field('bigbluebuttonbn', 'viewerpass', 'name', $bigbluebuttonbn->name);
     // print "## $modPW ##";
     $joinURL = '<a href="view.php?id=' . $bigbluebuttonbn->coursemodule . '">' . format_string($bigbluebuttonbn->name) . '</a>';
     // $status = $bigbluebuttonbn->meetingid;
     //echo "XX";
     //
     // Output Users in the meeting
     //
     $getArray = BigBlueButtonBN::getMeetingInfoArray($bigbluebuttonbn->meetingid, $modPW, $url, $salt);
     // print_object( $getArray );
     if (!$getArray) {
         //
         // The server was unreachable
         //
         error(get_string('index_unable_display', 'bigbluebuttonbn'));
         return;
     }
     if (isset($getArray['messageKey'])) {
         //
         // There was an error returned
         //
         if ($info['messageKey'] == "checksumError") {
             error(get_string('index_checksum_error', 'bigbluebuttonbn'));
             return;
        ?>
";
                        }
                }
</script>
<?php 
    } else {
        //
        // Join as Viewer, no wait check
        //
        print "<br />" . get_string('view_login_viewer', 'bigbluebuttonbn') . "<br /><br />";
        print "<center><img src='loading.gif' /></center>";
        $response = BigBlueButtonBN::createMeetingArray("", $bigbluebuttonbn->meetingid, "", $modPW, $viewerPW, $salt, $url, $logoutURL);
        if (!$response) {
            // If the server is unreachable, then prompts the user of the necessary action
            error('Unable to join the meeting. Please contact your administrator.');
        }
        if ($response['returncode'] == "FAILED") {
            // The meeting was not created
            if ($response['messageKey'] == "checksumError") {
                error(get_string('index_checksum_error', 'bigbluebuttonbn'));
            } else {
                error($response['message']);
            }
        }
        $joinURL = BigBlueButtonBN::joinURL($bigbluebuttonbn->meetingid, $username, $viewerPW, $salt, $url, $userID);
        redirect($joinURL);
    }
}
// Finish the page
print_footer($course);
 public static function isServerRunning($URL)
 {
     $base_url_record = $URL . "api";
     $xml = BigBlueButtonBN::_wrap_simplexml_load_file($base_url_record);
     if ($xml && $xml->returncode == 'SUCCESS') {
         return true;
     } else {
         return false;
     }
 }
function bigbluebuttonbn_view_after($bbbsession)
{
    echo '<script type="text/javascript" >' . "\n";
    echo '    var joining = "false";' . "\n";
    echo '    var bigbluebuttonbn_view = "after";' . "\n";
    echo '    var view_recording_list_recording = "' . get_string('view_recording_list_recording', 'bigbluebuttonbn') . '";' . "\n";
    echo '    var view_recording_list_course = "' . get_string('view_recording_list_course', 'bigbluebuttonbn') . '";' . "\n";
    echo '    var view_recording_list_activity = "' . get_string('view_recording_list_activity', 'bigbluebuttonbn') . '";' . "\n";
    echo '    var view_recording_list_description = "' . get_string('view_recording_list_description', 'bigbluebuttonbn') . '";' . "\n";
    echo '    var view_recording_list_date = "' . get_string('view_recording_list_date', 'bigbluebuttonbn') . '";' . "\n";
    echo '    var view_recording_list_actionbar = "' . get_string('view_recording_list_actionbar', 'bigbluebuttonbn') . '";' . "\n";
    echo '</script>' . "\n";
    $recordingsArray = BigBlueButtonBN::getRecordingsArray($bbbsession['meetingid'], $bbbsession['url'], $bbbsession['salt']);
    if (!isset($recordingsArray) || array_key_exists('messageKey', $recordingsArray)) {
        // There are no recordings for this meeting
        if ($bbbsession['flag']['record']) {
            print_string('bbbnorecordings', 'bigbluebuttonbn');
        }
    } else {
        // Actually, there are recordings for this meeting
        echo '    <center>' . "\n";
        echo '      <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">' . "\n";
        echo '        <thead>' . "\n";
        echo '        </thead>' . "\n";
        echo '        <tbody>' . "\n";
        echo '        </tbody>' . "\n";
        echo '        <tfoot>' . "\n";
        echo '        </tfoot>' . "\n";
        echo '      </table>' . "\n";
        echo '    </center>' . "\n";
    }
}
Exemple #9
0
 /**
  * Creates a link in the links tool from the given videoconference recording
  * @param int ID of the item in the plugin_bbb_meeting table
  * @param string Hash identifying the recording, as provided by the API
  * @return mixed ID of the newly created link, or false on error
  * @assert (null, null) === false
  * @assert (1, null) === false
  * @assert (null, 'abcdefabcdefabcdefabcdef') === false
  */
 public function copy_record_to_link_tool($id, $record_id)
 {
     if (empty($id) or empty($record_id)) {
         return false;
     }
     require_once api_get_path(LIBRARY_PATH) . 'link.lib.php';
     $records = BigBlueButtonBN::getRecordingsArray($id, $this->url, $this->salt);
     if (!empty($records)) {
         foreach ($records as $record) {
             if ($record['recordID'] == $record_id) {
                 if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) {
                     foreach ($record['playbacks'] as $item) {
                         $link = new Link();
                         $params['url'] = $item['url'];
                         $params['title'] = 'bbb 1';
                         $id = $link->save($params);
                         return $id;
                     }
                 }
             }
         }
     }
     return false;
 }
Exemple #10
0
 /**
  * Creates a link in the links tool from the given videoconference recording
  * @param int ID of the item in the plugin_bbb_meeting table
  * @param string Hash identifying the recording, as provided by the API
  * @return mixed ID of the newly created link, or false on error
  * @assert (null, null) === false
  * @assert (1, null) === false
  * @assert (null, 'abcdefabcdefabcdefabcdef') === false
  */
 function copy_record_to_link_tool($id, $record_id)
 {
     if (empty($id) or empty($record_id)) {
         return false;
     }
     $records = BigBlueButtonBN::getRecordingsArray($id, $this->url, $this->salt);
     if (!empty($records)) {
         foreach ($records as $record) {
             //error_log($record['recordID']);
             if ($record['recordID'] == $record_id) {
                 if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) {
                     foreach ($record['playbacks'] as $item) {
                         $link = new Link();
                         $params['url'] = $item['url'];
                         $params['title'] = 'bbb 1';
                         $id = $link->save($params);
                         return $id;
                     }
                 }
             }
         }
     }
     return false;
 }
function displayBigBlueButtonRooms($url, $salt, $moderator, $course, $bigbluebuttonbn, $groupObj = null)
{
    $joinURL = null;
    $user = null;
    $result = null;
    $group = "-";
    $users = "-";
    $running = "-";
    $actions = "-";
    $viewerList = "-";
    $moderatorList = "-";
    $recording = "-";
    if (!$bigbluebuttonbn->visible) {
        // Nothing to do
    } else {
        $modPW = $bigbluebuttonbn->moderatorpass;
        $attPW = $bigbluebuttonbn->viewerpass;
        //
        // Output Users in the meeting
        //
        if ($groupObj == null) {
            $getArray = BigBlueButtonBN::getMeetingInfoArray($bigbluebuttonbn->meetingid, $modPW, $url, $salt);
            if ($bigbluebuttonbn->newwindow == 1) {
                $joinURL = '<a href="view.php?id=' . $bigbluebuttonbn->coursemodule . '" target="_blank">' . format_string($bigbluebuttonbn->name) . '</a>';
            } else {
                $joinURL = '<a href="view.php?id=' . $bigbluebuttonbn->coursemodule . '">' . format_string($bigbluebuttonbn->name) . '</a>';
            }
        } else {
            $getArray = BigBlueButtonBN::getMeetingInfoArray($bigbluebuttonbn->meetingid . '[' . $groupObj->id . ']', $modPW, $url, $salt);
            if ($bigbluebuttonbn->newwindow == 1) {
                $joinURL = '<a href="view.php?id=' . $bigbluebuttonbn->coursemodule . '&group=' . $groupObj->id . '" target="_blank">' . format_string($bigbluebuttonbn->name) . '</a>';
            } else {
                $joinURL = '<a href="view.php?id=' . $bigbluebuttonbn->coursemodule . '&group=' . $groupObj->id . '">' . format_string($bigbluebuttonbn->name) . '</a>';
            }
            $group = $groupObj->name;
        }
        if (!$getArray) {
            //
            // The server was unreachable
            //
            print_error(get_string('index_error_unable_display', 'bigbluebuttonbn'));
            return;
        }
        if (isset($getArray['messageKey'])) {
            //
            // There was an error returned
            //
            if ($getArray['messageKey'] == "checksumError") {
                print_error(get_string('index_error_checksum', 'bigbluebuttonbn'));
                return;
            }
            if ($getArray['messageKey'] == "notFound" || $getArray['messageKey'] == "invalidMeetingId") {
                //
                // The meeting does not exist yet on the BigBlueButton server.  This is OK.
                //
            } else {
                //
                // There was an error
                //
                $users = $getArray['messageKey'] . ": " . $getArray['message'];
            }
        } else {
            //
            // The meeting info was returned
            //
            if ($getArray['running'] == 'true') {
                if ($moderator) {
                    if ($groupObj == null) {
                        $actions = '<form name="form1" method="post" action=""><INPUT type="hidden" name="id" value="' . $course->id . '"><INPUT type="hidden" name="a" value="' . $bigbluebuttonbn->id . '"><INPUT type="submit" name="submit" value="end" onclick="return confirm(\'' . get_string('index_confirm_end', 'bigbluebuttonbn') . '\')"></form>';
                    } else {
                        $actions = '<form name="form1" method="post" action=""><INPUT type="hidden" name="id" value="' . $course->id . '"><INPUT type="hidden" name="a" value="' . $bigbluebuttonbn->id . '"><INPUT type="hidden" name="g" value="' . $groupObj->id . '"><INPUT type="submit" name="submit" value="end" onclick="return confirm(\'' . get_string('index_confirm_end', 'bigbluebuttonbn') . '\')"></form>';
                    }
                }
                if (isset($getArray['metadata']->recording) && $getArray['metadata']->recording == 'true') {
                    // if it has been set when meeting created, set the variable on/off
                    $recording = get_string('index_enabled', 'bigbluebuttonbn');
                }
                $xml = $getArray['attendees'];
                if (count($xml) && count($xml->attendee)) {
                    $users = count($xml->attendee);
                    $viewer_count = 0;
                    $moderator_count = 0;
                    foreach ($xml->attendee as $attendee) {
                        if ($attendee->role == "MODERATOR") {
                            if ($viewer_count++ > 0) {
                                $moderatorList .= ", ";
                            } else {
                                $moderatorList = "";
                            }
                            $moderatorList .= $attendee->fullName;
                        } else {
                            if ($moderator_count++ > 0) {
                                $viewerList .= ", ";
                            } else {
                                $viewerList = "";
                            }
                            $viewerList .= $attendee->fullName;
                        }
                    }
                }
            }
        }
        return array($bigbluebuttonbn->section, $joinURL, $group, $users, $viewerList, $moderatorList, $recording, $actions);
    }
}
/**
 * Given an ID of an instance of this module,
 * this function will permanently delete the instance
 * and any data that depends on it.
 *
 * @param int $id Id of the module instance
 * @return boolean Success/Failure
 */
function bigbluebuttonbn_delete_instance($id)
{
    global $CFG, $DB;
    if (!($bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $id)))) {
        return false;
    }
    $result = true;
    //
    // End the session associated with this instance (if it's running)
    //
    $meetingID = $bigbluebuttonbn->meetingid;
    $modPW = $bigbluebuttonbn->moderatorpass;
    $url = trim(trim($CFG->BigBlueButtonBNServerURL), '/') . '/';
    $salt = trim($CFG->BigBlueButtonBNSecuritySalt);
    $getArray = BigBlueButtonBN::endMeeting($meetingID, $modPW, $url, $salt);
    if (!$DB->delete_records('bigbluebuttonbn', array('id' => $bigbluebuttonbn->id))) {
        $result = false;
    }
    if (!$DB->delete_records('event', array('modulename' => 'bigbluebuttonbn', 'instance' => $bigbluebuttonbn->id))) {
        $result = false;
    }
    return $result;
}