From 621fefae922bef53a35adcfc9847d4d9c2a67d3f Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Mon, 9 May 2016 16:31:25 +0200 Subject: [PATCH] WIP: Add group conference support see BT#11014 --- main/inc/lib/database.lib.php | 9 +++ plugin/bbb/changelog.md | 21 ++++-- plugin/bbb/lib/bbb.lib.php | 105 +++++++++++++++++++++++----- plugin/bbb/lib/bbb_plugin.class.php | 3 +- plugin/bbb/listing.php | 1 + 5 files changed, 115 insertions(+), 24 deletions(-) diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index 8db2d76600..a4b0eef8d2 100755 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -672,4 +672,13 @@ $connection->executeQuery('set sql_mode=""'); { 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); + } } diff --git a/plugin/bbb/changelog.md b/plugin/bbb/changelog.md index 6d94acb6b7..86ed797e33 100644 --- a/plugin/bbb/changelog.md +++ b/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);". @@ -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 diff --git a/plugin/bbb/lib/bbb.lib.php b/plugin/bbb/lib/bbb.lib.php index 418fd58721..10b35ac0f4 100755 --- a/plugin/bbb/lib/bbb.lib.php +++ b/plugin/bbb/lib/bbb.lib.php @@ -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 @@ -49,6 +50,9 @@ class bbb $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']; @@ -90,6 +94,14 @@ class bbb 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 @@ -137,6 +149,10 @@ class bbb $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(); @@ -166,7 +182,7 @@ class bbb 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; @@ -235,17 +251,31 @@ class bbb $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)); } @@ -396,17 +426,32 @@ class bbb 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(); @@ -732,12 +777,35 @@ class bbb { $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; } @@ -926,6 +994,11 @@ class bbb 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(); } diff --git a/plugin/bbb/lib/bbb_plugin.class.php b/plugin/bbb/lib/bbb_plugin.class.php index 8ad9fb41fd..9e7ff4e75a 100755 --- a/plugin/bbb/lib/bbb_plugin.class.php +++ b/plugin/bbb/lib/bbb_plugin.class.php @@ -30,7 +30,7 @@ class BBBPlugin extends Plugin protected function __construct() { parent::__construct( - '2.3', + '2.4', 'Julio Montoya, Yannick Warnier', [ 'tool_enable' => 'boolean', @@ -59,6 +59,7 @@ class BBBPlugin extends Plugin $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 '', diff --git a/plugin/bbb/listing.php b/plugin/bbb/listing.php index 195e7d9854..b059157a93 100755 --- a/plugin/bbb/listing.php +++ b/plugin/bbb/listing.php @@ -105,6 +105,7 @@ if ($conferenceManager) { break; } } + $meetings = $bbb->getMeetings(); if (!empty($meetings)) {