admin.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * This script initiates a video conference session, calling the BigBlueButton API
  4. * @package chamilo.plugin.bigbluebutton
  5. */
  6. use Chamilo\UserBundle\Entity\User;
  7. $course_plugin = 'bbb'; //needed in order to load the plugin lang variables
  8. $cidReset = true;
  9. require_once __DIR__ . '/../../main/inc/global.inc.php';
  10. api_protect_admin_script();
  11. $plugin = BBBPlugin::create();
  12. $tool_name = $plugin->get_lang('Videoconference');
  13. $tpl = new Template($tool_name);
  14. $bbb = new bbb('', '');
  15. $action = isset($_GET['action']) ? $_GET['action'] : null;
  16. $meetings = $bbb->getMeetings();
  17. foreach ($meetings as &$meeting) {
  18. $participants = $bbb->findMeetingParticipants($meeting['id']);
  19. /** @var User $participant */
  20. foreach ($participants as $participant) {
  21. $meeting['participants'][] = $participant['participant']->getCompleteName();
  22. }
  23. }
  24. if ($action) {
  25. switch ($action) {
  26. case 'export':
  27. $dataToExport = [
  28. [$tool_name, get_lang('RecordList')],
  29. [],
  30. [
  31. get_lang('CreatedAt'),
  32. get_lang('Status'),
  33. get_lang('Records'),
  34. get_lang('Course'),
  35. get_lang('Session'),
  36. get_lang('Participants'),
  37. ]
  38. ];
  39. foreach ($meetings as $meeting) {
  40. $dataToExport[] = [
  41. $meeting['created_at'],
  42. $meeting['status'] == 1 ? get_lang('MeetingOpened') : get_lang('MeetingClosed'),
  43. $meeting['record'] == 1 ? get_lang('Yes') : get_lang('No'),
  44. $meeting['course'] ? $meeting['course']->getTitle() : '-',
  45. $meeting['session'] ? $meeting['session']->getName() : '-',
  46. isset($meeting['participants']) ? implode(PHP_EOL, $meeting['participants']) : null
  47. ];
  48. }
  49. Export::arrayToXls($dataToExport);
  50. break;
  51. }
  52. }
  53. if (!empty($meetings)) {
  54. $meetings = array_reverse($meetings);
  55. }
  56. if (!$bbb->isServerRunning()) {
  57. Display::addFlash(
  58. Display::return_message(get_lang('ServerIsNotRunning'), 'error')
  59. );
  60. }
  61. $tpl->assign('meetings', $meetings);
  62. $content = $tpl->fetch('bbb/admin.tpl');
  63. $actions = [];
  64. if ($meetings) {
  65. $actions[] = Display::toolbarButton(
  66. get_lang('ExportInExcel'),
  67. api_get_self() . '?action=export',
  68. 'file-excel-o',
  69. 'success',
  70. [],
  71. false
  72. );
  73. }
  74. $tpl->assign('header', get_lang('RecordList'));
  75. $tpl->assign('actions', implode('', $actions));
  76. $tpl->assign('content', $content);
  77. $tpl->display_one_col_template();