listing.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * This script initiates a videoconference session, calling the BigBlueButton API
  4. * @package chamilo.plugin.bigbluebutton
  5. */
  6. /**
  7. * Initialization
  8. */
  9. $course_plugin = 'bbb'; //needed in order to load the plugin lang variables
  10. require_once dirname(__FILE__).'/config.php';
  11. $plugin = BBBPlugin::create();
  12. $tool_name = $plugin->get_lang('Videoconference');
  13. $tpl = new Template($tool_name);
  14. $bbb = new bbb();
  15. $action = isset($_GET['action']) ? $_GET['action'] : null;
  16. $teacher = $bbb->isTeacher();
  17. api_protect_course_script(true);
  18. $message = null;
  19. if ($teacher) {
  20. switch ($action) {
  21. case 'add_to_calendar':
  22. $course_info = api_get_course_info();
  23. $agenda = new Agenda();
  24. $agenda->type = 'course';
  25. $id = intval($_GET['id']);
  26. $title = sprintf(get_lang('VideoConferenceXCourseX'), $id, $course_info['name']);
  27. $content = Display::url(get_lang('GoToTheVideoConference'), $_GET['url']);
  28. $event_id = $agenda->add_event(
  29. $_REQUEST['start'],
  30. null,
  31. 'true',
  32. $title,
  33. $content,
  34. array('everyone')
  35. );
  36. if (!empty($event_id)) {
  37. $message = Display::return_message(get_lang('VideoConferenceAddedToTheCalendar'), 'success');
  38. } else {
  39. $message = Display::return_message(get_lang('Error'), 'error');
  40. }
  41. break;
  42. case 'copy_record_to_link_tool':
  43. $result = $bbb->copyRecordToLinkTool($_GET['id']);
  44. if ($result) {
  45. $message = Display::return_message(get_lang('VideoConferenceAddedToTheLinkTool'), 'success');
  46. } else {
  47. $message = Display::return_message(get_lang('Error'), 'error');
  48. }
  49. break;
  50. case 'delete_record':
  51. $bbb->deleteRecord($_GET['id']);
  52. if ($result) {
  53. $message = Display::return_message(get_lang('Deleted'), 'success');
  54. } else {
  55. $message = Display::return_message(get_lang('Error'), 'error');
  56. }
  57. break;
  58. case 'end':
  59. $bbb->endMeeting($_GET['id']);
  60. $message = Display::return_message(
  61. get_lang('MeetingClosed') . '<br />' . get_lang(
  62. 'MeetingClosedComment'
  63. ),
  64. 'success',
  65. false
  66. );
  67. if (file_exists(__DIR__ . '/config.vm.php')) {
  68. require __DIR__ . '/../../vendor/autoload.php';
  69. require __DIR__ . '/lib/vm/AbstractVM.php';
  70. require __DIR__ . '/lib/vm/VMInterface.php';
  71. require __DIR__ . '/lib/vm/DigitalOceanVM.php';
  72. require __DIR__ . '/lib/VM.php';
  73. $config = require __DIR__ . '/config.vm.php';
  74. $vm = new VM($config);
  75. $vm->resizeToMinLimit();
  76. }
  77. break;
  78. case 'publish':
  79. $result = $bbb->publishMeeting($_GET['id']);
  80. break;
  81. case 'unpublish':
  82. $result = $bbb->unpublishMeeting($_GET['id']);
  83. break;
  84. default:
  85. break;
  86. }
  87. }
  88. $meetings = $bbb->getCourseMeetings();
  89. if (!empty($meetings)) {
  90. $meetings = array_reverse($meetings);
  91. }
  92. $users_online = $bbb->getUsersOnlineInCurrentRoom();
  93. $status = $bbb->isServerRunning();
  94. $meeting_exists = $bbb->meetingExists(api_get_course_id().'-'.api_get_session_id());
  95. $show_join_button = false;
  96. if ($meeting_exists || $teacher) {
  97. $show_join_button = true;
  98. }
  99. $tpl->assign('allow_to_edit', $teacher);
  100. $tpl->assign('meetings', $meetings);
  101. $conferenceUrl = api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?launch=1&'.api_get_cidreq();
  102. $tpl->assign('conference_url', $conferenceUrl);
  103. $tpl->assign('users_online', $users_online);
  104. $tpl->assign('bbb_status', $status);
  105. $tpl->assign('show_join_button', $show_join_button);
  106. //$tpl->assign('actions', $actions);
  107. $tpl->assign('message', $message);
  108. $listing_tpl = 'bbb/listing.tpl';
  109. $content = $tpl->fetch($listing_tpl);
  110. $tpl->assign('content', $content);$tpl->display_one_col_template();