start.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /* For license terms, see /license.txt */
  3. /**
  4. * This script initiates a video conference session, calling the BigBlueButton API.
  5. *
  6. * @package chamilo.plugin.bigbluebutton
  7. */
  8. require_once __DIR__.'/../../vendor/autoload.php';
  9. $course_plugin = 'bbb'; //needed in order to load the plugin lang variables
  10. require_once __DIR__.'/config.php';
  11. $logInfo = [
  12. 'tool' => 'Videoconference',
  13. 'tool_id' => 0,
  14. 'tool_id_detail' => 0,
  15. 'action' => '',
  16. 'action_details' => '',
  17. ];
  18. Event::registerLog($logInfo);
  19. $tool_name = get_lang('Videoconference');
  20. $tpl = new Template($tool_name);
  21. $vmIsEnabled = false;
  22. $host = '';
  23. $salt = '';
  24. $isGlobal = isset($_GET['global']) ? true : false;
  25. $isGlobalPerUser = isset($_GET['user_id']) ? (int) $_GET['user_id'] : false;
  26. $interface = isset($_GET['interface']) ? (int) $_GET['interface'] : 0;
  27. $bbb = new bbb('', '', $isGlobal, $isGlobalPerUser);
  28. $conferenceManager = $bbb->isConferenceManager();
  29. if ($bbb->isGlobalConference()) {
  30. api_block_anonymous_users();
  31. } else {
  32. api_protect_course_script(true);
  33. }
  34. if ($bbb->pluginEnabled) {
  35. if ($bbb->isServerRunning()) {
  36. if (isset($_GET['launch']) && $_GET['launch'] == 1) {
  37. if (file_exists(__DIR__.'/config.vm.php')) {
  38. $config = require __DIR__.'/config.vm.php';
  39. $vmIsEnabled = true;
  40. $host = '';
  41. $salt = '';
  42. require __DIR__.'/lib/vm/AbstractVM.php';
  43. require __DIR__.'/lib/vm/VMInterface.php';
  44. require __DIR__.'/lib/vm/DigitalOceanVM.php';
  45. require __DIR__.'/lib/VM.php';
  46. $vm = new VM($config);
  47. if ($vm->isEnabled()) {
  48. try {
  49. $vm->resizeToMaxLimit();
  50. } catch (\Exception $e) {
  51. echo $e->getMessage();
  52. exit;
  53. }
  54. }
  55. }
  56. $meetingParams = [];
  57. $meetingParams['meeting_name'] = $bbb->getCurrentVideoConferenceName();
  58. $meetingParams['interface'] = $interface;
  59. if ($bbb->meetingExists($meetingParams['meeting_name'])) {
  60. $joinUrl = $bbb->joinMeeting($meetingParams['meeting_name']);
  61. if ($joinUrl) {
  62. $url = $joinUrl;
  63. } else {
  64. $url = $bbb->createMeeting($meetingParams);
  65. }
  66. } else {
  67. $url = $bbb->isConferenceManager() ? $bbb->createMeeting($meetingParams) : $bbb->getListingUrl();
  68. }
  69. $meetingInfo = $bbb->findMeetingByName($meetingParams['meeting_name']);
  70. if (!empty($meetingInfo) && $url) {
  71. $bbb->saveParticipant($meetingInfo['id'], api_get_user_id(), $interface);
  72. $bbb->redirectToBBB($url);
  73. } else {
  74. $url = $bbb->getListingUrl();
  75. header('Location: '.$url);
  76. exit;
  77. }
  78. } else {
  79. $url = $bbb->getListingUrl();
  80. header('Location: '.$url);
  81. exit;
  82. }
  83. } else {
  84. $message = Display::return_message(get_lang('ServerIsNotRunning'), 'warning');
  85. }
  86. } else {
  87. $message = Display::return_message(get_lang('ServerIsNotConfigured'), 'warning');
  88. }
  89. $tpl->assign('message', $message);
  90. $tpl->display_one_col_template();