video.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once __DIR__.'/../../../global.inc.php';
  4. if (api_is_anonymous()) {
  5. api_not_allowed(true);
  6. }
  7. $roomId = isset($_GET['room']) ? $_GET['room'] : null;
  8. $entityManager = Database::getManager();
  9. $chatVideo = $entityManager->find('ChamiloCoreBundle:ChatVideo', $roomId);
  10. if (!$chatVideo) {
  11. header('Location: '.api_get_path(WEB_PATH));
  12. exit;
  13. }
  14. $friend_html = SocialManager::listMyFriendsBlock($user_id, '', false);
  15. $isSender = $chatVideo->getFromUser() === api_get_user_id();
  16. $isReceiver = $chatVideo->getToUser() === api_get_user_id();
  17. if (!$isSender && !$isReceiver) {
  18. header('Location: '.api_get_path(WEB_PATH));
  19. exit;
  20. }
  21. if ($isSender) {
  22. $chatUser = api_get_user_info($chatVideo->getToUser());
  23. } elseif ($isReceiver) {
  24. $chatUser = api_get_user_info($chatVideo->getFromUser());
  25. }
  26. $idUserLocal = api_get_user_id();
  27. $userLocal = api_get_user_info($idUserLocal, true);
  28. $htmlHeadXtra[] = '<script type="text/javascript" src="'
  29. . api_get_path(WEB_PATH) . 'web/assets/simpleWebRTC/latest-v2.js'
  30. . '"></script>' . "\n";
  31. $navigator = api_get_navigator();
  32. $template = new Template();
  33. $template->assign('room_name', $chatVideo->getRoomName());
  34. $template->assign('chat_user', $chatUser);
  35. $template->assign('user_local', $userLocal);
  36. $template->assign('block_friends', $friend_html);
  37. $template->assign('navigator_is_firefox', $navigator['name'] == 'Mozilla');
  38. $tpl = $template->get_template('chat/video.tpl');
  39. $content = $template->fetch($tpl);
  40. $templateHeader = Display::returnFontAwesomeIcon('video-camera', 'lg', true)
  41. . $chatVideo->getRoomName();
  42. $template->assign('header', $templateHeader);
  43. $template->assign('content', $content);
  44. $template->assign(
  45. 'message',
  46. Display::return_message(get_lang('YourBroswerDoesNotSupportWebRTC'), 'warning')
  47. );
  48. $template->display_one_col_template();