listing.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 dirname(__FILE__).'/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();
  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->addEvent(
  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 = $om->copy_record_to_link_tool($_GET['id'], $_GET['record_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. /*$result = $om->delete_record($_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 'delete':
  59. $om->deleteMeeting($_GET['id']);
  60. unset($om);
  61. $message = Display::return_message(get_lang('MeetingDeleted').'<br />'.get_lang('MeetingDeletedComment'), 'success', false);
  62. header('Location: '.api_get_self());
  63. exit;
  64. break;
  65. case 'end':
  66. $om->endMeeting($_GET['id']);
  67. $message = Display::return_message(get_lang('MeetingClosed').'<br />'.get_lang('MeetingClosedComment'), 'success', false);
  68. break;
  69. case 'publish':
  70. // Not implemented yet
  71. //$result = $om->publish_meeting($_GET['id']);
  72. break;
  73. case 'unpublish':
  74. // Not implemented yet
  75. //$result = $om->unpublish_meeting($_GET['id']);
  76. break;
  77. default:
  78. break;
  79. }
  80. }
  81. $meetings = $om->getCourseMeetings();
  82. $openMeeting = false;
  83. $users_online = 0;
  84. if (!empty($meetings)) {
  85. $meetings = array_reverse($meetings);
  86. foreach ($meetings as $meeting) {
  87. if ($meeting['status'] == 1) {
  88. $openMeeting = true;
  89. }
  90. }
  91. $users_online = $meetings->participantCount;
  92. }
  93. $status = $om->isServerRunning();
  94. $show_join_button = false;
  95. if ($openMeeting || $teacher) {
  96. $show_join_button = true;
  97. }
  98. $tpl->assign('allow_to_edit', $teacher);
  99. $tpl->assign('meetings', $meetings);
  100. $conference_url = api_get_path(WEB_PLUGIN_PATH).'openmeetings/start.php?launch=1&'.api_get_cidreq();
  101. $tpl->assign('conference_url', $conference_url);
  102. $tpl->assign('users_online', $users_online);
  103. $tpl->assign('openmeetings_status', $status);
  104. $tpl->assign('show_join_button', $show_join_button);
  105. $tpl->assign('message', $message);
  106. $listing_tpl = 'openmeetings/listing.tpl';
  107. $content = $tpl->fetch($listing_tpl);
  108. $tpl->assign('content', $content);
  109. $tpl->display_one_col_template();