listing.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /**
  3. * This script initiates a video conference session, calling the BigBlueButton API
  4. * @package chamilo.plugin.bigbluebutton
  5. */
  6. $course_plugin = 'bbb'; //needed in order to load the plugin lang variables
  7. require_once __DIR__.'/config.php';
  8. $plugin = BBBPlugin::create();
  9. $tool_name = $plugin->get_lang('Videoconference');
  10. $htmlHeadXtra[] = api_get_js_simple(
  11. api_get_path(WEB_PLUGIN_PATH) . 'bbb/resources/utils.js'
  12. );
  13. $htmlHeadXtra[] = "<script>var _p = {web_plugin: '" . api_get_path(WEB_PLUGIN_PATH). "'}</script>";
  14. $tpl = new Template($tool_name);
  15. $isGlobal = isset($_GET['global']) ? true : false;
  16. $bbb = new bbb('', '', $isGlobal);
  17. $action = isset($_GET['action']) ? $_GET['action'] : null;
  18. $conferenceManager = $bbb->isConferenceManager();
  19. if ($bbb->isGlobalConference()) {
  20. api_block_anonymous_users();
  21. } else {
  22. api_protect_course_script(true);
  23. }
  24. $message = null;
  25. if ($conferenceManager) {
  26. switch ($action) {
  27. case 'add_to_calendar':
  28. if ($bbb->isGlobalConference()) {
  29. return false;
  30. }
  31. $courseInfo = api_get_course_info();
  32. $agenda = new Agenda();
  33. $agenda->type = 'course';
  34. $id = intval($_GET['id']);
  35. $title = sprintf(get_lang('VideoConferenceXCourseX'), $id, $courseInfo['name']);
  36. $content = Display::url(get_lang('GoToTheVideoConference'), $_GET['url']);
  37. $eventId = $agenda->addEvent(
  38. $_REQUEST['start'],
  39. null,
  40. 'true',
  41. $title,
  42. $content,
  43. array('everyone')
  44. );
  45. if (!empty($eventId)) {
  46. $message = Display::return_message(get_lang('VideoConferenceAddedToTheCalendar'), 'success');
  47. } else {
  48. $message = Display::return_message(get_lang('Error'), 'error');
  49. }
  50. break;
  51. case 'copy_record_to_link_tool':
  52. $result = $bbb->copyRecordToLinkTool($_GET['id']);
  53. if ($result) {
  54. $message = Display::return_message(get_lang('VideoConferenceAddedToTheLinkTool'), 'success');
  55. } else {
  56. $message = Display::return_message(get_lang('Error'), 'error');
  57. }
  58. break;
  59. case 'delete_record':
  60. $bbb->deleteRecord($_GET['id']);
  61. if ($result) {
  62. $message = Display::return_message(get_lang('Deleted'), 'success');
  63. } else {
  64. $message = Display::return_message(get_lang('Error'), 'error');
  65. }
  66. break;
  67. case 'end':
  68. $bbb->endMeeting($_GET['id']);
  69. $message = Display::return_message(
  70. get_lang('MeetingClosed') . '<br />' . get_lang(
  71. 'MeetingClosedComment'
  72. ),
  73. 'success',
  74. false
  75. );
  76. if (file_exists(__DIR__ . '/config.vm.php')) {
  77. require __DIR__ . '/../../vendor/autoload.php';
  78. require __DIR__ . '/lib/vm/AbstractVM.php';
  79. require __DIR__ . '/lib/vm/VMInterface.php';
  80. require __DIR__ . '/lib/vm/DigitalOceanVM.php';
  81. require __DIR__ . '/lib/VM.php';
  82. $config = require __DIR__ . '/config.vm.php';
  83. $vm = new VM($config);
  84. $vm->resizeToMinLimit();
  85. }
  86. break;
  87. case 'publish':
  88. $result = $bbb->publishMeeting($_GET['id']);
  89. break;
  90. case 'unpublish':
  91. $result = $bbb->unpublishMeeting($_GET['id']);
  92. break;
  93. default:
  94. break;
  95. }
  96. }
  97. $meetings = $bbb->getMeetings(
  98. api_get_course_int_id(),
  99. api_get_session_id(),
  100. api_get_group_id()
  101. );
  102. if (!empty($meetings)) {
  103. $meetings = array_reverse($meetings);
  104. }
  105. $users_online = $bbb->getUsersOnlineInCurrentRoom();
  106. $status = $bbb->isServerRunning();
  107. $meetingExists = $bbb->meetingExists($bbb->getCurrentVideoConferenceName());
  108. $showJoinButton = false;
  109. if ($meetingExists || $conferenceManager) {
  110. $showJoinButton = true;
  111. }
  112. $tpl->assign('allow_to_edit', $conferenceManager);
  113. $tpl->assign('meetings', $meetings);
  114. $conferenceUrl = $bbb->getConferenceUrl();
  115. $tpl->assign('conference_url', $conferenceUrl);
  116. $tpl->assign('users_online', $users_online);
  117. $tpl->assign('bbb_status', $status);
  118. $tpl->assign('show_join_button', $showJoinButton);
  119. $tpl->assign('message', $message);
  120. $listing_tpl = 'bbb/listing.tpl';
  121. $content = $tpl->fetch($listing_tpl);
  122. if (api_is_platform_admin()) {
  123. $actionLinks = [
  124. Display::toolbarButton(
  125. $plugin->get_lang('AdminView'),
  126. api_get_path(WEB_PLUGIN_PATH) . 'bbb/admin.php',
  127. 'list',
  128. 'primary'
  129. )
  130. ];
  131. $tpl->assign('actions', implode(PHP_EOL, $actionLinks));
  132. }
  133. $tpl->assign('content', $content);
  134. $tpl->display_one_col_template();