Check if the BBB meeting has a m4v file - refs BT#11636

pull/2487/head
Angel Fernando Quiroz Campos 9 years ago
parent c9a13e75f0
commit e5f0002860
  1. 14
      plugin/bbb/README.md
  2. 8
      plugin/bbb/admin.php
  3. 47
      plugin/bbb/ajax.php
  4. 55
      plugin/bbb/lib/bbb.lib.php
  5. 27
      plugin/bbb/resources/utils.js

@ -25,3 +25,17 @@ You need execute this SQL query in your database after making the Chamilo migrat
ALTER TABLE plugin_bbb_meeting ADD user_id int unsigned NOT NULL DEFAULT 0;
ALTER TABLE plugin_bbb_meeting ADD access_url int NOT NULL DEFAULT 1;
```
For the version 2.5 you need execute these SQL queries
```sql
CREATE TABLE plugin_bbb_room (
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
meeting_id int(10) unsigned NOT NULL,
participant_id int(11) NOT NULL,
in_at datetime NOT NULL,
out_at datetime NOT NULL,
FOREIGN KEY (meeting_id) REFERENCES plugin_bbb_meeting (id),
FOREIGN KEY (participant_id) REFERENCES user (id)
);
ALTER TABLE plugin_bbb_meeting ADD video_url TEXT NULL;
ALTER TABLE plugin_bbb_meeting ADD has_video_m4v TINYINT NOT NULL DEFAULT 0;
```

@ -15,7 +15,6 @@ api_protect_admin_script();
$plugin = BBBPlugin::create();
$tool_name = $plugin->get_lang('Videoconference');
$tpl = new Template($tool_name);
$isGlobal = isset($_GET['global']) ? true : false;
@ -75,6 +74,13 @@ if (!$bbb->isServerRunning()) {
);
}
$htmlHeadXtra[] = api_get_js_simple(
api_get_path(WEB_PLUGIN_PATH) . 'bbb/resources/utils.js'
);
$htmlHeadXtra[] = "<script>var _p = {web_plugin: '" . api_get_path(WEB_PLUGIN_PATH). "'}</script>";
$tpl = new Template($tool_name);
$tpl->assign('meetings', $meetings);
$content = $tpl->fetch('bbb/admin.tpl');

@ -0,0 +1,47 @@
<?php
/**
* This script initiates a video conference session, calling the BigBlueButton API
* @package chamilo.plugin.bigbluebutton
*/
$course_plugin = 'bbb'; //needed in order to load the plugin lang variables
$cidReset = true;
require_once __DIR__ . '/../../main/inc/global.inc.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$meetingId = isset($_REQUEST['meeting']) ? intval($_REQUEST['meeting']) : 0;
$bbb = new bbb('', '');
switch ($action) {
case 'check_m4v':
if (!api_is_platform_admin()) {
api_not_allowed();
exit;
}
if (!$meetingId) {
exit;
}
if ($bbb->checkDirectMeetingVideoUrl($meetingId)) {
$meetingInfo = Database::select(
'*',
'plugin_bbb_meeting',
['where' => ['id = ?' => intval($meetingId)]],
'first'
);
$url = $meetingInfo['video_url'] . '/capture.m4v';
$link = Display::url(
Display::return_icon('save.png', get_lang('DownloadFile')),
$meetingInfo['video_url'] . '/capture.m4v',
['target' => '_blank']
);
header('Content-Type: application/json');
echo json_encode(['url' => $url, 'link' => $link]);
}
break;
}

@ -1252,11 +1252,23 @@ class bbb
);
}
$links[] = Display::url(
Display::return_icon('save.png', get_lang('DownloadFile')),
$recordInfo['playbackFormatUrl'] . '/capture.m4v',
['target' => '_blank']
);
if ($meetingInfo['has_video_m4v']) {
$links[] = Display::url(
Display::return_icon('save.png', get_lang('DownloadFile')),
$recordInfo['playbackFormatUrl'] . '/capture.m4v',
['target' => '_blank']
);
} else {
$links[] = Display::url(
Display::return_icon('save.png', get_lang('DownloadFile')),
'#',
[
'id' => "btn-check-meeting-video-{$meetingInfo['id']}",
'class' => 'check-meeting-video',
'data-id' => $meetingInfo['id']
]
);
}
if (!$isAdminReport) {
$links[] = Display::url(
@ -1287,4 +1299,37 @@ class bbb
['id = ?' => intval($meetingId)]
);
}
/**
* Check if the meeting has a capture.m4v video file. If exists then the has_video_m4v field is updated
* @param int $meetingId
* @return bool
*/
public function checkDirectMeetingVideoUrl($meetingId)
{
$meetingInfo = Database::select(
'*',
'plugin_bbb_meeting',
[
'where' => ['id = ?' => intval($meetingId)]
],
'first'
);
if (!isset($meetingInfo['video_url'])) {
return false;
}
$hasCapture = SocialManager::verifyUrl($meetingInfo['video_url'] . '/capture.m4v');
if ($hasCapture) {
return Database::update(
'plugin_bbb_meeting',
['has_video_m4v' => true],
['id = ?' => intval($meetingId)]
);
}
return $hasCapture;
}
}

@ -0,0 +1,27 @@
$(document).on('ready', function () {
$('.check-meeting-video').on('click', function (e) {
e.preventDefault();
var $self = $(this),
meetingId = $self.data('id') || 0;
if (!meetingId) {
return;
}
var $loader = $('<span>', {
'aria-hidden': 'true'
}).addClass('fa fa-spinner fa-spin fa-fw');
$self.replaceWith($loader);
$.get(_p.web_plugin + 'bbb/ajax.php', {
a: 'check_m4v',
meeting: meetingId
}, function (response) {
$loader.replaceWith(response.link);
window.open(response.url);
});
});
});
Loading…
Cancel
Save