Updating api with the latest changes in github + fixing the playback URL see #5803

skala
Julio Montoya 13 years ago
parent 6876b34edf
commit c4bb8e7ad8
  1. 2
      plugin/bbb/lang/english.php
  2. 4
      plugin/bbb/lang/spanish.php
  3. 230
      plugin/bbb/lib/bbb.lib.php
  4. 1293
      plugin/bbb/lib/bbb_api.php
  5. 1
      plugin/bbb/lib/bbb_plugin.class.php
  6. 2
      plugin/bbb/listing.php

@ -49,4 +49,6 @@ $strings['big_blue_button_record_and_store'] = 'Record and store sessions';
$strings['plugin_tool_bbb'] = 'Video';
$strings['ThereAreNotRecordingsForTheMeetings'] = 'There are not recordings for the meetings';

@ -2,4 +2,6 @@
//Needed in order to show the plugin title
$strings['plugin_title'] = "Videoconferencia";
$strings['plugin_comment'] = "Agrega una videoconferencia en un curso usando BigBlueButton (BBB)";
$strings['plugin_comment'] = "Agrega una videoconferencia en un curso usando BigBlueButton (BBB)";
$strings['ThereAreNotRecordingsForTheMeetings'] = 'No existen grabaciones';

@ -24,9 +24,9 @@ class bbb {
$bbb_host = $plugin->get('host');
$bbb_salt = $plugin->get('salt');
$course_code = api_get_course_id();
//$course_code = api_get_course_id();
$this->logout_url = api_get_course_url($course_code);
$this->logout_url = api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php';
$this->table = Database::get_main_table('plugin_bbb_meeting');
if ($bbb_plugin == true) {
@ -39,6 +39,12 @@ class bbb {
$this->protocol = $info['scheme'].'://';
$this->url = str_replace($this->protocol, '', $this->url);
}
// Setting BBB api
define(CONFIG_SECURITY_SALT, $this->salt);
define(CONFIG_SERVER_BASE_URL, $this->url);
$this->api = new BigBlueButtonBN();
$this->plugin_enabled = true;
}
}
@ -47,16 +53,46 @@ class bbb {
return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
}
/*
* See this file in you BBB to set up default values
/var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
*
More record information:
http://code.google.com/p/bigbluebutton/wiki/RecordPlaybackSpecification
# Default maximum number of users a meeting can have.
# Doesn't get enforced yet but is the default value when the create
# API doesn't pass a value.
defaultMaxUsers=20
# Default duration of the meeting in minutes.
# Current default is 0 (meeting doesn't end).
defaultMeetingDuration=0
# Remove the meeting from memory when the end API is called.
# This allows 3rd-party apps to recycle the meeting right-away
# instead of waiting for the meeting to expire (see below).
removeMeetingWhenEnded=false
# The number of minutes before the system removes the meeting from memory.
defaultMeetingExpireDuration=1
# The number of minutes the system waits when a meeting is created and when
# a user joins. If after this period, a user hasn't joined, the meeting is
# removed from memory.
defaultMeetingCreateJoinDuration=5
*
*/
function create_meeting($params) {
$params['c_id'] = api_get_course_int_id();
$course_code = api_get_course_id();
$attende_password = $params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : api_get_course_id();
$moderator_password = $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : api_get_course_id().'mod';
$moderator_password = $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->get_mod_meeting_password();
$params['record'] = api_get_course_setting('big_blue_button_record_and_store', $course_code) == 1 ? true : false;
$max = api_get_course_setting('big_blue_button_max_students_allowed', $course_code);
$max = isset($max) ? $max : -1;
$params['status'] = 1;
@ -72,16 +108,30 @@ class bbb {
$welcome_msg = isset($params['welcome_msg']) ? $params['welcome_msg'] : null;
$record = isset($params['record']) && $params['record'] ? 'true' : 'false';
$duration = isset($params['duration']) ? intval($params['duration']) : 0;
// ??
$voiceBridge = 0;
$metadata = array('maxParticipants' => $max);
$result = $this->protocol.BigBlueButtonBN::createMeetingAndGetJoinURL(
$this->user_complete_name, $meeting_name, $id, $welcome_msg, $moderator_password, $attende_password,
$this->salt, $this->url, $this->logout_url, $record, $duration, $voiceBridge, $metadata
$duration = 30;
$bbb_params = array(
'meetingId' => $id, // REQUIRED
'meetingName' => $meeting_name, // REQUIRED
'attendeePw' => $attende_password, // Match this value in getJoinMeetingURL() to join as attendee.
'moderatorPw' => $moderator_password, // Match this value in getJoinMeetingURL() to join as moderator.
'welcomeMsg' => $welcome_msg, // ''= use default. Change to customize.
'dialNumber' => '', // The main number to call into. Optional.
'voiceBridge' => '0', // PIN to join voice. Optional.
'webVoice' => '', // Alphanumeric to join voice. Optional.
'logoutUrl' => $this->logout_url,
'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number]
'record' => $record, // New. 'true' will tell BBB to record the meeting.
'duration' => $duration, // Default = 0 which means no set duration in minutes. [number]
//'meta_category' => '', // Use to pass additional info to BBB server. See API docs.
);
if ($this->debug) error_log("create_meeting result: ".print_r($result,1));
return $result;
if ($this->debug) error_log("create_meeting params: ".print_r($bbb_params,1));
$result = $this->api->createMeetingWithXmlResponseArray($bbb_params);
if (isset($result) && (string)$result['returncode'] == 'SUCCESS') {
if ($this->debug) error_log("create_meeting result: ".print_r($result,1));
return $this->join_meeting($meeting_name);
}
return $this->logout;
}
}
@ -101,32 +151,56 @@ class bbb {
*/
function join_meeting($meeting_name) {
$pass = $this->get_user_meeting_password();
$mod_pass = $this->get_mod_meeting_password();
$meeting_data = Database::select('*', $this->table, array('where' => array('meeting_name = ? AND status = 1 ' => $meeting_name)), 'first');
if (empty($meeting_data)) {
if ($this->debug) error_log("meeting does not exist: $meeting_name ");
return false;
}
$meeting_is_running = BigBlueButtonBN::isMeetingRunning($meeting_data['id'], $this->url, $this->salt);
$meeting_info = BigBlueButtonBN::getMeetingInfoArray($meeting_data['id'], $mod_pass, $this->url, $this->salt);
$meeting_info_exists = false;
if ($meeting_info['returncode'] != 'FAILED') {
$meeting_info_exists = true;
}
$meeting_is_running_info = $this->api->isMeetingRunningWithXmlResponseArray($meeting_data['id']);
$meeting_is_running = $meeting_is_running_info['running'] == 'true' ? true : false;
$url = false;
if ($this->debug) error_log("meeting is running: ".$meeting_is_running);
if ($this->debug) error_log("meeting is running:getMeetingInfoArray ".print_r($meeting_info, 1));
$params = array(
'meetingId' => $meeting_data['id'], // -- REQUIRED - The unique id for the meeting
'password' => $this->get_mod_meeting_password() // -- REQUIRED - The moderator password for the meeting
);
$meeting_info_exists = $this->get_meeting_info($params);
if (isset($meeting_is_running) && $meeting_info_exists) {
$url = $this->protocol.BigBlueButtonBN::joinURL($meeting_data['id'], $this->user_complete_name, $pass, $this->salt, $this->url);
$joinParams = array(
'meetingId' => $meeting_data['id'], // -- REQUIRED - A unique id for the meeting
'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting
'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
//'createTime' => api_get_utc_datetime(), //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
'userID' => api_get_user_id(), //-- OPTIONAL - string
'webVoiceConf' => '' // -- OPTIONAL - string
);
$url = $this->api->getJoinMeetingURL($joinParams);
$url = $this->protocol.$url;
} else {
$url = $this->logout_url;
}
if ($this->debug) error_log("return url :".$url);
return $url;
}
function get_meeting_info($params) {
try {
$result = $this->api->getMeetingInfoWithXmlResponseArray($params);
if ($result == null) {
if ($this->debug) error_log("Failed to get any response. Maybe we can't contact the BBB server.");
} else {
return $result;
}
} catch (Exception $e) {
if ($this->debug) error_log('Caught exception: ', $e->getMessage(), "\n");
}
return false;
}
/**
* Gets all the course meetings saved in the plugin_bbb_meeting table
* @return string
@ -139,42 +213,72 @@ class bbb {
$item = array();
foreach ($meeting_list as $meeting_db) {
$meeting_bbb = BigBlueButtonBN::getMeetingInfoArray($meeting_db['id'], $pass, $this->url, $this->salt);
if ($meeting_bbb['returncode'] == 'FAILED') {
$meeting_bbb = $this->get_meeting_info(array('meetingId' => $meeting_db['id'], 'password' => $pass));
$meeting_bbb['end_url'] = api_get_self().'?action=end&id='.$meeting_db['id'];
if ((string)$meeting_bbb['returncode'] == 'FAILED') {
if ($meeting_db['status'] == 1) {
$this->end_meeting($meeting_db['id']);
}
} else {
$meeting_bbb['end_url'] = api_get_self().'?action=end&id='.$meeting_db['id'];
$meeting_bbb['add_to_calendar_url'] = api_get_self().'?action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['created_at']);
}
$record_array = array();
if ($meeting_db['record'] == 1) {
$records = BigBlueButtonBN::getRecordingsArray($meeting_db['id'], $this->url, $this->salt);
//var_dump($meeting['id']);
$recordingParams = array(
'meetingId' => $meeting_db['id'], //-- OPTIONAL - comma separate if multiple ids
);
//To see the recording list in your BBB server do: bbb-record --list
$records = $this->api->getRecordingsWithXmlResponseArray($recordingParams);
if (!empty($records)) {
$count = 1;
foreach ($records as $record) {
if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) {
//Fix the bbb timestamp
//$record['startTime'] = substr($record['startTime'], 0, strlen($record['startTime']) -3);
//$record['endTime'] = substr($record['endTime'], 0, strlen($record['endTime']) -3);
//.' - '.api_convert_and_format_date($record['startTime']).' - '.api_convert_and_format_date($record['endTime'])
foreach ($record['playbacks'] as $item) {
$url = Display::url(get_lang('ViewRecord'), $item['url'], array('target' => '_blank'));
//$url .= Display::url(get_lang('DeleteRecord'), api_get_self().'?action=delete_record&'.$record['recordID']);
if (isset($records['message']) && !empty($records['message'])) {
if ($records['messageKey'] == 'noRecordings') {
//$record_array[] = get_lang('ThereAreNotRecordingsForTheMeetings');
} else {
//$record_array[] = $records['message'];
}
} else {
foreach ($records as $record) {
if (is_array($record) && isset($record['recordId'])) {
$url = Display::url(get_lang('ViewRecord'), $record['playbackFormatUrl'], array('target' => '_blank'));
if ($this->is_teacher()) {
$url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meeting_db['id'].'&record_id='.$record['recordID']);
$url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['created_at']).'&url='.$item['url']);
$url .= Display::url(Display::return_icon('delete.png',get_lang('Delete')), api_get_self().'?action=delete_record&id='.$record['recordID']);
$url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meeting_db['id'].'&record_id='.$record['recordId']);
$url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['created_at']).'&url='.$record['playbackFormatUrl']);
$url .= Display::url(Display::return_icon('delete.png',get_lang('Delete')), api_get_self().'?action=delete_record&id='.$record['recordId']);
}
//$url .= api_get_self().'?action=publish&id='.$record['recordID'];
$count++;
$record_array[] = $url;
} else {
/*if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) {
//Fix the bbb timestamp
//$record['startTime'] = substr($record['startTime'], 0, strlen($record['startTime']) -3);
//$record['endTime'] = substr($record['endTime'], 0, strlen($record['endTime']) -3);
//.' - '.api_convert_and_format_date($record['startTime']).' - '.api_convert_and_format_date($record['endTime'])
foreach($record['playbacks'] as $item) {
$url = Display::url(get_lang('ViewRecord'), $item['url'], array('target' => '_blank'));
//$url .= Display::url(get_lang('DeleteRecord'), api_get_self().'?action=delete_record&'.$record['recordID']);
if ($this->is_teacher()) {
$url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meeting_db['id'].'&record_id='.$record['recordID']);
$url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['created_at']).'&url='.$item['url']);
$url .= Display::url(Display::return_icon('delete.png',get_lang('Delete')), api_get_self().'?action=delete_record&id='.$record['recordID']);
}
//$url .= api_get_self().'?action=publish&id='.$record['recordID'];
$count++;
$record_array[] = $url;
}
}*/
}
}
}
}
//var_dump($record_array);
$item['show_links'] = implode('<br />', $record_array);
}
@ -185,7 +289,15 @@ class bbb {
$item['unpublish_url'] = api_get_self().'?action=unpublish&id='.$meeting_db['id'];
if ($meeting_db['status'] == 1) {
$item['go_url'] = $this->protocol.BigBlueButtonBN::joinURL($meeting_db['id'], $this->user_complete_name, $pass, $this->salt, $this->url);
$joinParams = array(
'meetingId' => $meeting_db['id'], //-- REQUIRED - A unique id for the meeting
'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting
'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
'createTime' => '', //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
'userID' => '', // -- OPTIONAL - string
'webVoiceConf' => '' // -- OPTIONAL - string
);
$item['go_url'] = $this->protocol.$this->api->getJoinMeetingURL($joinParams);
}
$item = array_merge($item, $meeting_db, $meeting_bbb);
$new_meeting_list[] = $item;
@ -194,22 +306,26 @@ class bbb {
}
function publish_meeting($id) {
return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt);
//return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt);
}
function unpublish_meeting($id) {
return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt);
//return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt);
}
function end_meeting($id) {
$pass = $this->get_user_meeting_password();
BigBlueButtonBN::endMeeting($id, $pass, $this->url, $this->salt);
Database::update($this->table, array('status' => 0), array('id = ? ' => $id));
$endParams = array(
'meetingId' => $id, // REQUIRED - We have to know which meeting to end.
'password' => $pass, // REQUIRED - Must match moderator pass for meeting.
);
$this->api->endMeetingWithXmlResponseArray($endParams);
Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $id));
}
function get_user_meeting_password() {
if ($this->is_teacher()) {
return api_get_course_id().'mod';
return $this->get_mod_meeting_password();
} else {
return api_get_course_id();
}
@ -229,8 +345,7 @@ class bbb {
return 0;
}
$pass = $this->get_mod_meeting_password();
//$meeting_is_running = BigBlueButtonBN::isMeetingRunning($meeting_data['id'], $this->url, $this->salt);
$info = BigBlueButtonBN::getMeetingInfoArray($meeting_data['id'], $pass, $this->url, $this->salt);
$info = $this->get_meeting_info(array('meetingId' => $meeting_data['id'], 'password' => $pass));
if (!empty($info) && isset($info['participantCount'])) {
return $info['participantCount'];
@ -240,7 +355,17 @@ class bbb {
}
function delete_record($ids) {
return BigBlueButtonBN::deleteRecordings($ids, $this->url, $this->salt);
$recordingParams = array(
/*
* NOTE: Set the recordId below to a valid id after you have created a recorded meeting,
* and received back a real recordID back from your BBB server using the
* getRecordingsWithXmlResponseArray method.
*/
// REQUIRED - We have to know which recording:
'recordId' => $ids,
);
return $this->api->deleteRecordingsWithXmlResponseArray($recordingParams);
}
function copy_record_to_link_tool($id, $record_id) {
@ -266,6 +391,7 @@ class bbb {
}
function is_server_running() {
return BigBlueButtonBN::isServerRunning($this->protocol.$this->url);
return true;
//return BigBlueButtonBN::isServerRunning($this->protocol.$this->url);
}
}

File diff suppressed because it is too large Load Diff

@ -36,6 +36,7 @@ class BBBPlugin extends Plugin
record INT NOT NULL DEFAULT 0,
status INT NOT NULL DEFAULT 0,
created_at VARCHAR(255) NOT NULL,
closed_at VARCHAR(255) NOT NULL,
calendar_id INT DEFAULT 0,
welcome_msg VARCHAR(255) NOT NULL DEFAULT '')";
Database::query($sql);

@ -17,6 +17,8 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
$teacher = api_is_course_admin() || api_is_coach() || api_is_platform_admin();
api_protect_course_script(true);
if ($teacher) {
switch ($action) {
case 'add_to_calendar':

Loading…
Cancel
Save