Merge branch '1.10.x' of https://github.com/chamilo/chamilo-lms into 1.10.x

1.10.x
Angel Fernando Quiroz Campos 10 years ago
commit ca2d8a33a4
  1. 5
      app/Resources/public/css/base.css
  2. 9
      main/inc/lib/database.lib.php
  3. 21
      plugin/bbb/changelog.md
  4. 4
      plugin/bbb/cron.php
  5. 1
      plugin/bbb/lib/VM.php
  6. 301
      plugin/bbb/lib/bbb.lib.php
  7. 18
      plugin/bbb/lib/bbb_plugin.class.php
  8. 38
      plugin/bbb/listing.php
  9. 29
      plugin/bbb/start.php

@ -2964,6 +2964,9 @@ a:active{
tr.forum_category_header a { tr.forum_category_header a {
color: #fff; color: #fff;
} }
.forum-description {
display: inline-block;
}
/* **** FORUM **** */ /* **** FORUM **** */
.forum_header { .forum_header {
background-color: #EEF; background-color: #EEF;
@ -5880,4 +5883,4 @@ a.sessionView {
border: 2px dashed #bbbbbb; border: 2px dashed #bbbbbb;
font-size: 120%; font-size: 120%;
margin-bottom: 0; margin-bottom: 0;
} }

@ -672,4 +672,13 @@ $connection->executeQuery('set sql_mode=""');
{ {
return self::getManager()->getConnection()->getSchemaManager()->tablesExist($table); return self::getManager()->getConnection()->getSchemaManager()->tablesExist($table);
} }
/**
* @param $table
* @return \Doctrine\DBAL\Schema\Column[]
*/
public static function listTableColumns($table)
{
return self::getManager()->getConnection()->getSchemaManager()->listTableColumns($table);
}
} }

@ -1,10 +1,18 @@
version 2.3 - 2015-05-18 Version 2.4
------------------------
Changes:
* Global conference support (Requires to turn on, in plugin settings)
* Course group conference support.
* Requires a DB change: "ALTER TABLE plugin_bbb_meeting ADD COLUMN group_id INT DEFAULT 0"
Version 2.3 - 2015-05-18
------------------------ ------------------------
Changes: Changes:
* Added support for variable voiceBridge to be sent on meeting creation. See https://code.google.com/p/bigbluebutton/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Component%20Summary&groupby=&sort=&id=1186 and https://support.chamilo.org/issues/7669 for details. * Added support for variable voiceBridge to be sent on meeting creation. See https://code.google.com/p/bigbluebutton/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Component%20Summary&groupby=&sort=&id=1186 and https://support.chamilo.org/issues/7669 for details.
* Requires you to "ALTER TABLE plugin_bbb_meeting ADD COLUMN voice_bridge INT NOT NULL DEFAULT 1;" * Requires a DB change: "ALTER TABLE plugin_bbb_meeting ADD COLUMN voice_bridge INT NOT NULL DEFAULT 1;"
version 2.2 - 2014-10-15 Version 2.2 - 2014-10-15
------------------------ ------------------------
Changes: Changes:
* Add a pseudo-random guid to avoid clashing conferences when several Chamilo portals use the same server. If you were using this plugin before, you will have to update the plugin_bbb_meeting table to "alter table plugin_bbb_meeting add column remote_id char(36);". * Add a pseudo-random guid to avoid clashing conferences when several Chamilo portals use the same server. If you were using this plugin before, you will have to update the plugin_bbb_meeting table to "alter table plugin_bbb_meeting add column remote_id char(36);".
@ -13,16 +21,15 @@ Changes:
* Hide the ID of the meeting (this was an internal ID, useless to the final user). It is still in the HTML source, however * Hide the ID of the meeting (this was an internal ID, useless to the final user). It is still in the HTML source, however
* Show number of minutes of the recording (in the recordings list) * Show number of minutes of the recording (in the recordings list)
version 2.1 Version 2.1
----------- -----------
Released with: Chamilo LMS 1.9.8 Released with: Chamilo LMS 1.9.8
Changes: Changes:
* now supports sessions (requires you to "alter table plugin_bbb_meeting add column session_id int default 0;") * now supports sessions (requires you to "alter table plugin_bbb_meeting add column session_id int default 0;")
version 2.0 Version 2.0
----------- -----------
(to be described)
version 1.0 Version 1.0
----------- -----------
Released with: Chamilo LMS 1.9.0 Released with: Chamilo LMS 1.9.0

@ -14,9 +14,9 @@ if (file_exists(__DIR__ . '/config.vm.php')) {
$vm = new VM($config); $vm = new VM($config);
if ($vm->IsEnabled()) { if ($vm->isEnabled()) {
$bbb = new bbb(); $bbb = new bbb();
if ($bbb->plugin_enabled) { if ($bbb->pluginEnabled) {
$activeSessions = $bbb->getActiveSessionsCount(); $activeSessions = $bbb->getActiveSessionsCount();
if (empty($activeSessions)) { if (empty($activeSessions)) {
$vm->runCron(); $vm->runCron();

@ -34,6 +34,7 @@ class VM
$config = $this->getConfig(); $config = $this->getConfig();
if (!isset($config)) { if (!isset($config)) {
return false; return false;
} }

@ -20,41 +20,40 @@ class bbb
public $url; public $url;
public $salt; public $salt;
public $api; public $api;
public $user_complete_name = null; public $user_complete_name = '';
public $protocol = 'http://'; public $protocol = 'http://';
public $debug = false; public $debug = false;
public $logout_url = null; public $logoutUrl = '';
public $plugin_enabled = false; public $pluginEnabled = false;
public $enableGlobalConference = false;
public $isGlobalConference = false;
public $groupSupport = 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 video conference server) * required for the connection to the video conference server)
* @param string $host * @param string $host
* @param string $salt * @param string $salt
*/ */
public function __construct($host = null, $salt = null) public function __construct($host = '', $salt = '', $isGlobalConference = false)
{ {
// 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'); $bbbPlugin = $plugin->get('tool_enable');
if (empty($host)) { $bbb_host = !empty($host) ? $host : $plugin->get('host');
$bbb_host = $plugin->get('host'); $bbb_salt = !empty($salt) ? $salt : $plugin->get('salt');
} else {
$bbb_host = $host;
}
if (empty($salt)) {
$bbb_salt = $plugin->get('salt');
} else {
$bbb_salt = $salt;
}
$this->logout_url = $this->getListingUrl(); $this->logoutUrl = $this->getListingUrl();
$this->table = Database::get_main_table('plugin_bbb_meeting'); $this->table = Database::get_main_table('plugin_bbb_meeting');
$this->enableGlobalConference = $plugin->get('enable_global_conference');
$this->isGlobalConference = (bool) $isGlobalConference;
if ($bbb_plugin == true) { $columns = Database::listTableColumns($this->table);
$this->groupSupport = isset($columns['group_id']) ? true : false;
if ($bbbPlugin === true) {
$userInfo = api_get_user_info(); $userInfo = api_get_user_info();
$this->user_complete_name = $userInfo['complete_name']; $this->user_complete_name = $userInfo['complete_name'];
$this->salt = $bbb_salt; $this->salt = $bbb_salt;
@ -70,15 +69,44 @@ class bbb
define('CONFIG_SERVER_BASE_URL', $this->url); define('CONFIG_SERVER_BASE_URL', $this->url);
$this->api = new BigBlueButtonBN(); $this->api = new BigBlueButtonBN();
$this->plugin_enabled = true; $this->pluginEnabled = true;
} }
} }
/**
* @return bool
*/
public function isGlobalConferenceEnabled()
{
return (bool) $this->enableGlobalConference;
}
/**
* @return bool
*/
public function isGlobalConference()
{
if ($this->isGlobalConferenceEnabled() === false) {
return false;
}
return (bool) $this->isGlobalConference;
}
/**
* @return bool
*/
public function hasGroupSupport()
{
return $this->groupSupport;
}
/** /**
* Checks whether a user is teacher in the current course * Checks whether a user is teacher in the current course
* @return bool True if the user can be considered a teacher in this course, false otherwise * @return bool True if the user can be considered a teacher in this course, false otherwise
*/ */
public function isTeacher() public function isConferenceManager()
{ {
return api_is_course_admin() || api_is_coach() || api_is_platform_admin(); return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
} }
@ -117,11 +145,15 @@ class bbb
*/ */
public function createMeeting($params) public function createMeeting($params)
{ {
$params['c_id'] = api_get_course_int_id();
$courseCode = api_get_course_id(); $courseCode = api_get_course_id();
$params['c_id'] = api_get_course_int_id();
$params['session_id'] = api_get_session_id(); $params['session_id'] = api_get_session_id();
$params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : api_get_course_id(); if ($this->hasGroupSupport()) {
$params['group_id'] = api_get_group_id();
}
$params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $courseCode;
$attendeePassword = $params['attendee_pw']; $attendeePassword = $params['attendee_pw'];
$params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword(); $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword();
$moderatorPassword = $params['moderator_pw']; $moderatorPassword = $params['moderator_pw'];
@ -129,13 +161,14 @@ class bbb
$params['record'] = api_get_course_setting('big_blue_button_record_and_store', $courseCode) == 1 ? true : false; $params['record'] = api_get_course_setting('big_blue_button_record_and_store', $courseCode) == 1 ? true : false;
$max = api_get_course_setting('big_blue_button_max_students_allowed', $courseCode); $max = api_get_course_setting('big_blue_button_max_students_allowed', $courseCode);
$max = isset($max) ? $max : -1; $max = isset($max) ? $max : -1;
$params['status'] = 1; $params['status'] = 1;
// Generate a pseudo-global-unique-id to avoid clash of conferences on // Generate a pseudo-global-unique-id to avoid clash of conferences on
// the same BBB server with several Chamilo portals // the same BBB server with several Chamilo portals
$params['remote_id'] = uniqid(true, true); $params['remote_id'] = uniqid(true, true);
// Each simultaneous conference room needs to have a different // Each simultaneous conference room needs to have a different
// voice_bridge composed of a 5 digits number, so generating a random one // voice_bridge composed of a 5 digits number, so generating a random one
$params['voice_bridge'] = rand(10000,99999); $params['voice_bridge'] = rand(10000, 99999);
if ($this->debug) { if ($this->debug) {
error_log("enter create_meeting ".print_r($params, 1)); error_log("enter create_meeting ".print_r($params, 1));
@ -149,7 +182,7 @@ class bbb
error_log("create_meeting: $id "); error_log("create_meeting: $id ");
} }
$meetingName = isset($params['meeting_name']) ? $params['meeting_name'] : api_get_course_id().'-'.api_get_session_id(); $meetingName = isset($params['meeting_name']) ? $params['meeting_name'] : $this->getCurrentVideoConferenceName();
$welcomeMessage = isset($params['welcome_msg']) ? $params['welcome_msg'] : null; $welcomeMessage = isset($params['welcome_msg']) ? $params['welcome_msg'] : null;
$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;
@ -166,7 +199,7 @@ class bbb
'dialNumber' => '', // The main number to call into. Optional. 'dialNumber' => '', // The main number to call into. Optional.
'voiceBridge' => $params['voice_bridge'], // PIN to join voice. Required. 'voiceBridge' => $params['voice_bridge'], // PIN to join voice. Required.
'webVoice' => '', // Alphanumeric to join voice. Optional. 'webVoice' => '', // Alphanumeric to join voice. Optional.
'logoutUrl' => $this->logout_url, 'logoutUrl' => $this->logoutUrl,
'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number] 'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number]
'record' => $record, // New. 'true' will tell BBB to record the meeting. 'record' => $record, // New. 'true' will tell BBB to record the meeting.
'duration' => $duration, // Default = 0 which means no set duration in minutes. [number] 'duration' => $duration, // Default = 0 which means no set duration in minutes. [number]
@ -180,7 +213,7 @@ class bbb
$status = false; $status = false;
$meeting = null; $meeting = null;
while ($status == false) { while ($status === false) {
$result = $this->api->createMeetingWithXmlResponseArray( $result = $this->api->createMeetingWithXmlResponseArray(
$bbbParams $bbbParams
); );
@ -195,7 +228,8 @@ class bbb
return $meeting; return $meeting;
} }
} }
return $this->logout;
return $this->logoutUrl;
} }
} }
@ -211,25 +245,43 @@ class bbb
public function meetingExists($meetingName) public function meetingExists($meetingName)
{ {
if (empty($meetingName)) { if (empty($meetingName)) {
return false; return false;
} }
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$sessionId = api_get_session_id(); $sessionId = api_get_session_id();
$conditions = array(
'where' => array(
'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 ' =>
array($courseId, $sessionId, $meetingName)
)
);
if ($this->hasGroupSupport()) {
$groupId = api_get_group_id();
$conditions = array(
'where' => array(
'c_id = ? AND session_id = ? AND meeting_name = ? AND group_id = ? AND status = 1 ' =>
array($courseId, $sessionId, $meetingName, $groupId)
)
);
}
$meetingData = Database::select( $meetingData = Database::select(
'*', '*',
$this->table, $this->table,
array( $conditions,
'where' => array(
'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 ' =>
array($courseId, $sessionId, $meetingName)
)
),
'first' 'first'
); );
if ($this->debug) { if ($this->debug) {
error_log("meeting_exists ".print_r($meetingData, 1)); error_log("meeting_exists ".print_r($meetingData, 1));
} }
if (empty($meetingData)) { if (empty($meetingData)) {
return false; return false;
} else { } else {
return true; return true;
@ -276,7 +328,7 @@ class bbb
$status = false; $status = false;
$meetingInfoExists = false; $meetingInfoExists = false;
while ($status == false) { while ($status === false) {
$meetingIsRunningInfo = $this->getMeetingInfo($params); $meetingIsRunningInfo = $this->getMeetingInfo($params);
if ($meetingIsRunningInfo === false) { if ($meetingIsRunningInfo === false) {
@ -332,11 +384,12 @@ class bbb
$url = $this->api->getJoinMeetingURL($joinParams); $url = $this->api->getJoinMeetingURL($joinParams);
$url = $this->protocol.$url; $url = $this->protocol.$url;
} else { } else {
$url = $this->logout_url; $url = $this->logoutUrl;
} }
if ($this->debug) { if ($this->debug) {
error_log("return url :" . $url); error_log("return url :" . $url);
} }
return $url; return $url;
} }
@ -362,6 +415,7 @@ class bbb
error_log('Caught exception: ', $e->getMessage(), "\n"); error_log('Caught exception: ', $e->getMessage(), "\n");
} }
} }
return false; return false;
} }
@ -369,27 +423,41 @@ class bbb
* Gets all the course meetings saved in the plugin_bbb_meeting table * Gets all the course meetings saved in the plugin_bbb_meeting table
* @return array Array of current open meeting rooms * @return array Array of current open meeting rooms
*/ */
public function getCourseMeetings() public function getMeetings()
{ {
$pass = $this->getUserMeetingPassword(); $pass = $this->getUserMeetingPassword();
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$conditions = array(
'where' => array(
'c_id = ? AND session_id = ? ' => array(
$courseId,
$sessionId,
),
),
);
if ($this->hasGroupSupport()) {
$groupId = api_get_group_id();
$conditions = array(
'where' => array(
'c_id = ? AND session_id = ? AND group_id = ? ' =>
array($courseId, $sessionId, $groupId)
)
);
}
$meetingList = Database::select( $meetingList = Database::select(
'*', '*',
$this->table, $this->table,
array( $conditions
'where' => array(
'c_id = ? AND session_id = ? ' => array(
api_get_course_int_id(),
api_get_session_id(),
),
),
)
); );
$isGlobal = $this->isGlobalConference();
$newMeetingList = array(); $newMeetingList = array();
$item = array(); $item = array();
foreach ($meetingList as $meetingDB) { foreach ($meetingList as $meetingDB) {
$meetingBBB = $this->getMeetingInfo(array('meetingId' => $meetingDB['remote_id'], 'password' => $pass)); $meetingBBB = $this->getMeetingInfo(['meetingId' => $meetingDB['remote_id'], 'password' => $pass]);
if ($meetingBBB === false) { if ($meetingBBB === false) {
//checking with the remote_id didn't work, so just in case and //checking with the remote_id didn't work, so just in case and
// to provide backwards support, check with the id // to provide backwards support, check with the id
@ -402,13 +470,13 @@ class bbb
$meetingBBB = $this->getMeetingInfo($params); $meetingBBB = $this->getMeetingInfo($params);
} }
if ($meetingDB['visibility'] == 0 and $this->isTeacher() == false) { if ($meetingDB['visibility'] == 0 && $this->isConferenceManager() === false) {
continue; continue;
} }
$meetingBBB['end_url'] = $this->endUrl($meetingDB); $meetingBBB['end_url'] = $this->endUrl($meetingDB);
if ((string)$meetingBBB['returncode'] == 'FAILED') { if ((string)$meetingBBB['returncode'] == 'FAILED') {
if ($meetingDB['status'] == 1 && $this->isTeacher()) { if ($meetingDB['status'] == 1 && $this->isConferenceManager()) {
$this->endMeeting($meetingDB['id']); $this->endMeeting($meetingDB['id']);
} }
} else { } else {
@ -461,8 +529,6 @@ class bbb
$this->unPublishUrl($meetingDB) $this->unPublishUrl($meetingDB)
); );
} }
} else {
//$recordArray[] = $records['message'];
} }
} else { } else {
foreach ($records as $record) { foreach ($records as $record) {
@ -477,21 +543,23 @@ class bbb
array('target' => '_blank') array('target' => '_blank')
); );
$actionLinks = ''; $actionLinks = '';
if ($this->isTeacher()) { if ($this->isConferenceManager()) {
$actionLinks .= Display::url( if ($isGlobal === false) {
Display::return_icon( $actionLinks .= Display::url(
'link.gif', Display::return_icon(
get_lang('CopyToLinkTool') 'link.gif',
), get_lang('CopyToLinkTool')
$this->copyToRecordToLinkTool($meetingDB) ),
); $this->copyToRecordToLinkTool($meetingDB)
$actionLinks .= Display::url( );
Display::return_icon( $actionLinks .= Display::url(
'agenda.png', Display::return_icon(
get_lang('AddToCalendar') 'agenda.png',
), get_lang('AddToCalendar')
$this->addToCalendarUrl($meetingDB, $record) ),
); $this->addToCalendarUrl($meetingDB, $record)
);
}
$actionLinks .= Display::url( $actionLinks .= Display::url(
Display::return_icon( Display::return_icon(
'delete.png', 'delete.png',
@ -499,6 +567,7 @@ class bbb
), ),
$this->deleteRecordUrl($meetingDB) $this->deleteRecordUrl($meetingDB)
); );
if ($meetingDB['visibility'] == 0) { if ($meetingDB['visibility'] == 0) {
$actionLinks .= Display::url( $actionLinks .= Display::url(
Display::return_icon( Display::return_icon(
@ -521,7 +590,6 @@ class bbb
); );
} }
} }
//$url .= api_get_self().'?action=publish&id='.$record['recordID'];
$count++; $count++;
$recordArray[] = $url; $recordArray[] = $url;
$actionLinksArray[] = $actionLinks; $actionLinksArray[] = $actionLinks;
@ -535,7 +603,7 @@ class bbb
foreach($record['playbacks'] as $item) { foreach($record['playbacks'] as $item) {
$url = Display::url(get_lang('ViewRecord'), $item['url'], array('target' => '_blank')); $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']); //$url .= Display::url(get_lang('DeleteRecord'), api_get_self().'?action=delete_record&'.$record['recordID']);
if ($this->isTeacher()) { if ($this->isConferenceManager()) {
$url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meetingDB['id'].'&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='.$meetingDB['id'].'&record_id='.$record['recordID']);
$url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meetingDB['id'].'&start='.api_strtotime($meetingDB['created_at']).'&url='.$item['url']); $url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meetingDB['id'].'&start='.api_strtotime($meetingDB['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('delete.png',get_lang('Delete')), api_get_self().'?action=delete_record&id='.$record['recordID']);
@ -550,7 +618,7 @@ class bbb
} }
} else { } else {
$actionLinks = ''; $actionLinks = '';
if ($this->isTeacher()) { if ($this->isConferenceManager()) {
if ($meetingDB['visibility'] == 0) { if ($meetingDB['visibility'] == 0) {
$actionLinks .= Display::url( $actionLinks .= Display::url(
Display::return_icon( Display::return_icon(
@ -629,10 +697,11 @@ class bbb
{ {
//return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt); //return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt);
if (empty($id)) { if (empty($id)) {
return false; return false;
} }
$id = intval($id); $id = intval($id);
Database::update($this->table, array('visibility' => 0), array('id = ? ' => $id)); Database::update($this->table, array('visibility' => 0), array('id = ?' => $id));
return true; return true;
} }
@ -647,6 +716,7 @@ class bbb
public function endMeeting($id) public function endMeeting($id)
{ {
if (empty($id)) { if (empty($id)) {
return false; return false;
} }
$meetingData = Database::select('*', $this->table, array('where' => array('id = ?' => array($id))), 'first'); $meetingData = Database::select('*', $this->table, array('where' => array('id = ?' => array($id))), 'first');
@ -670,9 +740,16 @@ class bbb
*/ */
public function getUserMeetingPassword() public function getUserMeetingPassword()
{ {
if ($this->isTeacher()) { if ($this->isConferenceManager()) {
return $this->getModMeetingPassword(); return $this->getModMeetingPassword();
} else { } else {
if ($this->isGlobalConference()) {
return 'url_'.api_get_current_access_url_id();
}
return api_get_course_id(); return api_get_course_id();
} }
} }
@ -683,6 +760,11 @@ class bbb
*/ */
public function getModMeetingPassword() public function getModMeetingPassword()
{ {
if ($this->isGlobalConference()) {
return 'url_'.api_get_current_access_url_id().'_mod';
}
return api_get_course_id().'mod'; return api_get_course_id().'mod';
} }
@ -695,12 +777,35 @@ class bbb
{ {
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$sessionId = api_get_session_id(); $sessionId = api_get_session_id();
$conditions = array(
'where' => array(
'c_id = ? AND session_id = ? AND status = 1 ' => array(
$courseId,
$sessionId,
),
),
);
if ($this->hasGroupSupport()) {
$groupId = api_get_group_id();
$conditions = array(
'where' => array(
'c_id = ? AND session_id = ? AND group_id = ? AND status = 1 ' => array(
$courseId,
$sessionId,
$groupId
),
),
);
}
$meetingData = Database::select( $meetingData = Database::select(
'*', '*',
$this->table, $this->table,
array('where' => array('c_id = ? AND session_id = ? AND status = 1 ' => array($courseId, $sessionId))), $conditions,
'first' 'first'
); );
if (empty($meetingData)) { if (empty($meetingData)) {
return 0; return 0;
} }
@ -861,12 +966,48 @@ class bbb
exit;*/ exit;*/
} }
/**
* @return string
*/
public function getUrlParams()
{
$courseInfo = api_get_course_info();
if (empty($courseInfo)) {
if ($this->isGlobalConference()) {
return 'global=1';
}
return '';
}
return api_get_cidreq();
}
/**
* @return string
*/
public function getCurrentVideoConferenceName()
{
if ($this->isGlobalConference()) {
return 'url_'.api_get_current_access_url_id();
}
if ($this->hasGroupSupport()) {
return api_get_course_id().'-'.api_get_session_id().'-'.api_get_group_id();
}
return api_get_course_id().'-'.api_get_session_id();
}
/** /**
* @return string * @return string
*/ */
public function getConferenceUrl() public function getConferenceUrl()
{ {
return api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?launch=1&'.api_get_cidreq(); return api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?launch=1&'.$this->getUrlParams();
} }
/** /**
@ -874,7 +1015,7 @@ class bbb
*/ */
public function getListingUrl() public function getListingUrl()
{ {
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq(); return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams();
} }
/** /**
@ -883,7 +1024,7 @@ class bbb
*/ */
public function endUrl($meeting) public function endUrl($meeting)
{ {
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq().'&action=end&id='.$meeting['id']; return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=end&id='.$meeting['id'];
} }
/** /**
@ -895,7 +1036,7 @@ class bbb
{ {
$url = isset($record['playbackFormatUrl']) ? $record['playbackFormatUrl'] : ''; $url = isset($record['playbackFormatUrl']) ? $record['playbackFormatUrl'] : '';
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq().'&action=add_to_calendar&id='.$meeting['id'].'&start='.api_strtotime($meeting['created_at']).'&url='.$url; return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=add_to_calendar&id='.$meeting['id'].'&start='.api_strtotime($meeting['created_at']).'&url='.$url;
} }
/** /**
@ -904,7 +1045,7 @@ class bbb
*/ */
public function publishUrl($meeting) public function publishUrl($meeting)
{ {
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq().'&action=publish&id='.$meeting['id']; return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=publish&id='.$meeting['id'];
} }
/** /**
@ -913,7 +1054,7 @@ class bbb
*/ */
public function unPublishUrl($meeting) public function unPublishUrl($meeting)
{ {
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq().'&action=unpublish&id='.$meeting['id']; return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=unpublish&id='.$meeting['id'];
} }
/** /**
@ -922,7 +1063,7 @@ class bbb
*/ */
public function deleteRecordUrl($meeting) public function deleteRecordUrl($meeting)
{ {
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq().'&action=delete_record&id='.$meeting['id']; return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=delete_record&id='.$meeting['id'];
} }
/** /**
@ -931,6 +1072,6 @@ class bbb
*/ */
public function copyToRecordToLinkTool($meeting) public function copyToRecordToLinkTool($meeting)
{ {
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq().'&action=copy_record_to_link_tool&id='.$meeting['id']; return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=copy_record_to_link_tool&id='.$meeting['id'];
} }
} }

@ -16,7 +16,7 @@ class BBBPlugin extends Plugin
{ {
public $isCoursePlugin = true; public $isCoursePlugin = true;
//When creating a new course this settings are added to the course // When creating a new course this settings are added to the course
public $course_settings = array( public $course_settings = array(
array( array(
'name' => 'big_blue_button_record_and_store', 'name' => 'big_blue_button_record_and_store',
@ -30,12 +30,20 @@ class BBBPlugin extends Plugin
protected function __construct() protected function __construct()
{ {
parent::__construct( parent::__construct(
'2.2', '2.4',
'Julio Montoya, Yannick Warnier', 'Julio Montoya, Yannick Warnier',
array('tool_enable' => 'boolean', 'host' => 'text', 'salt' => 'text') [
'tool_enable' => 'boolean',
'host' => 'text',
'salt' => 'text',
'enable_global_conference' => 'boolean',
]
); );
} }
/**
* @return BBBPlugin|null
*/
public static function create() public static function create()
{ {
static $result = null; static $result = null;
@ -51,6 +59,7 @@ class BBBPlugin extends Plugin
$sql = "CREATE TABLE IF NOT EXISTS $table ( $sql = "CREATE TABLE IF NOT EXISTS $table (
id INT unsigned NOT NULL auto_increment PRIMARY KEY, id INT unsigned NOT NULL auto_increment PRIMARY KEY,
c_id INT unsigned NOT NULL DEFAULT 0, c_id INT unsigned NOT NULL DEFAULT 0,
group_id INT unsigned NOT NULL DEFAULT 0,
meeting_name VARCHAR(255) NOT NULL DEFAULT '', meeting_name VARCHAR(255) NOT NULL DEFAULT '',
attendee_pw VARCHAR(255) NOT NULL DEFAULT '', attendee_pw VARCHAR(255) NOT NULL DEFAULT '',
moderator_pw VARCHAR(255) NOT NULL DEFAULT '', moderator_pw VARCHAR(255) NOT NULL DEFAULT '',
@ -80,8 +89,7 @@ class BBBPlugin extends Plugin
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS); $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST); $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
//New settings // New settings
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_tool_enable'"; $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_tool_enable'";
Database::query($sql); Database::query($sql);
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_salt'"; $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_salt'";

@ -11,24 +11,33 @@ $plugin = BBBPlugin::create();
$tool_name = $plugin->get_lang('Videoconference'); $tool_name = $plugin->get_lang('Videoconference');
$tpl = new Template($tool_name); $tpl = new Template($tool_name);
$bbb = new bbb(); $isGlobal = isset($_GET['global']) ? true : false;
$bbb = new bbb('', '', $isGlobal);
$action = isset($_GET['action']) ? $_GET['action'] : null; $action = isset($_GET['action']) ? $_GET['action'] : null;
$teacher = $bbb->isTeacher(); $conferenceManager = $bbb->isConferenceManager();
$courseInfo = api_get_course_info(); if ($bbb->isGlobalConference()) {
api_block_anonymous_users();
} else {
api_protect_course_script(true);
}
api_protect_course_script(true);
$message = null; $message = null;
if ($teacher) { if ($conferenceManager) {
switch ($action) { switch ($action) {
case 'add_to_calendar': case 'add_to_calendar':
$course_info = api_get_course_info(); if ($bbb->isGlobalConference()) {
return false;
}
$courseInfo = api_get_course_info();
$agenda = new Agenda(); $agenda = new Agenda();
$agenda->type = 'course'; $agenda->type = 'course';
$id = intval($_GET['id']); $id = intval($_GET['id']);
$title = sprintf(get_lang('VideoConferenceXCourseX'), $id, $course_info['name']); $title = sprintf(get_lang('VideoConferenceXCourseX'), $id, $courseInfo['name']);
$content = Display::url(get_lang('GoToTheVideoConference'), $_GET['url']); $content = Display::url(get_lang('GoToTheVideoConference'), $_GET['url']);
$eventId = $agenda->addEvent( $eventId = $agenda->addEvent(
@ -96,26 +105,27 @@ if ($teacher) {
break; break;
} }
} }
$meetings = $bbb->getCourseMeetings(); $meetings = $bbb->getMeetings();
if (!empty($meetings)) { if (!empty($meetings)) {
$meetings = array_reverse($meetings); $meetings = array_reverse($meetings);
} }
$users_online = $bbb->getUsersOnlineInCurrentRoom(); $users_online = $bbb->getUsersOnlineInCurrentRoom();
$status = $bbb->isServerRunning(); $status = $bbb->isServerRunning();
$meeting_exists = $bbb->meetingExists(api_get_course_id().'-'.api_get_session_id()); $meetingExists = $bbb->meetingExists($bbb->getCurrentVideoConferenceName());
$show_join_button = false; $showJoinButton = false;
if ($meeting_exists || $teacher) { if ($meetingExists || $conferenceManager) {
$show_join_button = true; $showJoinButton = true;
} }
$tpl->assign('allow_to_edit', $teacher); $tpl->assign('allow_to_edit', $conferenceManager);
$tpl->assign('meetings', $meetings); $tpl->assign('meetings', $meetings);
$conferenceUrl = $bbb->getConferenceUrl(); $conferenceUrl = $bbb->getConferenceUrl();
$tpl->assign('conference_url', $conferenceUrl); $tpl->assign('conference_url', $conferenceUrl);
$tpl->assign('users_online', $users_online); $tpl->assign('users_online', $users_online);
$tpl->assign('bbb_status', $status); $tpl->assign('bbb_status', $status);
$tpl->assign('show_join_button', $show_join_button); $tpl->assign('show_join_button', $showJoinButton);
$tpl->assign('message', $message); $tpl->assign('message', $message);
$listing_tpl = 'bbb/listing.tpl'; $listing_tpl = 'bbb/listing.tpl';

@ -13,11 +13,12 @@ $tool_name = get_lang('Videoconference');
$tpl = new Template($tool_name); $tpl = new Template($tool_name);
$vmIsEnabled = false; $vmIsEnabled = false;
$host = null; $host = '';
$salt = null; $salt = '';
$bbb = new bbb(); $isGlobal = isset($_GET['global']) ? true : false;
$bbb = new bbb('', '', $isGlobal);
if ($bbb->plugin_enabled) { if ($bbb->pluginEnabled) {
if ($bbb->isServerRunning()) { if ($bbb->isServerRunning()) {
if (isset($_GET['launch']) && $_GET['launch'] == 1) { if (isset($_GET['launch']) && $_GET['launch'] == 1) {
@ -25,8 +26,8 @@ if ($bbb->plugin_enabled) {
if (file_exists(__DIR__ . '/config.vm.php')) { if (file_exists(__DIR__ . '/config.vm.php')) {
$config = require __DIR__ . '/config.vm.php'; $config = require __DIR__ . '/config.vm.php';
$vmIsEnabled = true; $vmIsEnabled = true;
$host = null; $host = '';
$salt = null; $salt = '';
require __DIR__ . '/lib/vm/AbstractVM.php'; require __DIR__ . '/lib/vm/AbstractVM.php';
require __DIR__ . '/lib/vm/VMInterface.php'; require __DIR__ . '/lib/vm/VMInterface.php';
@ -35,7 +36,7 @@ if ($bbb->plugin_enabled) {
$vm = new VM($config); $vm = new VM($config);
if ($vm->IsEnabled()) { if ($vm->isEnabled()) {
try { try {
$vm->resizeToMaxLimit(); $vm->resizeToMaxLimit();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -45,20 +46,20 @@ if ($bbb->plugin_enabled) {
} }
} }
$meeting_params = array(); $meetingParams = array();
$meeting_params['meeting_name'] = api_get_course_id().'-'.api_get_session_id(); $meetingParams['meeting_name'] = $bbb->getCurrentVideoConferenceName();
if ($bbb->meetingExists($meeting_params['meeting_name'])) { if ($bbb->meetingExists($meetingParams['meeting_name'])) {
$url = $bbb->joinMeeting($meeting_params['meeting_name']); $url = $bbb->joinMeeting($meetingParams['meeting_name']);
if ($url) { if ($url) {
$bbb->redirectToBBB($url); $bbb->redirectToBBB($url);
} else { } else {
$url = $bbb->createMeeting($meeting_params); $url = $bbb->createMeeting($meetingParams);
$bbb->redirectToBBB($url); $bbb->redirectToBBB($url);
} }
} else { } else {
if ($bbb->isTeacher()) { if ($bbb->isConferenceManager()) {
$url = $bbb->createMeeting($meeting_params); $url = $bbb->createMeeting($meetingParams);
$bbb->redirectToBBB($url); $bbb->redirectToBBB($url);
} else { } else {
$url = $bbb->getListingUrl(); $url = $bbb->getListingUrl();

Loading…
Cancel
Save