Browse Source

Save bbb "internal meeting id" in plugin_bbb_meeting table see BT#15618

Requires DB change. That id is needed in order to regenerate records.
Julio Montoya 5 years ago
parent
commit
89fed6ecde
4 changed files with 52 additions and 51 deletions
  1. 5 1
      plugin/bbb/README.md
  2. 15 21
      plugin/bbb/lib/bbb.lib.php
  3. 24 22
      plugin/bbb/lib/bbb_api.php
  4. 8 7
      plugin/bbb/lib/bbb_plugin.class.php

+ 5 - 1
plugin/bbb/README.md

@@ -56,4 +56,8 @@ ALTER TABLE plugin_bbb_meeting ADD COLUMN interface INT NOT NULL DEFAULT 0;
 ALTER TABLE plugin_bbb_room ADD COLUMN interface INT NOT NULL DEFAULT 0;
 ALTER TABLE plugin_bbb_room MODIFY COLUMN in_at datetime;
 ALTER TABLE plugin_bbb_room MODIFY COLUMN out_at datetime;
-```
+```
+
+For version 2.8
+
+ALTER TABLE plugin_bbb_meeting ADD COLUMN internal_meeting_id VARCHAR(255) DEFAULT NULL;

+ 15 - 21
plugin/bbb/lib/bbb.lib.php

@@ -357,7 +357,7 @@ class bbb
             $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;
+            //$duration = isset($params['duration']) ? intval($params['duration']) : 0;
             // This setting currently limits the maximum conference duration,
             // to avoid lingering sessions on the video-conference server #6261
             $duration = 300;
@@ -377,31 +377,23 @@ class bbb
                 //'meta_category' => '', 				// Use to pass additional info to BBB server. See API docs.
             );
 
-            if ($this->debug) {
-                error_log("create_meeting params: ".print_r($bbbParams, 1));
-            }
-
             $status = false;
             $meeting = null;
-
             while ($status === false) {
-                $result = $this->api->createMeetingWithXmlResponseArray(
-                    $bbbParams
-                );
+                $result = $this->api->createMeetingWithXmlResponseArray($bbbParams);
                 if (isset($result) && strval($result['returncode']) == 'SUCCESS') {
-                    if ($this->debug) {
-                        error_log(
-                            "create_meeting result: ".print_r($result, 1)
-                        );
+                    if ($this->plugin->get('allow_regenerate_recording') === 'true') {
+                        $sql = "UPDATE $this->table SET internal_meeting_id = '".$result['internalMeetingID']."' 
+                                WHERE id = $id";
+                        Database::query($sql);
                     }
                     $meeting = $this->joinMeeting($meetingName, true);
 
                     return $meeting;
                 }
             }
-
-            return false;
         }
+
         return false;
     }
 
@@ -827,7 +819,7 @@ class bbb
                     $recordLink = Display::url(
                         $this->plugin->get_lang('ViewRecord'),
                         $record['playbackFormatUrl'],
-                        ['target' => '_blank']
+                        ['target' => '_blank', 'class' => 'btn btn-default']
                     );
                 } else {
                     $recordLink = $this->plugin->get_lang('NoRecording');
@@ -1140,13 +1132,15 @@ class bbb
         // Check if there are recordings for this meeting
         $recordings = $this->api->getRecordings(['meetingId' => $meetingData['remote_id']]);
         if (!empty($recordings) && isset($recordings['messageKey']) && $recordings['messageKey'] === 'noRecordings') {
-            // we regenerate the meeting id
-            $pass = $this->getModMeetingPassword();
+            // Regenerate the meeting id
+            if (!empty($meetingData['internal_meeting_id'])) {
+                return $this->api->generateRecording(['recordId' => $meetingData['internal_meeting_id']]);
+            }
+            /*$pass = $this->getModMeetingPassword();
             $info = $this->getMeetingInfo(['meetingId' => $meetingData['remote_id'], 'password' => $pass]);
             if (!empty($info) && isset($info['internalMeetingID'])) {
-                return $this->api->generateRecording(['recordId' => $info['internalMeetingID']]);
-            }
-
+                return $this->api->generateRecording(['recordId' => $meetingData['internal_meeting_id']]);
+            }*/
             return false;
         } else {
             if (!empty($recordings['records'])) {

+ 24 - 22
plugin/bbb/lib/bbb_api.php

@@ -138,7 +138,8 @@ class BigBlueButtonBN
 		return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
 	}
 
-	public function createMeetingWithXmlResponseArray($creationParams) {
+	public function createMeetingWithXmlResponseArray($creationParams)
+    {
 		/*
 		USAGE:
 		$creationParams = array(
@@ -160,27 +161,28 @@ class BigBlueButtonBN
 		$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
 
         if ($xml) {
-			if($xml->meetingID)
-				return array(
-					'returncode' => $xml->returncode->__toString(),
-					'message' => $xml->message->__toString(),
-					'messageKey' => $xml->messageKey->__toString(),
-					'meetingId' => $xml->meetingID->__toString(),
-					'attendeePw' => $xml->attendeePW->__toString(),
-					'moderatorPw' => $xml->moderatorPW->__toString(),
-					'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(),
-					'createTime' => $xml->createTime->__toString()
-					);
-			else
-				return array(
-					'returncode' => $xml->returncode->__toString(),
-					'message' => $xml->message->__toString(),
-					'messageKey' => $xml->messageKey->__toString()
-					);
-		}
-		else {
-			return null;
-		}
+            if ($xml->meetingID) {
+                return array(
+                    'returncode' => $xml->returncode->__toString(),
+                    'message' => $xml->message->__toString(),
+                    'messageKey' => $xml->messageKey->__toString(),
+                    'meetingId' => $xml->meetingID->__toString(),
+                    'attendeePw' => $xml->attendeePW->__toString(),
+                    'moderatorPw' => $xml->moderatorPW->__toString(),
+                    'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(),
+                    'createTime' => $xml->createTime->__toString(),
+                    'internalMeetingID' => $xml->internalMeetingID->__toString()
+                );
+            } else {
+                return array(
+                    'returncode' => $xml->returncode->__toString(),
+                    'message' => $xml->message->__toString(),
+                    'messageKey' => $xml->messageKey->__toString(),
+                );
+            }
+        } else {
+            return null;
+        }
 	}
 
 	public function getJoinMeetingURL($joinParams) {

+ 8 - 7
plugin/bbb/lib/bbb_plugin.class.php

@@ -42,7 +42,7 @@ class BBBPlugin extends Plugin
     protected function __construct()
     {
         parent::__construct(
-            '2.7',
+            '2.8',
             'Julio Montoya, Yannick Warnier, Angel Fernando Quiroz Campos',
             [
                 'tool_enable' => 'boolean',
@@ -96,9 +96,9 @@ class BBBPlugin extends Plugin
         if ($variable === 'bbb_enable_conference_in_groups') {
             if ($this->get('enable_conference_in_course_groups') === 'true') {
                 return true;
-            } else {
-                return false;
             }
+
+            return false;
         }
 
         return true;
@@ -134,12 +134,13 @@ class BBBPlugin extends Plugin
                 welcome_msg VARCHAR(255) NOT NULL DEFAULT '',
                 session_id INT unsigned DEFAULT 0,
                 remote_id CHAR(30),
+                internal_meeting_id VARCHAR(255) DEFAULT NULL,
                 visibility TINYINT NOT NULL DEFAULT 1,
                 voice_bridge INT NOT NULL DEFAULT 1,
                 access_url INT NOT NULL DEFAULT 1,
                 video_url TEXT NULL,
                 has_video_m4v TINYINT NOT NULL DEFAULT 0,
-                interface INT NOT NULL DEFAULT 0                
+                interface INT NOT NULL DEFAULT 0                                              
                 )";
         Database::query($sql);
 
@@ -281,7 +282,7 @@ class BBBPlugin extends Plugin
     {
         $data = [
             'text' => $this->get_lang('EnterConferenceFlash'),
-            'url' => $conferenceUrl . '&interface=' . self::INTERFACE_FLASH,
+            'url' => $conferenceUrl.'&interface='.self::INTERFACE_FLASH,
             'icon' => 'resources/img/64/videoconference_flash.png'
         ];
         return $data;
@@ -296,8 +297,8 @@ class BBBPlugin extends Plugin
     {
         $data = [
             'text' => $this->get_lang('EnterConferenceHTML5'),
-            'url' => $conferenceUrl . '&interface=' . self::INTERFACE_HTML5,
-            'icon' => 'resources/img/64/videoconference_html5.png'
+            'url' => $conferenceUrl.'&interface='.self::INTERFACE_HTML5,
+            'icon' => 'resources/img/64/videoconference_html5.png',
         ];
         return $data;
     }