Skip to content

Commit

Permalink
WIP: Add group conference support see BT#11014
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed May 9, 2016
1 parent a47b7ac commit 621fefa
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 24 deletions.
9 changes: 9 additions & 0 deletions main/inc/lib/database.lib.php
Expand Up @@ -672,4 +672,13 @@ public static function tableExists($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);
}
}
21 changes: 14 additions & 7 deletions plugin/bbb/changelog.md
@@ -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:
* 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:
* 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);".
Expand All @@ -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
* Show number of minutes of the recording (in the recordings list)

version 2.1
Version 2.1
-----------
Released with: Chamilo LMS 1.9.8
Changes:
* 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
105 changes: 89 additions & 16 deletions plugin/bbb/lib/bbb.lib.php
Expand Up @@ -27,6 +27,7 @@ class bbb
public $pluginEnabled = false;
public $enableGlobalConference = false;
public $isGlobalConference = false;
public $groupSupport = false;

/**
* Constructor (generates a connection to the API and the Chamilo settings
Expand All @@ -49,6 +50,9 @@ public function __construct($host = '', $salt = '', $isGlobalConference = false)
$this->enableGlobalConference = $plugin->get('enable_global_conference');
$this->isGlobalConference = (bool) $isGlobalConference;

$columns = Database::listTableColumns($this->table);
$this->groupSupport = isset($columns['group_id']) ? true : false;

if ($bbbPlugin === true) {
$userInfo = api_get_user_info();
$this->user_complete_name = $userInfo['complete_name'];
Expand Down Expand Up @@ -90,6 +94,14 @@ public function isGlobalConference()
return (bool) $this->isGlobalConference;
}

/**
* @return bool
*/
public function hasGroupSupport()
{
return $this->groupSupport;
}

/**
* 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
Expand Down Expand Up @@ -137,6 +149,10 @@ public function createMeeting($params)
$params['c_id'] = api_get_course_int_id();
$params['session_id'] = api_get_session_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'];
$params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword();
Expand Down Expand Up @@ -166,7 +182,7 @@ public function createMeeting($params)
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;
$record = isset($params['record']) && $params['record'] ? 'true' : 'false';
$duration = isset($params['duration']) ? intval($params['duration']) : 0;
Expand Down Expand Up @@ -235,17 +251,31 @@ public function meetingExists($meetingName)

$courseId = api_get_course_int_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(
'*',
$this->table,
array(
'where' => array(
'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 ' =>
array($courseId, $sessionId, $meetingName)
)
),
$conditions,
'first'
);


if ($this->debug) {
error_log("meeting_exists ".print_r($meetingData, 1));
}
Expand Down Expand Up @@ -396,17 +426,32 @@ public function getMeetingInfo($params)
public function getMeetings()
{
$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(
'*',
$this->table,
array(
'where' => array(
'c_id = ? AND session_id = ? ' => array(
api_get_course_int_id(),
api_get_session_id(),
),
),
)
$conditions
);
$isGlobal = $this->isGlobalConference();
$newMeetingList = array();
Expand Down Expand Up @@ -732,12 +777,35 @@ public function getUsersOnlineInCurrentRoom()
{
$courseId = api_get_course_int_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(
'*',
$this->table,
array('where' => array('c_id = ? AND session_id = ? AND status = 1 ' => array($courseId, $sessionId))),
$conditions,
'first'
);

if (empty($meetingData)) {
return 0;
}
Expand Down Expand Up @@ -926,6 +994,11 @@ public function getCurrentVideoConferenceName()
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();
}

Expand Down
3 changes: 2 additions & 1 deletion plugin/bbb/lib/bbb_plugin.class.php
Expand Up @@ -30,7 +30,7 @@ class BBBPlugin extends Plugin
protected function __construct()
{
parent::__construct(
'2.3',
'2.4',
'Julio Montoya, Yannick Warnier',
[
'tool_enable' => 'boolean',
Expand Down Expand Up @@ -59,6 +59,7 @@ public function install()
$sql = "CREATE TABLE IF NOT EXISTS $table (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
c_id INT unsigned NOT NULL DEFAULT 0,
group_id INT unsigned NOT NULL DEFAULT 0,
meeting_name VARCHAR(255) NOT NULL DEFAULT '',
attendee_pw VARCHAR(255) NOT NULL DEFAULT '',
moderator_pw VARCHAR(255) NOT NULL DEFAULT '',
Expand Down
1 change: 1 addition & 0 deletions plugin/bbb/listing.php
Expand Up @@ -105,6 +105,7 @@
break;
}
}


$meetings = $bbb->getMeetings();
if (!empty($meetings)) {
Expand Down

0 comments on commit 621fefa

Please sign in to comment.