admin.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. $form = new FormValidator(get_lang('Search'));
  16. $form->addDatePicker('search_meeting', get_lang('Date'));
  17. $form->addButtonSearch(get_lang('Search'));
  18. $actions = [];
  19. if ($form->validate()) {
  20. $date = $form->getSubmitValue('search_meeting');
  21. $meetings = $bbb->getMeetings(0, 0, 0, true, $date);
  22. $actions[] = Display::toolbarButton(
  23. $plugin->get_lang('ReturnToFullList'),
  24. api_get_self(),
  25. 'list',
  26. 'primary'
  27. );
  28. } else {
  29. $meetings = $bbb->getMeetings(0, 0, 0, true);
  30. }
  31. foreach ($meetings as &$meeting) {
  32. $participants = $bbb->findMeetingParticipants($meeting['id']);
  33. foreach ($participants as $meetingParticipant) {
  34. /** @var User $participant */
  35. $participant = $meetingParticipant['participant'];
  36. $meeting['participants'][] = $participant->getCompleteName()
  37. . ' (' . $participant->getEmail() . ')';
  38. }
  39. }
  40. if ($action) {
  41. switch ($action) {
  42. case 'export':
  43. $dataToExport = [
  44. [$tool_name, $plugin->get_lang('RecordList')],
  45. [],
  46. [
  47. get_lang('CreatedAt'),
  48. get_lang('Status'),
  49. $plugin->get_lang('Records'),
  50. get_lang('Course'),
  51. get_lang('Session'),
  52. get_lang('Participants'),
  53. ]
  54. ];
  55. foreach ($meetings as $meeting) {
  56. $dataToExport[] = [
  57. $meeting['created_at'],
  58. $meeting['status'] == 1 ? $plugin->get_lang('MeetingOpened') : $plugin->get_lang('MeetingClosed'),
  59. $meeting['record'] == 1 ? get_lang('Yes') : get_lang('No'),
  60. $meeting['course'] ? $meeting['course']->getTitle() : '-',
  61. $meeting['session'] ? $meeting['session']->getName() : '-',
  62. isset($meeting['participants']) ? implode(PHP_EOL, $meeting['participants']) : null
  63. ];
  64. }
  65. Export::arrayToXls($dataToExport);
  66. break;
  67. }
  68. }
  69. if (!empty($meetings)) {
  70. $meetings = array_reverse($meetings);
  71. }
  72. if (!$bbb->isServerRunning()) {
  73. Display::addFlash(
  74. Display::return_message(get_lang('ServerIsNotRunning'), 'error')
  75. );
  76. }
  77. $htmlHeadXtra[] = api_get_js_simple(
  78. api_get_path(WEB_PLUGIN_PATH) . 'bbb/resources/utils.js'
  79. );
  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('bbb/admin.tpl');
  85. if ($meetings) {
  86. $actions[] = Display::toolbarButton(
  87. get_lang('ExportInExcel'),
  88. api_get_self() . '?action=export',
  89. 'file-excel-o',
  90. 'success'
  91. );
  92. }
  93. $tpl->assign('header', $plugin->get_lang('RecordList'));
  94. $tpl->assign('actions', implode('', $actions));
  95. $tpl->assign('content', $content);
  96. $tpl->display_one_col_template();