start.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. $isGlobalPerUser = isset($_GET['user_id']) ? (int) $_GET['user_id'] : false;
  16. $bbb = new bbb('', '', $isGlobal, $isGlobalPerUser);
  17. if ($bbb->pluginEnabled) {
  18. if ($bbb->isServerRunning()) {
  19. if (isset($_GET['launch']) && $_GET['launch'] == 1) {
  20. if (file_exists(__DIR__.'/config.vm.php')) {
  21. $config = require __DIR__.'/config.vm.php';
  22. $vmIsEnabled = true;
  23. $host = '';
  24. $salt = '';
  25. require __DIR__.'/lib/vm/AbstractVM.php';
  26. require __DIR__.'/lib/vm/VMInterface.php';
  27. require __DIR__.'/lib/vm/DigitalOceanVM.php';
  28. require __DIR__.'/lib/VM.php';
  29. $vm = new VM($config);
  30. if ($vm->isEnabled()) {
  31. try {
  32. $vm->resizeToMaxLimit();
  33. } catch (\Exception $e) {
  34. echo $e->getMessage();
  35. exit;
  36. }
  37. }
  38. }
  39. $meetingParams = array();
  40. $meetingParams['meeting_name'] = $bbb->getCurrentVideoConferenceName();
  41. if ($bbb->meetingExists($meetingParams['meeting_name'])) {
  42. $url = $bbb->joinMeeting($meetingParams['meeting_name']) ?: $bbb->createMeeting($meetingParams);
  43. } else {
  44. $url = $bbb->isConferenceManager() ? $bbb->createMeeting($meetingParams) : $bbb->getListingUrl();
  45. }
  46. $meetingInfo = $bbb->findMeetingByName($meetingParams['meeting_name']);
  47. $bbb->saveParticipant($meetingInfo['id'], api_get_user_id());
  48. $bbb->redirectToBBB($url);
  49. } else {
  50. $url = $bbb->getListingUrl();
  51. header('Location: '.$url);
  52. exit;
  53. }
  54. } else {
  55. $message = Display::return_message(get_lang('ServerIsNotRunning'), 'warning');
  56. }
  57. } else {
  58. $message = Display::return_message(get_lang('ServerIsNotConfigured'), 'warning');
  59. }
  60. $tpl->assign('message', $message);
  61. $tpl->display_one_col_template();