admin.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. $bbb = new bbb('', '');
  14. $action = isset($_GET['action']) ? $_GET['action'] : null;
  15. $currentMonth = date('n');
  16. $dateStart = isset($_REQUEST['search_meeting_start']) ? $_REQUEST['search_meeting_start'] : date('Y-m-d', mktime(1, 1, 1, $currentMonth, 1, date('Y')));
  17. $dateEnd = isset($_REQUEST['search_meeting_end']) ? $_REQUEST['search_meeting_end'] : date('Y-m-d', mktime(1, 1, 1, ++$currentMonth, 0, date('Y')));
  18. $dateRange = [
  19. 'search_meeting_start' => $dateStart,
  20. 'search_meeting_end' => $dateEnd
  21. ];
  22. $form = new FormValidator(get_lang('Search'));
  23. $form->addDatePicker('search_meeting_start', get_lang('DateStart'));
  24. $form->addDatePicker('search_meeting_end', get_lang('DateEnd'));
  25. $form->addButtonSearch(get_lang('Search'));
  26. $form->setDefaults($dateRange);
  27. $actions = [];
  28. if ($form->validate()) {
  29. $dateRange = $form->getSubmitValues();
  30. $meetings = $bbb->getMeetings(0, 0, 0, true, $dateRange);
  31. } else {
  32. $meetings = $bbb->getMeetings(0, 0, 0, true, $dateRange);
  33. }
  34. foreach ($meetings as &$meeting) {
  35. $participants = $bbb->findMeetingParticipants($meeting['id']);
  36. foreach ($participants as $meetingParticipant) {
  37. /** @var User $participant */
  38. $participant = $meetingParticipant['participant'];
  39. $meeting['participants'][] = $participant->getCompleteName()
  40. . ' (' . $participant->getEmail() . ')';
  41. }
  42. }
  43. if ($action) {
  44. switch ($action) {
  45. case 'export':
  46. $dataToExport = [
  47. [$tool_name, $plugin->get_lang('RecordList')],
  48. [],
  49. [
  50. get_lang('CreatedAt'),
  51. get_lang('Status'),
  52. $plugin->get_lang('Records'),
  53. get_lang('Course'),
  54. get_lang('Session'),
  55. get_lang('Participants'),
  56. ]
  57. ];
  58. foreach ($meetings as $meeting) {
  59. $dataToExport[] = [
  60. $meeting['created_at'],
  61. $meeting['status'] == 1 ? $plugin->get_lang('MeetingOpened') : $plugin->get_lang('MeetingClosed'),
  62. $meeting['record'] == 1 ? get_lang('Yes') : get_lang('No'),
  63. $meeting['course'] ? $meeting['course']->getTitle() : '-',
  64. $meeting['session'] ? $meeting['session']->getName() : '-',
  65. isset($meeting['participants']) ? implode(PHP_EOL, $meeting['participants']) : null
  66. ];
  67. }
  68. Export::arrayToXls($dataToExport);
  69. break;
  70. }
  71. }
  72. if (!empty($meetings)) {
  73. $meetings = array_reverse($meetings);
  74. }
  75. if (!$bbb->isServerRunning()) {
  76. Display::addFlash(
  77. Display::return_message(get_lang('ServerIsNotRunning'), 'error')
  78. );
  79. }
  80. $htmlHeadXtra[] = api_get_js_simple(
  81. api_get_path(WEB_PLUGIN_PATH) . 'bbb/resources/utils.js'
  82. );
  83. $htmlHeadXtra[] = "<script>var _p = {web_plugin: '" . api_get_path(WEB_PLUGIN_PATH). "'}</script>";
  84. $tpl = new Template($tool_name);
  85. $tpl->assign('meetings', $meetings);
  86. $tpl->assign('search_form', $form->returnForm());
  87. $content = $tpl->fetch('bbb/admin.tpl');
  88. if ($meetings) {
  89. $actions[] = Display::toolbarButton(
  90. get_lang('ExportInExcel'),
  91. api_get_self() . '?action=export' . http_build_query([
  92. 'action' => 'export',
  93. 'search_meeting_start' => $dateStart,
  94. 'search_meeting_end' => $dateEnd
  95. ]),
  96. 'file-excel-o',
  97. 'success'
  98. );
  99. }
  100. $tpl->assign('header', $plugin->get_lang('RecordList'));
  101. $tpl->assign('actions', implode('', $actions));
  102. $tpl->assign('content', $content);
  103. $tpl->display_one_col_template();