admin.php 4.0 KB

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