Browse Source

Allow generate records when user didn't click in "record conference" BT#15618

Julio Montoya 5 năm trước cách đây
mục cha
commit
ad49e34f83
4 tập tin đã thay đổi với 96 bổ sung73 xóa
  1. 76 42
      plugin/bbb/lib/bbb.lib.php
  2. 15 19
      plugin/bbb/lib/bbb_api.php
  3. 3 7
      plugin/bbb/listing.php
  4. 2 5
      plugin/bbb/view/listing.tpl

+ 76 - 42
plugin/bbb/lib/bbb.lib.php

@@ -628,9 +628,8 @@ class bbb
                 if ($this->debug) {
                     error_log("Failed to get any response. Maybe we can't contact the BBB server.");
                 }
-            } else {
-                return $result;
             }
+            return $result;
         } catch (Exception $e) {
             if ($this->debug) {
                 error_log('Caught exception: ', $e->getMessage(), "\n");
@@ -766,7 +765,7 @@ class bbb
             );
 
             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
                 $params = array(
                     'meetingId' => $meetingDB['id'],
@@ -783,7 +782,7 @@ class bbb
 
             $meetingBBB['end_url'] = $this->endUrl($meetingDB);
 
-            if (isset($meetingBBB['returncode']) && (string) $meetingBBB['returncode'] == 'FAILED') {
+            if (isset($meetingBBB['returncode']) && (string) $meetingBBB['returncode'] === 'FAILED') {
                 if ($meetingDB['status'] == 1 && $this->isConferenceManager()) {
                     $this->endMeeting($meetingDB['id'], $courseCode);
                 }
@@ -804,39 +803,35 @@ class bbb
                 }
 
                 $record = [];
-                //if (empty($meetingDB['video_url'])) {
-                    $recordingParams = ['meetingId' => $mId];
-                    $records = $this->api->getRecordingsWithXmlResponseArray($recordingParams);
-
-                    if (!empty($records)) {
-                        if (!isset($records['messageKey']) || $records['messageKey'] != 'noRecordings') {
-                            $record = end($records);
-                            if (!is_array($record) || !isset($record['recordId'])) {
-                                continue;
-                            }
-
-                            if (!empty($record['playbackFormatUrl'])) {
-                                $this->updateMeetingVideoUrl($meetingDB['id'], $record['playbackFormatUrl']);
-                            }
-
-                            if (!$this->isConferenceManager()) {
-                                $record = [];
-                            }
+                $recordingParams = ['meetingId' => $mId];
+                $records = $this->api->getRecordingsWithXmlResponseArray($recordingParams);
+
+                if (!empty($records)) {
+                    if (!isset($records['messageKey']) || $records['messageKey'] !== 'noRecordings') {
+                        $record = end($records);
+                        if (!is_array($record) || !isset($record['recordId'])) {
+                            continue;
+                        }
+
+                        if (!empty($record['playbackFormatUrl'])) {
+                            $this->updateMeetingVideoUrl($meetingDB['id'], $record['playbackFormatUrl']);
                         }
-                    }
-                //}
 
-                /* else {
-                    $record['playbackFormatUrl'] = $meetingDB['video_url'];
-                }*/
+                        if (!$this->isConferenceManager()) {
+                            $record = [];
+                        }
+                    }
+                }
 
-                $recordLink = isset($record['playbackFormatUrl']) && !empty($record['playbackFormatUrl'])
-                    ? Display::url(
+                if (isset($record['playbackFormatUrl']) && !empty($record['playbackFormatUrl'])) {
+                    $recordLink = Display::url(
                         $this->plugin->get_lang('ViewRecord'),
                         $record['playbackFormatUrl'],
                         ['target' => '_blank']
-                    )
-                    : $this->plugin->get_lang('NoRecording');
+                    );
+                } else {
+                    $recordLink = $this->plugin->get_lang('NoRecording');
+                }
 
                 if ($isAdminReport) {
                     $this->forceCIdReq(
@@ -1127,6 +1122,10 @@ class bbb
      */
     public function regenerateRecording($id, $recordId)
     {
+        if ($this->plugin->get('allow_regenerate_recording') !== 'true') {
+            return false;
+        }
+
         if (empty($id)) {
             return false;
         }
@@ -1141,6 +1140,13 @@ 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();
+            $info = $this->getMeetingInfo(['meetingId' => $meetingData['remote_id'], 'password' => $pass]);
+            if (!empty($info) && isset($info['internalMeetingID'])) {
+                return $this->api->generateRecording(['recordId' => $info['internalMeetingID']]);
+            }
+
             return false;
         } else {
             if (!empty($recordings['records'])) {
@@ -1459,6 +1465,24 @@ class bbb
             '&action=regenerate_record&id='.$meeting['id'].'&record_id='.$recordInfo['recordId'];
     }
 
+    /**
+     * @param array $meeting
+     *
+     * @return string
+     */
+    public function regenerateRecordUrlFromMeeting($meeting)
+    {
+        if ($this->plugin->get('allow_regenerate_recording') !== 'true') {
+            return '';
+        }
+
+        if (!isset($meeting['id'])) {
+            return '';
+        }
+
+        return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().
+            '&action=regenerate_record&id='.$meeting['id'];
+    }
 
     /**
      * @param array $meeting
@@ -1590,14 +1614,29 @@ class bbb
             );
 
         $links = [];
+        if ($this->plugin->get('allow_regenerate_recording') === 'true' && $meetingInfo['status'] == 1) {
+            if (!empty($recordInfo)) {
+                $links[] = Display::url(
+                    Display::return_icon('reload.png', get_lang('RegenerateRecord')),
+                    $this->regenerateRecordUrl($meetingInfo, $recordInfo)
+                );
+            } else {
+                $links[] = Display::url(
+                    Display::return_icon('reload.png', get_lang('RegenerateRecord')),
+                    $this->regenerateRecordUrlFromMeeting($meetingInfo)
+                );
+            }
+        }
 
         if (empty($recordInfo)) {
             if (!$isAdminReport) {
-                $links[] = Display::url(
-                    Display::return_icon('delete.png', get_lang('Delete')),
-                    $this->deleteRecordUrl($meetingInfo)
-                );
-                $links[] = $linkVisibility;
+                if ($meetingInfo['status'] == 0) {
+                    $links[] = Display::url(
+                        Display::return_icon('delete.png', get_lang('Delete')),
+                        $this->deleteRecordUrl($meetingInfo)
+                    );
+                    $links[] = $linkVisibility;
+                }
 
                 return $links;
             } else {
@@ -1643,12 +1682,6 @@ class bbb
             }
         }
 
-        if (!empty($recordInfo)) {
-            $links[] = Display::url(
-                Display::return_icon('reload.png', get_lang('RegenerateRecord')),
-                $this->regenerateRecordUrl($meetingInfo, $recordInfo)
-            );
-        }
 
         if (!$isAdminReport) {
             $links[] = Display::url(
@@ -1663,6 +1696,7 @@ class bbb
             );
         }
 
+
         return $links;
     }
 

+ 15 - 19
plugin/bbb/lib/bbb_api.php

@@ -37,32 +37,27 @@ Versions:
 					    -- See included samples for usage examples
 */
 
-/* _______________________________________________________________________*/
-
-/* get the config values */
-//require_once "config.php";
-
-class BigBlueButtonBN {
-
+class BigBlueButtonBN
+{
 	private $_securitySalt;
 	private $_bbbServerBaseUrl;
 
-	/* ___________ General Methods for the BigBlueButton Class __________ */
-
-	function __construct() {
-	/*
-	Establish just our basic elements in the constructor:
-	*/
+	public function __construct()
+    {
+        /*
+        Establish just our basic elements in the constructor:
+        */
 		// BASE CONFIGS - set these for your BBB server in config.php and they will
 		// simply flow in here via the constants:
 		$this->_securitySalt 		= CONFIG_SECURITY_SALT;
 		$this->_bbbServerBaseUrl 	= CONFIG_SERVER_BASE_URL;
 	}
 
-	private function _processXmlResponse($url){
-	/*
-	A private utility method used by other public methods to process XML responses.
-	*/
+	private function _processXmlResponse($url)
+    {
+        /*
+        A private utility method used by other public methods to process XML responses.
+        */
 		if (extension_loaded('curl')) {
 			$ch = curl_init() or die ( curl_error($ch) );
 			$timeout = 10;
@@ -396,8 +391,7 @@ class BigBlueButtonBN {
 					'message' => $xml->message->__toString()
 				);
 				return $result;
-			}
-			else {
+			} else {
 				// In this case, we have success and meeting info:
 				$result = array(
 					'returncode' => $xml->returncode->__toString(),
@@ -415,7 +409,9 @@ class BigBlueButtonBN {
 					'participantCount' => $xml->participantCount->__toString(),
 					'maxUsers' => $xml->maxUsers->__toString(),
 					'moderatorCount' => $xml->moderatorCount->__toString(),
+                    'internalMeetingID' => $xml->internalMeetingID->__toString()
 				);
+
 				// Then interate through attendee results and return them as part of the array:
 				foreach ($xml->attendees->attendee as $a) {
 					$result[] = array(

+ 3 - 7
plugin/bbb/listing.php

@@ -66,8 +66,8 @@ if ($conferenceManager) {
             if ($plugin->get('allow_regenerate_recording') !== 'true') {
                 api_not_allowed();
             }
-            $result = $bbb->regenerateRecording($_GET['id'], $_GET['record_id']);
-
+            $recordId = isset($_GET['record_id']) ? $_GET['record_id'] : '';
+            $result = $bbb->regenerateRecording($_GET['id'], $recordId);
             if ($result) {
                 $message = Display::return_message(get_lang('Success'), 'success');
             } else {
@@ -93,9 +93,7 @@ if ($conferenceManager) {
         case 'end':
             $bbb->endMeeting($_GET['id']);
             $message = Display::return_message(
-                $plugin->get_lang('MeetingClosed').'<br />'.$plugin->get_lang(
-                    'MeetingClosedComment'
-                ),
+                $plugin->get_lang('MeetingClosed').'<br />'.$plugin->get_lang('MeetingClosedComment'),
                 'success',
                 false
             );
@@ -238,8 +236,6 @@ switch ($type) {
             $showClientOptions = true;
         } else {
             if ($meetingExists) {
-                //$meetingInfo = $bbb->getMeetingByName($videoConferenceName);
-                //$meetinUserInfo = $bbb->getMeetingParticipantInfo($meetingInfo['id'], api_get_user_id());
                 $urlList = $plugin->getUrlInterfaceLinks($conferenceUrl);
                 $showClientOptions = true;
             }

+ 2 - 5
plugin/bbb/view/listing.tpl

@@ -118,15 +118,12 @@
 
         <table class="table">
             <tr>
-                <!-- th>#</th -->
                 <th>{{ 'CreatedAt'| get_plugin_lang('BBBPlugin') }}</th>
                 <th>{{ 'Status'| get_lang }}</th>
                 <th>{{ 'Records'| get_plugin_lang('BBBPlugin') }}</th>
-
                 {% if allow_to_edit  %}
                     <th>{{ 'Actions'| get_lang }}</th>
                 {% endif %}
-
             </tr>
             {% for meeting in meetings %}
             <tr>
@@ -151,7 +148,6 @@
                         {{ 'NoRecording'|get_plugin_lang('BBBPlugin') }}
                     {% endif %}
                 </td>
-
                 {% if allow_to_edit %}
                     <td>
                     {% if meeting.status == 1 %}
@@ -159,8 +155,9 @@
                             {{ 'CloseMeeting'|get_plugin_lang('BBBPlugin') }}
                         </a>
                     {% else %}
-                        {{ meeting.action_links }}
+
                     {% endif %}
+                        {{ meeting.action_links }}
                     </td>
                 {% endif %}