start.php 3.4 KB

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