end.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * This script closes a videoconference session, calling the BigBlueButton API
  4. */
  5. require_once '../../main/inc/global.inc.php';
  6. require_once 'bbb.lib.php';
  7. //The script receives the course_code (cidReq), which allows it to get the corresponding data
  8. $cid = api_get_real_course_id();
  9. $ccode = api_get_course_id();
  10. // initialize conference settings from course settings
  11. $meeting_name = api_get_course_setting('big_blue_button_meeting_name',$ccode);
  12. if (empty($meeting_name) or $meeting_name==-1) { $meeting_name = $ccode; }
  13. $meeting_att_pw = api_get_course_setting('big_blue_button_meeting_attendee_pw',$ccode);
  14. if (empty($meeting_att_pw) or $meeting_att_pw==-1) { $meeting_att_pw = $ccode; }
  15. $meeting_mod_pw = api_get_course_setting('big_blue_button_meeting_moderator_pw',$ccode);
  16. if (empty($meeting_mod_pw) or $meeting_mod_pw==-1) { $meeting_mod_pw = $ccode.'mod'; }
  17. $meeting_wel_ms = api_get_course_setting('big_blue_button_meeting_welcome_message',$ccode);
  18. if (empty($meeting_wel_ms) or $meeting_wel_ms==-1) { $meeting_wel_ms = ''; }
  19. // initialize video server settings from global settings
  20. $settings = api_get_settings('Extra','list',api_get_current_access_url_id());
  21. $bbb_settings = array();
  22. foreach ($settings as $setting) {
  23. if (substr($setting['variable'],0,4)==='bbb_') {
  24. $bbb_settings[$setting['variable']] = $setting['selected_value'];
  25. }
  26. }
  27. $bbb_plugin = $bbb_settings['bbb_plugin'] === 'true';
  28. $bbb_host = $bbb_settings['bbb_plugin_host'];
  29. $bbb_salt = $bbb_settings['bbb_plugin_salt'];
  30. if (!$bbb_plugin) {
  31. //the BigBlueButton plugin is not enabled (strangely), return to course homepage
  32. header('location: '.api_get_path(WEB_COURSE_PATH).'/'.$ccode);
  33. }
  34. $teacher = api_is_course_admin() || api_is_coach();
  35. $user_info = api_get_user_info();
  36. $full_user_name = api_get_person_name($user_info['firstname'],$user_info['lastname']);
  37. $is_running = wc_isMeetingRunning($bbb_host,$bbb_salt,$meeting_name);
  38. if ($is_running == 'true' && $teacher) {
  39. wc_endMeeting($bbb_host,$bbb_salt,$meeting_name,$meeting_mod_pw);
  40. } else { //$is_running = false or 'false'
  41. header('location: '.api_get_path(WEB_COURSE_PATH).'/'.$ccode);
  42. }