start.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * This script initiates a video conference session, calling the BigBlueButton API
  4. * @package chamilo.plugin.bigbluebutton
  5. */
  6. require __DIR__ . '/../../vendor/autoload.php';
  7. $course_plugin = 'bbb'; //needed in order to load the plugin lang variables
  8. require_once __DIR__.'/config.php';
  9. $tool_name = get_lang('Videoconference');
  10. $tpl = new Template($tool_name);
  11. $vmIsEnabled = false;
  12. $host = '';
  13. $salt = '';
  14. $isGlobal = isset($_GET['global']) ? true : false;
  15. $bbb = new bbb('', '', $isGlobal);
  16. if ($bbb->pluginEnabled) {
  17. if ($bbb->isServerRunning()) {
  18. if (isset($_GET['launch']) && $_GET['launch'] == 1) {
  19. if (file_exists(__DIR__ . '/config.vm.php')) {
  20. $config = require __DIR__ . '/config.vm.php';
  21. $vmIsEnabled = true;
  22. $host = '';
  23. $salt = '';
  24. require __DIR__ . '/lib/vm/AbstractVM.php';
  25. require __DIR__ . '/lib/vm/VMInterface.php';
  26. require __DIR__ . '/lib/vm/DigitalOceanVM.php';
  27. require __DIR__ . '/lib/VM.php';
  28. $vm = new VM($config);
  29. if ($vm->isEnabled()) {
  30. try {
  31. $vm->resizeToMaxLimit();
  32. } catch (\Exception $e) {
  33. echo $e->getMessage();
  34. exit;
  35. }
  36. }
  37. }
  38. $meetingParams = array();
  39. $meetingParams['meeting_name'] = $bbb->getCurrentVideoConferenceName();
  40. if ($bbb->meetingExists($meetingParams['meeting_name'])) {
  41. $url = $bbb->joinMeeting($meetingParams['meeting_name']) ?: $bbb->createMeeting($meetingParams);
  42. } else {
  43. $url = $bbb->isConferenceManager() ? $bbb->createMeeting($meetingParams) : $bbb->getListingUrl();
  44. }
  45. $meetingInfo = $bbb->findMeetingByName($meetingParams['meeting_name']);
  46. $bbb->saveParticipant($meetingInfo['id'], api_get_user_id());
  47. $bbb->redirectToBBB($url);
  48. } else {
  49. $url = $bbb->getListingUrl();
  50. header('Location: ' . $url);
  51. exit;
  52. }
  53. } else {
  54. $message = Display::return_message(get_lang('ServerIsNotRunning'), 'warning');
  55. }
  56. } else {
  57. $message = Display::return_message(get_lang('ServerIsNotConfigured'), 'warning');
  58. }
  59. $tpl->assign('message', $message);
  60. $tpl->display_one_col_template();