Browse Source

WIP: Add group conference support see BT#11014

jmontoyaa 8 years ago
parent
commit
621fefae92

+ 9 - 0
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);
+    }
 }

+ 14 - 7
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

+ 89 - 16
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();
     }
 

+ 2 - 1
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 '',

+ 1 - 0
plugin/bbb/listing.php

@@ -105,6 +105,7 @@ if ($conferenceManager) {
             break;
     }
 }
+    
 
 $meetings = $bbb->getMeetings();
 if (!empty($meetings)) {