video.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_PUBLIC_PATH).'assets/simpleWebRTC/latest-v2.js'
  30. . '"></script>' . "\n";
  31. $navigator = api_get_navigator();
  32. Display::addFlash(
  33. Display::return_message(get_lang('FeatureDisabledBecauseOfUnmaintainedThirdPartyLibraries'), 'error')
  34. );
  35. $template = new Template();
  36. $template->assign('room_name', $chatVideo->getRoomName());
  37. $template->assign('chat_user', $chatUser);
  38. $template->assign('user_local', $userLocal);
  39. $template->assign('block_friends', $friend_html);
  40. $template->assign('navigator_is_firefox', $navigator['name'] == 'Mozilla');
  41. $tpl = $template->get_template('chat/video.tpl');
  42. $content = $template->fetch($tpl);
  43. $templateHeader = Display::returnFontAwesomeIcon('video-camera', 'lg', true)
  44. . $chatVideo->getRoomName();
  45. $template->assign('header', $templateHeader);
  46. $template->assign('content', $content);
  47. $template->assign(
  48. 'message',
  49. Display::return_message(get_lang('YourBroswerDoesNotSupportWebRTC'), 'warning')
  50. );
  51. $template->display_one_col_template();