admin.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /* For license terms, see /license.txt */
  3. use Chamilo\UserBundle\Entity\User;
  4. /**
  5. * This script initiates a video conference session, calling the BigBlueButton API.
  6. *
  7. * @package chamilo.plugin.bigbluebutton
  8. */
  9. $course_plugin = 'bbb'; //needed in order to load the plugin lang variables
  10. $cidReset = true;
  11. require_once __DIR__.'/../../main/inc/global.inc.php';
  12. api_protect_admin_script();
  13. $plugin = BBBPlugin::create();
  14. $tool_name = $plugin->get_lang('Videoconference');
  15. $isGlobal = isset($_GET['global']) ? true : false;
  16. $bbb = new bbb('', '', $isGlobal);
  17. $action = isset($_GET['action']) ? $_GET['action'] : null;
  18. $currentMonth = date('n');
  19. $dateStart = isset($_REQUEST['search_meeting_start']) ? $_REQUEST['search_meeting_start'] : date('Y-m-d', mktime(1, 1, 1, $currentMonth, 1, date('Y')));
  20. $dateEnd = isset($_REQUEST['search_meeting_end']) ? $_REQUEST['search_meeting_end'] : date('Y-m-d', mktime(1, 1, 1, ++$currentMonth, 0, date('Y')));
  21. $dateRange = [
  22. 'search_meeting_start' => $dateStart,
  23. 'search_meeting_end' => $dateEnd,
  24. ];
  25. $form = new FormValidator(get_lang('Search'));
  26. $form->addDatePicker('search_meeting_start', get_lang('Start date'));
  27. $form->addDatePicker('search_meeting_end', get_lang('End date'));
  28. $form->addButtonSearch(get_lang('Search'));
  29. $form->setDefaults($dateRange);
  30. if ($form->validate()) {
  31. $dateRange = $form->getSubmitValues();
  32. }
  33. $meetings = $bbb->getMeetings(0, 0, 0, true, $dateRange);
  34. foreach ($meetings as &$meeting) {
  35. $participants = $bbb->findConnectedMeetingMembers($meeting['id']);
  36. foreach ($participants as $meetingParticipant) {
  37. /** @var User $participant */
  38. $participant = $meetingParticipant['participant'];
  39. $meeting['participants'][] = $participant->getCompleteName().' ('.$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('Created at'),
  50. get_lang('Status'),
  51. $plugin->get_lang('Records'),
  52. get_lang('Course'),
  53. get_lang('Session'),
  54. get_lang('Members'),
  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_simple(
  80. api_get_path(WEB_PLUGIN_PATH).'bbb/resources/utils.js'
  81. );
  82. $htmlHeadXtra[] = "<script>var _p = {web_plugin: '".api_get_path(WEB_PLUGIN_PATH)."'}</script>";
  83. $tpl = new Template($tool_name);
  84. $tpl->assign('meetings', $meetings);
  85. $tpl->assign('search_form', $form->returnForm());
  86. $content = $tpl->fetch('bbb/view/admin.tpl');
  87. if ($meetings) {
  88. $actions = Display::toolbarButton(
  89. get_lang('Export in Excel format'),
  90. api_get_self().'?'.http_build_query([
  91. 'action' => 'export',
  92. 'search_meeting_start' => $dateStart,
  93. 'search_meeting_end' => $dateEnd,
  94. ]),
  95. 'file-excel-o',
  96. 'success'
  97. );
  98. $tpl->assign(
  99. 'actions',
  100. Display::toolbarAction('toolbar', [$actions])
  101. );
  102. }
  103. $tpl->assign('header', $plugin->get_lang('RecordList'));
  104. $tpl->assign('content', $content);
  105. $tpl->display_one_col_template();