listing.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 = 'openmeetings'; //needed in order to load the plugin lang variables
  10. require_once __DIR__.'/config.php';
  11. $plugin = \OpenMeetingsPlugin::create();
  12. $tool_name = $plugin->get_lang('Videoconference');
  13. $tpl = new Template($tool_name);
  14. $om = new Chamilo\Plugin\OpenMeetings\OpenMeetings();
  15. $action = isset($_GET['action']) ? $_GET['action'] : null;
  16. $teacher = $om->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('course');
  24. $id = intval($_GET['id']);
  25. $title = sprintf(get_lang('VideoConferenceXCourseX'), $id, $course_info['name']);
  26. $content = Display::url(get_lang('GoToTheVideoConference'), $_GET['url']);
  27. $event_id = $agenda->addEvent(
  28. $_REQUEST['start'],
  29. null,
  30. 'true',
  31. $title,
  32. $content,
  33. array('everyone')
  34. );
  35. if (!empty($event_id)) {
  36. $message = Display::return_message(get_lang('VideoConferenceAddedToTheCalendar'), 'success');
  37. } else {
  38. $message = Display::return_message(get_lang('Error'), 'error');
  39. }
  40. break;
  41. case 'copy_record_to_link_tool':
  42. $result = $om->copy_record_to_link_tool($_GET['id'], $_GET['record_id']);
  43. if ($result) {
  44. $message = Display::return_message(get_lang('VideoConferenceAddedToTheLinkTool'), 'success');
  45. } else {
  46. $message = Display::return_message(get_lang('Error'), 'error');
  47. }
  48. break;
  49. case 'delete_record':
  50. /*$result = $om->delete_record($_GET['id']);
  51. if ($result) {
  52. $message = Display::return_message(get_lang('Deleted'), 'success');
  53. } else {
  54. $message = Display::return_message(get_lang('Error'), 'error');
  55. }*/
  56. break;
  57. case 'delete':
  58. $om->deleteMeeting($_GET['id']);
  59. unset($om);
  60. $message = Display::return_message(get_lang('MeetingDeleted').'<br />'.get_lang('MeetingDeletedComment'), 'success', false);
  61. header('Location: '.api_get_self());
  62. exit;
  63. break;
  64. case 'end':
  65. $om->endMeeting($_GET['id']);
  66. $message = Display::return_message(get_lang('MeetingClosed').'<br />'.get_lang('MeetingClosedComment'), 'success', false);
  67. break;
  68. case 'publish':
  69. // Not implemented yet
  70. //$result = $om->publish_meeting($_GET['id']);
  71. break;
  72. case 'unpublish':
  73. // Not implemented yet
  74. //$result = $om->unpublish_meeting($_GET['id']);
  75. break;
  76. default:
  77. break;
  78. }
  79. }
  80. $meetings = $om->getCourseMeetings();
  81. $openMeeting = false;
  82. $users_online = 0;
  83. if (!empty($meetings)) {
  84. $meetings = array_reverse($meetings);
  85. foreach ($meetings as $meeting) {
  86. if ($meeting['status'] == 1) {
  87. $openMeeting = true;
  88. }
  89. }
  90. $users_online = $meetings->participantCount;
  91. }
  92. $status = $om->isServerRunning();
  93. $show_join_button = false;
  94. if ($openMeeting || $teacher) {
  95. $show_join_button = true;
  96. }
  97. $tpl->assign('allow_to_edit', $teacher);
  98. $tpl->assign('meetings', $meetings);
  99. $conference_url = api_get_path(WEB_PLUGIN_PATH).'openmeetings/start.php?launch=1&'.api_get_cidreq();
  100. $tpl->assign('conference_url', $conference_url);
  101. $tpl->assign('users_online', $users_online);
  102. $tpl->assign('openmeetings_status', $status);
  103. $tpl->assign('show_join_button', $show_join_button);
  104. $tpl->assign('message', $message);
  105. $listing_tpl = 'openmeetings/listing.tpl';
  106. $content = $tpl->fetch($listing_tpl);
  107. $tpl->assign('content', $content);
  108. $tpl->display_one_col_template();