start.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. ];
  14. Event::registerLog($logInfo);
  15. $tool_name = get_lang('Videoconference');
  16. $tpl = new Template($tool_name);
  17. $vmIsEnabled = false;
  18. $host = '';
  19. $salt = '';
  20. $isGlobal = isset($_GET['global']) ? true : false;
  21. $isGlobalPerUser = isset($_GET['user_id']) ? (int) $_GET['user_id'] : false;
  22. $interface = isset($_GET['interface']) ? (int) $_GET['interface'] : 0;
  23. $bbb = new bbb('', '', $isGlobal, $isGlobalPerUser);
  24. $conferenceManager = $bbb->isConferenceManager();
  25. if ($bbb->isGlobalConference()) {
  26. api_block_anonymous_users();
  27. } else {
  28. api_protect_course_script(true);
  29. }
  30. if ($bbb->pluginEnabled) {
  31. if ($bbb->isServerRunning()) {
  32. if (isset($_GET['launch']) && $_GET['launch'] == 1) {
  33. if (file_exists(__DIR__.'/config.vm.php')) {
  34. $config = require __DIR__.'/config.vm.php';
  35. $vmIsEnabled = true;
  36. $host = '';
  37. $salt = '';
  38. require __DIR__.'/lib/vm/AbstractVM.php';
  39. require __DIR__.'/lib/vm/VMInterface.php';
  40. require __DIR__.'/lib/vm/DigitalOceanVM.php';
  41. require __DIR__.'/lib/VM.php';
  42. $vm = new VM($config);
  43. if ($vm->isEnabled()) {
  44. try {
  45. $vm->resizeToMaxLimit();
  46. } catch (\Exception $e) {
  47. echo $e->getMessage();
  48. exit;
  49. }
  50. }
  51. }
  52. $meetingParams = [];
  53. $meetingParams['meeting_name'] = $bbb->getCurrentVideoConferenceName();
  54. $meetingParams['interface'] = $interface;
  55. if ($bbb->meetingExists($meetingParams['meeting_name'])) {
  56. $joinUrl = $bbb->joinMeeting($meetingParams['meeting_name']);
  57. if ($joinUrl) {
  58. $url = $joinUrl;
  59. } else {
  60. $url = $bbb->createMeeting($meetingParams);
  61. }
  62. } else {
  63. $url = $bbb->isConferenceManager() ? $bbb->createMeeting($meetingParams) : $bbb->getListingUrl();
  64. }
  65. $meetingInfo = $bbb->findMeetingByName($meetingParams['meeting_name']);
  66. if (!empty($meetingInfo) && $url) {
  67. $bbb->saveParticipant($meetingInfo['id'], api_get_user_id(), $interface);
  68. $bbb->redirectToBBB($url);
  69. } else {
  70. $url = $bbb->getListingUrl();
  71. header('Location: '.$url);
  72. exit;
  73. }
  74. } else {
  75. $url = $bbb->getListingUrl();
  76. header('Location: '.$url);
  77. exit;
  78. }
  79. } else {
  80. $message = Display::return_message(get_lang('ServerIsNotRunning'), 'warning');
  81. }
  82. } else {
  83. $message = Display::return_message(get_lang('ServerIsNotConfigured'), 'warning');
  84. }
  85. $tpl->assign('message', $message);
  86. $tpl->display_one_col_template();