Check-out at the videoconference BT#17071

pull/3235/head
Nosolored 6 years ago
parent 2f963e3c8c
commit 459c5b1ec5
  1. 80
      plugin/bbb/cron_close_meeting.php
  2. 1
      plugin/bbb/lang/spanish.php
  3. 32
      plugin/bbb/lib/bbb.lib.php
  4. 157
      plugin/bbb/listing.php

@ -0,0 +1,80 @@
<?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
require_once __DIR__.'/config.php';
$plugin = BBBPlugin::create();
$meetingTable = Database::get_main_table('plugin_bbb_meeting');
$roomTable = Database::get_main_table('plugin_bbb_room');
$bbb = new bbb();
if ($bbb->pluginEnabled) {
$activeSessions = $bbb->getActiveSessions();
if (!empty($activeSessions)) {
foreach ($activeSessions as $value) {
$meetingId = $value['id'];
$courseInfo = api_get_course_info_by_id($value['c_id']);
$courseCode = $courseInfo['code'];
$meetingBBB = $bbb->getMeetingInfo(
[
'meetingId' => $value['remote_id'],
'password' => $value['moderator_pw']
]
);
if ($meetingBBB === false) {
//checking with the remote_id didn't work, so just in case and
// to provide backwards support, check with the id
$params = array(
'meetingId' => $value['id'],
'password' => $value['moderator_pw']
);
$meetingBBB = $bbb->getMeetingInfo($params);
}
if (!empty($meetingBBB)) {
if (isset($meetingBBB['returncode'])) {
$action = (string) $meetingBBB['returncode'];
switch ($action) {
case 'FAILED':
$bbb->endMeeting($value['id'], $courseCode);
break;
case 'SUCCESS':
$i = 0;
while ($i < $meetingBBB['participantCount']) {
$participantId = $meetingBBB[$i]['userId'];
$roomData = Database::select(
'*',
$roomTable,
[
'where' => [
'meeting_id = ? AND participant_id = ?' => [$meetingId, $participantId]
],
'order' => 'id DESC',
],
'first'
);
if (!empty($roomData)) {
$roomId = $roomData['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
}
$i++;
}
break;
}
}
}
}
}
}

@ -9,6 +9,7 @@ $strings['MeetingOpened'] = "Sala abierta";
$strings['MeetingClosed'] = "Sala cerrada";
$strings['MeetingClosedComment'] = "Si ha pedido grabar la sesión de videoconferencia en los parámetros del curso, esta grabación aparecerá en la lista siguiente una vez generada.";
$strings['CloseMeeting'] = "Cerrar sala";
$strings['RoomExit'] = "Ha salido de la sesión de Videoconferencia";
$strings['VideoConferenceXCourseX'] = "Videoconferencia #%s, curso %s";
$strings['VideoConferenceAddedToTheCalendar'] = "Videoconferencia añadida al calendario";

@ -1159,6 +1159,24 @@ class bbb
array('status' => 0, 'closed_at' => api_get_utc_datetime()),
array('id = ? ' => $id)
);
// Update users with in_at y ou_at field equal
$roomTable = Database::get_main_table('plugin_bbb_room');
$conditions['where'] = ['meeting_id=? AND in_at=out_at' => [$id]];
$roomList = Database::select(
'*',
$roomTable,
$conditions
);
foreach ($roomList as $roomDB) {
$roomId = $roomDB['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
}
}
/**
@ -1788,6 +1806,20 @@ class bbb
return $meetingList['count'];
}
/**
* Get active session in the all platform
*/
public function getActiveSessions()
{
$meetingList = Database::select(
'*',
$this->table,
array('where' => array('status = ? AND access_url = ?' => array(1, $this->accessUrl)))
);
return $meetingList;
}
/**
* @param string $url
*/

@ -10,12 +10,14 @@ require_once __DIR__.'/config.php';
$plugin = BBBPlugin::create();
$tool_name = $plugin->get_lang('Videoconference');
$roomTable = Database::get_main_table('plugin_bbb_room');
$htmlHeadXtra[] = api_get_js_simple(api_get_path(WEB_PLUGIN_PATH).'bbb/resources/utils.js');
$isGlobal = isset($_GET['global']) ? true : false;
$isGlobalPerUser = isset($_GET['user_id']) ? (int) $_GET['user_id'] : false;
$action = isset($_GET['action']) ? $_GET['action'] : '';
$userId = api_get_user_id();
$bbb = new bbb('', '', $isGlobal, $isGlobalPerUser);
@ -145,12 +147,167 @@ if ($conferenceManager) {
}
}
$remoteId = Database::escape_string($_GET['remote_id']);
$meetingData = Database::select(
'*',
Database::get_main_table('plugin_bbb_meeting'),
['where' => ['remote_id = ? AND access_url = ?' => [$remoteId, api_get_current_access_url_id()]]],
'first'
);
if (empty($meetingData) || !is_array($meetingData)) {
error_log("meeting does not exist - remote_id: $remoteId");
} else {
$meetingId = $meetingData['id'];
// If creator -> update
if ($meetingData['creator_id'] == api_get_user_id()) {
$courseInfo = api_get_course_info();
$courseCode = $courseInfo['code'];
$pass = $bbb->getModMeetingPassword($courseCode);
$meetingBBB = $bbb->getMeetingInfo(
[
'meetingId' => $remoteId,
'password' => $pass
]
);
if ($meetingBBB === false) {
//checking with the remote_id didn't work, so just in case and
// to provide backwards support, check with the id
$params = [
'meetingId' => $meetingId,
// -- REQUIRED - The unique id for the meeting
'password' => $pass
// -- REQUIRED - The moderator password for the meeting
];
$meetingBBB = $bbb->getMeetingInfo($params);
}
if (!empty($meetingBBB)) {
$i = 0;
while ($i < $meetingBBB['participantCount']) {
$participantId = $meetingBBB[$i]['userId'];
$roomData = Database::select(
'*',
$roomTable,
[
'where' => [
'meeting_id = ? AND participant_id = ?' => [$meetingId, $participantId]
],
'order' => 'id DESC',
],
'first'
);
if (!empty($roomData)) {
$roomId = $roomData['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
}
$i++;
}
}
$conditions['where'] = ['meeting_id=? AND in_at=out_at' => [$meetingId]];
$roomList = Database::select(
'*',
$roomTable,
$conditions
);
foreach ($roomList as $roomDB) {
$roomId = $roomDB['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
}
}
// Update out_at field of user
$roomData = Database::select(
'*',
$roomTable,
[
'where' => ['meeting_id = ? AND participant_id = ?' => [$meetingId, $userId]],
'order' => 'id DESC',
],
'first'
);
if (!empty($roomData)) {
$roomId = $roomData['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
}
$message = Display::return_message(
$plugin->get_lang('RoomClosed').'<br />'.$plugin->get_lang('RoomClosedComment'),
'success',
false
);
Display::addFlash($message);
}
header('Location: '.$bbb->getListingUrl());
exit;
break;
default:
break;
}
} else {
if ($action == 'logout') {
// Update out_at field of user
$remoteId = Database::escape_string($_GET['remote_id']);
$meetingData = Database::select(
'*',
Database::get_main_table('plugin_bbb_meeting'),
['where' => ['remote_id = ? AND access_url = ?' => [$remoteId, api_get_current_access_url_id()]]],
'first'
);
if (empty($meetingData) || !is_array($meetingData)) {
error_log("meeting does not exist - remote_id: $remoteId");
} else {
$meetingId = $meetingData['id'];
$roomData = Database::select(
'*',
$roomTable,
[
'where' => ['meeting_id = ? AND participant_id = ?' => [$meetingId, $userId]],
'order' => 'id DESC',
],
'first'
);
if (!empty($roomData)) {
$roomId = $roomData['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
}
$message = Display::return_message(
$plugin->get_lang('RoomExit'),
'success',
false
);
Display::addFlash($message);
}
header('Location: '.$bbb->getListingUrl());
exit;
}
}
$meetings = $bbb->getMeetings(

Loading…
Cancel
Save