From 29cc82f9773bc98d95ce31030e0fb58631eeb71c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 17 Apr 2019 09:58:00 +0200 Subject: [PATCH] Fix delete bbb records see BT#15513 --- plugin/bbb/lib/bbb.lib.php | 41 +++++++++++++------------ plugin/bbb/lib/bbb_api.php | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 20 deletions(-) diff --git a/plugin/bbb/lib/bbb.lib.php b/plugin/bbb/lib/bbb.lib.php index 2d93f31bae..10aa981bdb 100755 --- a/plugin/bbb/lib/bbb.lib.php +++ b/plugin/bbb/lib/bbb.lib.php @@ -1017,7 +1017,8 @@ class bbb } /** - * Generated a moderator password for the meeting + * Generated a moderator password for the meeting. + * * @param string $courseCode * * @return string A password for the moderation of the videoconference @@ -1038,7 +1039,8 @@ class bbb } /** - * Get users online in the current course room + * Get users online in the current course room. + * * @return int The number of users currently connected to the videoconference * @assert () > -1 */ @@ -1108,15 +1110,18 @@ class bbb if (!empty($info) && isset($info['participantCount'])) { return $info['participantCount']; - } + return 0; } /** - * Deletes a previous recording of a meeting + * Deletes a recording of a meeting + * * @param int $id ID of the recording - * @return array ? + * + * @return bool + * * @assert () === false * @todo Also delete links and agenda items created from this recording */ @@ -1135,24 +1140,20 @@ class bbb $delete = false; // Check if there are recordings for this meeting - $recordings = $this->api->getRecordingsWithXmlResponseArray(['meetingId' => $meetingData['remote_id']]); + $recordings = $this->api->getRecordings(['meetingId' => $meetingData['remote_id']]); if (!empty($recordings) && isset($recordings['messageKey']) && $recordings['messageKey'] == 'noRecordings') { $delete = true; } else { - $recordingParams = array( - /* - * NOTE: Set the recordId below to a valid id after you have - * created a recorded meeting, and received a real recordID - * back from your BBB server using the - * getRecordingsWithXmlResponseArray method. - */ - - // REQUIRED - We have to know which recording: - 'recordId' => $meetingData['remote_id'], - ); - $result = $this->api->deleteRecordingsWithXmlResponseArray($recordingParams); - if (!empty($result) && isset($result['deleted']) && $result['deleted'] === 'true') { - $delete = true; + $recordsToDelete = []; + if (!empty($recordings['records'])) { + foreach ($recordings['records'] as $record) { + $recordsToDelete[] = $record['recordId']; + } + $recordingParams = ['recordId' => implode(',', $recordsToDelete)]; + $result = $this->api->deleteRecordingsWithXmlResponseArray($recordingParams); + if (!empty($result) && isset($result['deleted']) && $result['deleted'] === 'true') { + $delete = true; + } } } diff --git a/plugin/bbb/lib/bbb_api.php b/plugin/bbb/lib/bbb_api.php index 764614fe98..3d2a35c4e9 100755 --- a/plugin/bbb/lib/bbb_api.php +++ b/plugin/bbb/lib/bbb_api.php @@ -509,6 +509,69 @@ class BigBlueButtonBN { } } + /** + * @param $array recordingParams + * + * @return array|null + */ + public function getRecordings($recordingParams) + { + /* USAGE: + $recordingParams = array( + 'meetingId' => '1234', -- OPTIONAL - comma separate if multiple ids + ); + NOTE: 'duration' DOES work when creating a meeting, so if you set duration + when creating a meeting, it will kick users out after the duration. Should + probably be required in user code when 'recording' is set to true. + */ + $xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams)); + if($xml) { + // If we don't get a success code or messageKey, find out why: + if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { + $result = array( + 'returncode' => $xml->returncode->__toString(), + 'messageKey' => $xml->messageKey->__toString(), + 'message' => $xml->message->__toString() + ); + return $result; + } + else { + // In this case, we have success and recording info: + $result = array( + 'returncode' => $xml->returncode->__toString(), + 'messageKey' => $xml->messageKey->__toString(), + 'message' => $xml->message->__toString() + ); + $result['records'] = []; + if (!empty($xml->recordings->recording)) { + foreach ($xml->recordings->recording as $r) { + $result['records'][] = array( + 'recordId' => $r->recordID->__toString(), + 'meetingId' => $r->meetingID->__toString(), + 'name' => $r->name->__toString(), + 'published' => $r->published->__toString(), + 'startTime' => $r->startTime->__toString(), + 'endTime' => $r->endTime->__toString(), + 'playbackFormatType' => $r->playback->format->type->__toString(), + 'playbackFormatUrl' => $r->playback->format->url->__toString(), + 'playbackFormatLength' => $r->playback->format->length->__toString(), + 'metadataTitle' => $r->metadata->title->__toString(), + 'metadataSubject' => $r->metadata->subject->__toString(), + 'metadataDescription' => $r->metadata->description->__toString(), + 'metadataCreator' => $r->metadata->creator->__toString(), + 'metadataContributor' => $r->metadata->contributor->__toString(), + 'metadataLanguage' => $r->metadata->language->__toString(), + ); + } + } + + return $result; + } + } + + return null; + } + public function getPublishRecordingsUrl($recordingParams) { /* USAGE: $recordingParams = array(