Adding DO support see #8183

1.9.x
Julio Montoya 12 years ago
parent 58b6113bb4
commit c54ff61a95
  1. 7
      plugin/bbb/config.vm.dist.php
  2. 2
      plugin/bbb/lang/english.php
  3. 1
      plugin/bbb/lang/french.php
  4. 1
      plugin/bbb/lang/spanish.php
  5. 1
      plugin/bbb/lib/VM.php
  6. 161
      plugin/bbb/lib/bbb.lib.php
  7. 1
      plugin/bbb/lib/vm/AbstractVM.php
  8. 3
      plugin/bbb/lib/vm/AmazonVM.php
  9. 3
      plugin/bbb/lib/vm/DigitalOceanVM.php
  10. 1
      plugin/bbb/lib/vm/VMInterface.php
  11. 14
      plugin/bbb/start.php

@ -23,13 +23,16 @@ return array(
array( array(
'enabled' => true, 'enabled' => true,
'name' => 'DigitalOcean', 'name' => 'DigitalOcean',
//'host' => 'server-address',
//'user'=> 'AjZjoXMEg0vm7P8QXEWOC',
'vm_client_id' => 'client_id', 'vm_client_id' => 'client_id',
'api_key' => '123456', 'api_key' => '123456',
'vm_id' => '123456', // The VM ID we want to access 'vm_id' => '123456', // The VM ID we want to access
'vm_min_size_id' => '66', // VM size ID example for 512mb use 66 'vm_min_size_id' => '66', // VM size ID example for 512mb use 66
'vm_max_size_id' => '65' // For 1GB use 63 'vm_max_size_id' => '65' // For 1GB use 63
),
// The Amazon hook is not implemented yet
array(
'enabled' => false,
'name' => 'Amazon'
) )
) )
); );

@ -52,4 +52,4 @@ $strings['plugin_tool_bbb'] = 'Video';
$strings['ThereAreNotRecordingsForTheMeetings'] = 'There are not recording for the meeting sessions'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'There are not recording for the meeting sessions';
$strings['NoRecording'] = 'No recording'; $strings['NoRecording'] = 'No recording';
$strings['ClickToContinue'] = 'Click to continue';

@ -46,3 +46,4 @@ $strings['plugin_tool_bbb'] = 'Vidéo';
$strings['ThereAreNotRecordingsForTheMeetings'] = 'Aucun enregistrement disponible'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'Aucun enregistrement disponible';
$strings['NoRecording'] = "Pas d'enregistrement"; $strings['NoRecording'] = "Pas d'enregistrement";
$strings['ClickToContinue'] = 'Cliquez pour continuer';

@ -46,3 +46,4 @@ $strings['plugin_tool_bbb'] = 'Video';
$strings['ThereAreNotRecordingsForTheMeetings'] = 'No hay grabaciones de sesiones de videoconferencia'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'No hay grabaciones de sesiones de videoconferencia';
$strings['NoRecording'] = 'No hay grabación'; $strings['NoRecording'] = 'No hay grabación';
$strings['ClickToContinue'] = 'Hacer click para continuar';

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */
/** /**
* Class VM * Class VM

@ -1,4 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */
/** /**
* Class bbb * Class bbb
* This script initiates a video conference session, calling the BigBlueButton * This script initiates a video conference session, calling the BigBlueButton
@ -19,19 +21,29 @@ class bbb
public $plugin_enabled = false; public $plugin_enabled = false;
/** /**
*
* Constructor (generates a connection to the API and the Chamilo settings * Constructor (generates a connection to the API and the Chamilo settings
* required for the connection to the videoconference server) * required for the connection to the video conference server)
* @param string $host
* @param string $salt
*/ */
public function __construct() public function __construct($host = null, $salt = null)
{ {
// initialize video server settings from global settings // Initialize video server settings from global settings
$plugin = BBBPlugin::create(); $plugin = BBBPlugin::create();
$bbb_plugin = $plugin->get('tool_enable'); $bbb_plugin = $plugin->get('tool_enable');
$bbb_host = $plugin->get('host');
$bbb_salt = $plugin->get('salt');
//$course_code = api_get_course_id(); if (empty($host)) {
$bbb_host = $plugin->get('host');
} else {
$bbb_host = $host;
}
if (empty($salt)) {
$bbb_salt = $plugin->get('salt');
} else {
$bbb_salt = $salt;
}
$this->logout_url = api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq(); $this->logout_url = api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq();
$this->table = Database::get_main_table('plugin_bbb_meeting'); $this->table = Database::get_main_table('plugin_bbb_meeting');
@ -65,7 +77,7 @@ class bbb
return api_is_course_admin() || api_is_coach() || api_is_platform_admin(); return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
} }
/* /**
* See this file in you BBB to set up default values * See this file in you BBB to set up default values
/var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
@ -123,8 +135,8 @@ class bbb
$record = isset($params['record']) && $params['record'] ? 'true' : 'false'; $record = isset($params['record']) && $params['record'] ? 'true' : 'false';
$duration = isset($params['duration']) ? intval($params['duration']) : 0; $duration = isset($params['duration']) ? intval($params['duration']) : 0;
// This setting currently limits the maximum conference duration, // This setting currently limits the maximum conference duration,
// to avoid llingering sessions on the videoconference server #6261 // to avoid lingering sessions on the videoconference server #6261
$duration = 300; $duration = 300;
$bbb_params = array( $bbb_params = array(
'meetingId' => $id, // REQUIRED 'meetingId' => $id, // REQUIRED
@ -141,11 +153,29 @@ class bbb
'duration' => $duration, // Default = 0 which means no set duration in minutes. [number] '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. //'meta_category' => '', // Use to pass additional info to BBB server. See API docs.
); );
if ($this->debug) error_log("create_meeting params: ".print_r($bbb_params,1)); 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') { $status = false;
if ($this->debug) error_log("create_meeting result: ".print_r($result,1)); $meeting = null;
return $this->join_meeting($meeting_name);
while ($status == false) {
$result = $this->api->createMeetingWithXmlResponseArray(
$bbb_params
);
if (isset($result) && strval(
$result['returncode']
) == 'SUCCESS'
) {
if ($this->debug) {
error_log(
"create_meeting result: " . print_r($result, 1)
);
}
$meeting = $this->join_meeting($meeting_name, true);
return $meeting;
}
} }
return $this->logout; return $this->logout;
} }
@ -154,7 +184,8 @@ class bbb
/** /**
* Tells whether the given meeting exists and is running * Tells whether the given meeting exists and is running
* (using course code as name) * (using course code as name)
* @param string Meeting name (usually the course code) * @param string $meeting_name Meeting name (usually the course code)
*
* @return bool True if meeting exists, false otherwise * @return bool True if meeting exists, false otherwise
* @assert ('') === false * @assert ('') === false
* @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
@ -191,30 +222,68 @@ class bbb
* @assert ('') === false * @assert ('') === false
* @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
*/ */
public function join_meeting($meeting_name) public function join_meeting($meeting_name, $loop = false)
{ {
if (empty($meeting_name)) { return false; } if (empty($meeting_name)) {
return false;
}
$pass = $this->get_user_meeting_password(); $pass = $this->get_user_meeting_password();
$meeting_data = Database::select('*', $this->table, array('where' => array('meeting_name = ? AND status = 1 ' => $meeting_name)), 'first');
if (empty($meeting_data)) { $meeting_data = Database::select(
'*',
$this->table,
array('where' => array('meeting_name = ? AND status = 1 ' => $meeting_name)),
'first'
);
if (empty($meeting_data) || !is_array($meeting_data)) {
if ($this->debug) error_log("meeting does not exist: $meeting_name "); if ($this->debug) error_log("meeting does not exist: $meeting_name ");
return false; return false;
} }
$meeting_is_running_info = $this->api->isMeetingRunningWithXmlResponseArray($meeting_data['id']); $params = array(
$meeting_is_running = $meeting_is_running_info['running'] == 'true' ? true : false; 'meetingId' => $meeting_data['id'],
// -- REQUIRED - The unique id for the meeting
'password' => $this->get_mod_meeting_password()
// -- REQUIRED - The moderator password for the meeting
);
if ($this->debug) error_log("meeting is running: ".$meeting_is_running); $status = false;
$meeting_info_exists = false;
while ($status == false) {
$params = array( $meeting_is_running_info = $this->get_meeting_info($params);
'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); error_log(print_r($meeting_is_running_info, 1));
if (isset($meeting_is_running) && $meeting_info_exists) { if (strval($meeting_is_running_info['returncode']) == 'SUCCESS' &&
isset($meeting_is_running_info['meetingName']) &&
!empty($meeting_is_running_info['meetingName'])
//strval($meeting_is_running_info['running']) == 'true'
) {
$meeting_info_exists = true;
}
if ($this->debug) {
error_log(
"meeting is running: " . intval($meeting_info_exists)
);
}
if ($meeting_info_exists) {
$status = true;
}
if ($loop) {
continue;
} else {
break;
}
}
if ($meeting_info_exists) {
$joinParams = array( $joinParams = array(
'meetingId' => $meeting_data['id'], // -- REQUIRED - A unique id for the meeting '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 'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting
@ -495,6 +564,7 @@ class bbb
} }
} }
} }
return false; return false;
} }
@ -509,4 +579,41 @@ class bbb
return true; return true;
//return BigBlueButtonBN::isServerRunning($this->protocol.$this->url); //return BigBlueButtonBN::isServerRunning($this->protocol.$this->url);
} }
/**
* Get active session in the all platform
*/
public function getActiveSessionsCount()
{
$meetingList = Database::select(
'count(id) as count',
$this->table,
array('where' => array('status = ?' => array(1))),
'first'
);
return $meetingList['count'];
}
/**
* @param string $url
*/
public function redirectToBBB($url)
{
if (file_exists(__DIR__ . '/../config.vm.php')) {
// Using VM
echo Display::url(get_lang('ClickToContinue'), $url);
exit;
} else {
// Classic
header("Location: $url");
exit;
}
// js
/*echo '<script>';
echo 'window.location = "'.$url.'"';
echo '</script>';
exit;*/
}
} }

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */
/** /**
* Class AbstractVM * Class AbstractVM

@ -1,10 +1,11 @@
<?php <?php
/* For licensing terms, see /license.txt */
use DigitalOcean\DigitalOcean; use DigitalOcean\DigitalOcean;
use DigitalOcean\Credentials; use DigitalOcean\Credentials;
/** /**
* Class DigitalOceanWrapper * Class AmazonVM
*/ */
class AmazonVM extends AbstractVM implements VirtualMachineInterface class AmazonVM extends AbstractVM implements VirtualMachineInterface
{ {

@ -1,10 +1,11 @@
<?php <?php
/* For licensing terms, see /license.txt */
use DigitalOcean\DigitalOcean; use DigitalOcean\DigitalOcean;
use DigitalOcean\Credentials; use DigitalOcean\Credentials;
/** /**
* Class DigitalOceanWrapper * Class DigitalOceanVM
*/ */
class DigitalOceanVM extends AbstractVM implements VirtualMachineInterface class DigitalOceanVM extends AbstractVM implements VirtualMachineInterface
{ {

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */
/** /**
* Interface VirtualMachineInterface * Interface VirtualMachineInterface

@ -54,27 +54,23 @@ if ($bbb->plugin_enabled) {
if ($bbb->meeting_exists($meeting_params['meeting_name'])) { if ($bbb->meeting_exists($meeting_params['meeting_name'])) {
$url = $bbb->join_meeting($meeting_params['meeting_name']); $url = $bbb->join_meeting($meeting_params['meeting_name']);
if ($url) { if ($url) {
header('location: '.$url); $bbb->redirectToBBB($url);
exit;
} else { } else {
$url = $bbb->create_meeting($meeting_params); $url = $bbb->create_meeting($meeting_params);
header('location: '.$url); $bbb->redirectToBBB($url);
exit;
} }
} else { } else {
if ($bbb->is_teacher()) { if ($bbb->is_teacher()) {
$url = $bbb->create_meeting($meeting_params); $url = $bbb->create_meeting($meeting_params);
header('location: '.$url); $bbb->redirectToBBB($url);
exit;
} else { } else {
$url = 'listing.php?'.api_get_cidreq(); $url = 'listing.php?'.api_get_cidreq();
header('location: '.$url); $bbb->redirectToBBB($url);
exit;
} }
} }
} else { } else {
$url = 'listing.php?'.api_get_cidreq(); $url = 'listing.php?'.api_get_cidreq();
header('location: '.$url); header('Location: ' . $url);
exit; exit;
} }
} else { } else {

Loading…
Cancel
Save