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. $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. if ($form->validate()) {
  29. $dateRange = $form->getSubmitValues();
  30. }
  31. $meetings = $bbb->getMeetings(0, 0, 0, true, $dateRange);
  32. foreach ($meetings as &$meeting) {
  33. $participants = $bbb->findMeetingParticipants($meeting['id']);
  34. foreach ($participants as $meetingParticipant) {
  35. /** @var User $participant */
  36. $participant = $meetingParticipant['participant'];
  37. $meeting['participants'][] = $participant->getCompleteName()
  38. . ' ('.$participant->getEmail().')';
  39. }
  40. }
  41. if ($action) {
  42. switch ($action) {
  43. case 'export':
  44. $dataToExport = [
  45. [$tool_name, $plugin->get_lang('RecordList')],
  46. [],
  47. [
  48. get_lang('CreatedAt'),
  49. get_lang('Status'),
  50. $plugin->get_lang('Records'),
  51. get_lang('Course'),
  52. get_lang('Session'),
  53. get_lang('Participants'),
  54. ]
  55. ];
  56. foreach ($meetings as $meeting) {
  57. $dataToExport[] = [
  58. $meeting['created_at'],
  59. $meeting['status'] == 1 ? $plugin->get_lang('MeetingOpened') : $plugin->get_lang('MeetingClosed'),
  60. $meeting['record'] == 1 ? get_lang('Yes') : get_lang('No'),
  61. $meeting['course'] ? $meeting['course']->getTitle() : '-',
  62. $meeting['session'] ? $meeting['session']->getName() : '-',
  63. isset($meeting['participants']) ? implode(PHP_EOL, $meeting['participants']) : null
  64. ];
  65. }
  66. Export::arrayToXls($dataToExport);
  67. break;
  68. }
  69. }
  70. if (!empty($meetings)) {
  71. $meetings = array_reverse($meetings);
  72. }
  73. if (!$bbb->isServerRunning()) {
  74. Display::addFlash(
  75. Display::return_message(get_lang('ServerIsNotRunning'), 'error')
  76. );
  77. }
  78. $htmlHeadXtra[] = api_get_js_simple(
  79. api_get_path(WEB_PLUGIN_PATH).'bbb/resources/utils.js'
  80. );
  81. $htmlHeadXtra[] = "<script>var _p = {web_plugin: '".api_get_path(WEB_PLUGIN_PATH)."'}</script>";
  82. $tpl = new Template($tool_name);
  83. $tpl->assign('meetings', $meetings);
  84. $tpl->assign('search_form', $form->returnForm());
  85. $content = $tpl->fetch('bbb/admin.tpl');
  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. $tpl->assign(
  98. 'actions',
  99. Display::toolbarAction('toolbar', [$actions])
  100. );
  101. }
  102. $tpl->assign('header', $plugin->get_lang('RecordList'));
  103. $tpl->assign('content', $content);
  104. $tpl->display_one_col_template();