start.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * This script initiates a video conference session
  4. */
  5. /**
  6. * Initialization
  7. */
  8. $course_plugin = 'openmeetings'; //needed in order to load the plugin lang variables
  9. require_once dirname(__FILE__).'/config.php';
  10. $tool_name = get_lang('Videoconference');
  11. $tpl = new Template($tool_name);
  12. $om = new \Chamilo\Plugin\OpenMeetings\OpenMeetings();
  13. if ($om->isServerRunning()) {
  14. if (isset($_GET['launch']) && $_GET['launch'] == 1) {
  15. $meeting_params = array();
  16. $meeting_params['meeting_name'] = 'C'.api_get_course_id().'-'.api_get_session_id();
  17. $meetings = $om->getCourseMeetings();
  18. $selectedMeeting = array();
  19. /*
  20. // Select the meeting with more participantCount.
  21. if (!empty($meetings)) {
  22. $max = 0;
  23. foreach ($meetings as $meeting) {
  24. if ($meeting['participantCount'] > $max) {
  25. $selectedMeeting = $meeting;
  26. $max = $meeting['participantCount'];
  27. }
  28. }
  29. }
  30. */
  31. // Check for the first meeting available with status = 1
  32. // (there should be only one at a time, as createMeeting checks for that first
  33. if (!empty($meetings)) {
  34. foreach ($meetings as $meeting) {
  35. if ($meeting['status'] == 1) {
  36. $selectedMeeting = $meeting;
  37. }
  38. }
  39. }
  40. if (!empty($selectedMeeting)) {
  41. $url = $om->joinMeeting($selectedMeeting['id']);
  42. if ($url) {
  43. header('location: '.$url);
  44. exit;
  45. }
  46. } else {
  47. if ($om->isTeacher()) {
  48. $om->createMeeting($meeting_params);
  49. exit;
  50. } else {
  51. $url = 'listing.php';
  52. header('location: '.$url);
  53. exit;
  54. }
  55. }
  56. } else {
  57. $url = 'listing.php';
  58. header('location: '.$url);
  59. exit;
  60. }
  61. } else {
  62. $message = Display::return_message(get_lang('ServerIsNotRunning'), 'warning');
  63. }
  64. $tpl->assign('message', $message);
  65. $tpl->display_one_col_template();