start.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 dirname(__FILE__).'/config.php';
  9. $tool_name = get_lang('Videoconference');
  10. $tpl = new Template($tool_name);
  11. $vmIsEnabled = false;
  12. $host = null;
  13. $salt = null;
  14. $bbb = new bbb();
  15. if ($bbb->plugin_enabled) {
  16. if ($bbb->isServerRunning()) {
  17. if (isset($_GET['launch']) && $_GET['launch'] == 1) {
  18. if (file_exists(__DIR__ . '/config.vm.php')) {
  19. $config = require __DIR__ . '/config.vm.php';
  20. $vmIsEnabled = true;
  21. $host = null;
  22. $salt = null;
  23. require __DIR__ . '/lib/vm/AbstractVM.php';
  24. require __DIR__ . '/lib/vm/VMInterface.php';
  25. require __DIR__ . '/lib/vm/DigitalOceanVM.php';
  26. require __DIR__ . '/lib/VM.php';
  27. $vm = new VM($config);
  28. if ($vm->IsEnabled()) {
  29. try {
  30. $vm->resizeToMaxLimit();
  31. } catch (\Exception $e) {
  32. echo $e->getMessage();
  33. exit;
  34. }
  35. }
  36. }
  37. $meeting_params = array();
  38. $meeting_params['meeting_name'] = api_get_course_id().'-'.api_get_session_id();
  39. if ($bbb->meetingExists($meeting_params['meeting_name'])) {
  40. $url = $bbb->joinMeeting($meeting_params['meeting_name']);
  41. if ($url) {
  42. $bbb->redirectToBBB($url);
  43. } else {
  44. $url = $bbb->createMeeting($meeting_params);
  45. $bbb->redirectToBBB($url);
  46. }
  47. } else {
  48. if ($bbb->isTeacher()) {
  49. $url = $bbb->createMeeting($meeting_params);
  50. $bbb->redirectToBBB($url);
  51. } else {
  52. $url = 'listing.php?'.api_get_cidreq();
  53. $bbb->redirectToBBB($url);
  54. }
  55. }
  56. } else {
  57. $url = 'listing.php?'.api_get_cidreq();
  58. header('Location: ' . $url);
  59. exit;
  60. }
  61. } else {
  62. $message = Display::return_message(get_lang('ServerIsNotRunning'), 'warning');
  63. }
  64. } else {
  65. $message = Display::return_message(get_lang('ServerIsNotConfigured'), 'warning');
  66. }
  67. $tpl->assign('message', $message);
  68. $tpl->display_one_col_template();