Improve access tracking in BBB

pull/3348/head
Nosolored 6 years ago
parent 94cf83af56
commit 1d30b92cd1
  1. 32
      plugin/bbb/cron_close_meeting.php
  2. 45
      plugin/bbb/lib/bbb.lib.php
  3. 30
      plugin/bbb/lib/bbb_plugin.class.php
  4. 108
      plugin/bbb/listing.php

@ -48,6 +48,12 @@ if ($bbb->pluginEnabled) {
$bbb->endMeeting($value['id'], $courseCode);
break;
case 'SUCCESS':
Database::update(
$roomTable,
['close' => BBBPlugin::ROOM_CHECK],
['meeting_id = ? AND close= ?' => [$meetingId, BBBPlugin::ROOM_OPEN]]
);
$i = 0;
while ($i < $meetingBBB['participantCount']) {
$participantId = $meetingBBB[$i]['userId'];
@ -56,22 +62,36 @@ if ($bbb->pluginEnabled) {
$roomTable,
[
'where' => [
'meeting_id = ? AND participant_id = ?' => [$meetingId, $participantId],
'meeting_id = ? AND participant_id = ? AND close = ?' => [
$meetingId,
$participantId,
BBBPlugin::ROOM_CHECK,
],
],
'order' => 'id DESC',
],
'first'
);
if (!empty($roomData)) {
$roomId = $roomData['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
if (!empty($roomId)) {
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime(), 'close' => BBBPlugin::ROOM_OPEN],
['id = ? ' => $roomId]
);
}
}
$i++;
}
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime(), 'close' => BBBPlugin::ROOM_CLOSE],
['meeting_id = ? AND close= ?' => [$meetingId, BBBPlugin::ROOM_CHECK]]
);
break;
}
}

@ -769,11 +769,47 @@ class bbb
*/
public function saveParticipant($meetingId, $participantId, $interface = 0)
{
$meetingData = Database::select(
'*',
'plugin_bbb_room',
[
'where' => [
'meeting_id = ? AND participant_id = ? AND close = ?' => [
$meetingId,
$participantId,
BBBPlugin::ROOM_OPEN,
],
],
]
);
foreach ($meetingData as $roomItem) {
$inAt = $roomItem['in_at'];
$outAt = $roomItem['out_at'];
$roomId = $roomItem['id'];
if (!empty($roomId)) {
if ($inAt != $outAt) {
Database::update(
'plugin_bbb_room',
['close' => BBBPlugin::ROOM_CLOSE],
['id = ? ' => $roomId]
);
} else {
Database::update(
'plugin_bbb_room',
['out_at' => api_get_utc_datetime(), 'close' => BBBPlugin::ROOM_CLOSE],
['id = ? ' => $roomId]
);
}
}
}
$params = [
'meeting_id' => $meetingId,
'participant_id' => $participantId,
'in_at' => api_get_utc_datetime(),
'out_at' => api_get_utc_datetime(),
'close' => BBBPlugin::ROOM_OPEN,
];
if ($this->plugin->get('interface') !== false) {
@ -1191,10 +1227,17 @@ class bbb
$roomId = $roomDB['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['out_at' => api_get_utc_datetime(), 'close' => BBBPlugin::ROOM_CLOSE],
['id = ? ' => $roomId]
);
}
// Close all meeting rooms with meeting ID
Database::update(
$roomTable,
['close' => BBBPlugin::ROOM_CLOSE],
['meeting_id = ? ' => $id]
);
}
/**

@ -21,6 +21,10 @@ class BBBPlugin extends Plugin
const LAUNCH_TYPE_SET_BY_TEACHER = 1;
const LAUNCH_TYPE_SET_BY_STUDENT = 2;
const ROOM_OPEN = 0;
const ROOM_CLOSE = 1;
const ROOM_CHECK = 2;
public $isCoursePlugin = true;
// When creating a new course this settings are added to the course
@ -45,8 +49,8 @@ class BBBPlugin extends Plugin
protected function __construct()
{
parent::__construct(
'2.8.1',
'Julio Montoya, Yannick Warnier, Angel Fernando Quiroz Campos',
'2.8.2',
'Julio Montoya, Yannick Warnier, Angel Fernando Quiroz Campos, Jose Angel Ruiz',
[
'tool_enable' => 'boolean',
'host' => 'text',
@ -326,6 +330,28 @@ class BBBPlugin extends Plugin
}
}
/**
* Update
*/
public function update()
{
$sql = "SHOW COLUMNS FROM plugin_bbb_room WHERE Field = 'close'";
$res = Database::query($sql);
if (Database::num_rows($res) === 0) {
$sql = "ALTER TABLE plugin_bbb_room ADD close int unsigned NULL";
$res = Database::query($sql);
if (!$res) {
echo Display::return_message($this->get_lang('ErrorUpdateFieldDB'), 'warning');
}
Database::update(
'plugin_bbb_room',
['close' => BBBPlugin::ROOM_CLOSE]
);
}
}
/**
* Return an array with URL
*

@ -184,47 +184,44 @@ if ($conferenceManager) {
}
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]
);
if (isset($meetingBBB['returncode'])) {
$status = (string) $meetingBBB['returncode'];
switch ($status) {
case 'FAILED':
$bbb->endMeeting($meetingId, $courseCode);
break;
case 'SUCCESS':
$i = 0;
while ($i < $meetingBBB['participantCount']) {
$participantId = $meetingBBB[$i]['userId'];
$roomData = Database::select(
'*',
$roomTable,
[
'where' => [
'meeting_id = ? AND participant_id = ? AND close = ?' => [
$meetingId,
$participantId,
BBBPlugin::ROOM_OPEN,
],
],
'order' => 'id DESC',
],
'first'
);
if (!empty($roomData)) {
$roomId = $roomData['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
}
$i++;
}
break;
}
$i++;
}
}
$conditions['where'] = ['meeting_id=? AND in_at=out_at' => [$meetingId]];
$roomList = Database::select(
'*',
$roomTable,
$conditions
);
if (!empty($roomList)) {
foreach ($roomList as $roomDB) {
$roomId = $roomDB['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
}
}
}
@ -244,7 +241,7 @@ if ($conferenceManager) {
$roomId = $roomData['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['out_at' => api_get_utc_datetime(), 'close' => BBBPlugin::ROOM_CLOSE],
['id = ? ' => $roomId]
);
}
@ -283,19 +280,30 @@ if ($conferenceManager) {
'*',
$roomTable,
[
'where' => ['meeting_id = ? AND participant_id = ?' => [$meetingId, $userId]],
'where' => [
'meeting_id = ? AND participant_id = ? AND close = ?' => [
$meetingId,
$userId,
BBBPlugin::ROOM_OPEN,
],
],
'order' => 'id DESC',
],
'first'
]
);
if (!empty($roomData)) {
$i = 0;
foreach ($roomData as $item) {
$roomId = $roomData['id'];
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
if ($i == 0) {
Database::update(
$roomTable,
['out_at' => api_get_utc_datetime()],
['id = ? ' => $roomId]
);
} else {
Database::update($roomTable, ['close' => BBBPlugin::ROOM_CLOSE], ['id = ? ' => $roomId]);
}
$i++;
}
$message = Display::return_message(

Loading…
Cancel
Save