Skip to content

Commit

Permalink
Allow generate records when user didn't click in "record conference" …
Browse files Browse the repository at this point in the history
…BT#15618
  • Loading branch information
jmontoyaa committed Jul 12, 2019
1 parent b626772 commit ad49e34
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 73 deletions.
118 changes: 76 additions & 42 deletions plugin/bbb/lib/bbb.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,8 @@ public function getMeetingInfo($params)
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");
Expand Down Expand Up @@ -766,7 +765,7 @@ public function getMeetings(
);

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'],
Expand All @@ -783,7 +782,7 @@ public function getMeetings(

$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);
}
Expand All @@ -804,39 +803,35 @@ public function getMeetings(
}

$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(
Expand Down Expand Up @@ -1127,6 +1122,10 @@ public function getUsersOnlineInCurrentRoom()
*/
public function regenerateRecording($id, $recordId)
{
if ($this->plugin->get('allow_regenerate_recording') !== 'true') {
return false;
}

if (empty($id)) {
return false;
}
Expand All @@ -1141,6 +1140,13 @@ public function regenerateRecording($id, $recordId)
// 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'])) {
Expand Down Expand Up @@ -1459,6 +1465,24 @@ public function regenerateRecordUrl($meeting, $recordInfo)
'&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
Expand Down Expand Up @@ -1590,14 +1614,29 @@ private function getActionLinks(
);

$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 {
Expand Down Expand Up @@ -1643,12 +1682,6 @@ private function getActionLinks(
}
}

if (!empty($recordInfo)) {
$links[] = Display::url(
Display::return_icon('reload.png', get_lang('RegenerateRecord')),
$this->regenerateRecordUrl($meetingInfo, $recordInfo)
);
}

if (!$isAdminReport) {
$links[] = Display::url(
Expand All @@ -1663,6 +1696,7 @@ private function getActionLinks(
);
}


return $links;
}

Expand Down
34 changes: 15 additions & 19 deletions plugin/bbb/lib/bbb_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,27 @@
-- 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;
Expand Down Expand Up @@ -396,8 +391,7 @@ public function getMeetingInfoWithXmlResponseArray($infoParams) {
'message' => $xml->message->__toString()
);
return $result;
}
else {
} else {
// In this case, we have success and meeting info:
$result = array(
'returncode' => $xml->returncode->__toString(),
Expand All @@ -415,7 +409,9 @@ public function getMeetingInfoWithXmlResponseArray($infoParams) {
'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(
Expand Down
10 changes: 3 additions & 7 deletions plugin/bbb/listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
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 {
Expand All @@ -93,9 +93,7 @@
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
);
Expand Down Expand Up @@ -238,8 +236,6 @@
$showClientOptions = true;
} else {
if ($meetingExists) {
//$meetingInfo = $bbb->getMeetingByName($videoConferenceName);
//$meetinUserInfo = $bbb->getMeetingParticipantInfo($meetingInfo['id'], api_get_user_id());
$urlList = $plugin->getUrlInterfaceLinks($conferenceUrl);
$showClientOptions = true;
}
Expand Down
7 changes: 2 additions & 5 deletions plugin/bbb/view/listing.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -151,16 +148,16 @@
{{ 'NoRecording'|get_plugin_lang('BBBPlugin') }}
{% endif %}
</td>
{% if allow_to_edit %}
<td>
{% if meeting.status == 1 %}
<a class="btn btn-default" href="{{ meeting.end_url }} ">
{{ 'CloseMeeting'|get_plugin_lang('BBBPlugin') }}
</a>
{% else %}
{{ meeting.action_links }}
{% endif %}
{{ meeting.action_links }}
</td>
{% endif %}
Expand Down

0 comments on commit ad49e34

Please sign in to comment.