Plugin: BBB: Improve code readability

pull/4266/head
Angel Fernando Quiroz Campos 4 years ago
parent 6966c1ec7e
commit 0443e4bd7c
  1. 30
      plugin/bbb/cron_close_meeting.php
  2. 6
      plugin/bbb/lib/bbb.lib.php

@ -13,11 +13,18 @@ $roomTable = Database::get_main_table('plugin_bbb_room');
$applyAllUrls = 'true' === $plugin->get('plugin_bbb_multiple_urls_cron_apply_to_all'); $applyAllUrls = 'true' === $plugin->get('plugin_bbb_multiple_urls_cron_apply_to_all');
$bbb = new bbb(); $bbb = new bbb();
if ($bbb->pluginEnabled) {
$activeSessions = $bbb->getActiveSessions($applyAllUrls);
if (!empty($activeSessions)) { if (!$bbb->pluginEnabled) {
foreach ($activeSessions as $value) { return;
}
$activeSessions = $bbb->getActiveSessions($applyAllUrls);
if (empty($activeSessions)) {
return;
}
foreach ($activeSessions as $value) {
$meetingId = $value['id']; $meetingId = $value['id'];
$courseCode = null; $courseCode = null;
$courseInfo = api_get_course_info_by_id($value['c_id']); $courseInfo = api_get_course_info_by_id($value['c_id']);
@ -42,9 +49,16 @@ if ($bbb->pluginEnabled) {
$meetingBBB = $bbb->getMeetingInfo($params); $meetingBBB = $bbb->getMeetingInfo($params);
} }
if (!empty($meetingBBB)) { if (empty($meetingBBB)) {
if (isset($meetingBBB['returncode'])) { continue;
}
if (!isset($meetingBBB['returncode'])) {
continue;
}
$action = (string) $meetingBBB['returncode']; $action = (string) $meetingBBB['returncode'];
switch ($action) { switch ($action) {
case 'FAILED': case 'FAILED':
$bbb->endMeeting($value['id'], $courseCode); $bbb->endMeeting($value['id'], $courseCode);
@ -96,8 +110,4 @@ if ($bbb->pluginEnabled) {
break; break;
} }
}
}
}
}
} }

@ -1880,7 +1880,7 @@ class bbb
* *
* @return array * @return array
*/ */
public function getActiveSessions(bool $allSites = false) public function getActiveSessions(bool $allSites = false): array
{ {
$where = ['where' => ['status = ?' => 1]]; $where = ['where' => ['status = ?' => 1]];
@ -1888,13 +1888,11 @@ class bbb
$where['where'][' AND access_url = ?'] = $this->accessUrl; $where['where'][' AND access_url = ?'] = $this->accessUrl;
} }
$meetingList = Database::select( return Database::select(
'*', '*',
$this->table, $this->table,
$where $where
); );
return $meetingList;
} }
/** /**

Loading…
Cancel
Save