Example #1
0
 /**
  * Method to display video
  * @return void
  */
 public function video()
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $requestUser = CFactory::getRequestUser();
     $videoId = $jinput->get('videoid', '', 'INT');
     $task = $jinput->getCmd('task');
     // Get show video location map by default
     $videoMapsDefault = $config->get('videosmapdefault');
     // Load window library
     CWindow::load();
     $video = JTable::getInstance('Video', 'CTable');
     if (empty($videoId)) {
         if ($jinput->get('videoid', '', 'INT')) {
             $videoId = $jinput->get('videoid', '', 'INT');
         } else {
             $url = CRoute::_('index.php?option=com_community&view=videos', false);
             $mainframe->redirect($url, JText::_('COM_COMMUNITY_VIDEOS_ID_ERROR'), 'warning');
         }
     }
     if (!$video->load($videoId)) {
         $url = CRoute::_('index.php?option=com_community&view=videos', false);
         $mainframe->redirect($url, JText::_('COM_COMMUNITY_VIDEOS_NOT_AVAILABLE'), 'warning');
     }
     if ($video->groupid) {
         JRequest::setVar('groupid', $video->groupid);
     } elseif ($video->eventid) {
         JRequest::setVar('eventid', $video->eventid);
     }
     // Setting up the sub menu
     if (COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0) {
         $this->addSubmenuItem('', JText::_('COM_COMMUNITY_VIDEOS_FETCH_THUMBNAIL'), "joms.api.videoFetchThumbnail('" . $video->id . "');", true);
         // Only add the set as profile video for video owner
         if ($my->id == $video->creator && $config->get('enableprofilevideo')) {
             $this->addSubmenuItem('', JText::_('COM_COMMUNITY_VIDEOS_SET_AS_PROFILE'), "joms.api.videoLinkToProfile('" . $video->id . "');", true);
         }
         $redirectUrl = CRoute::getURI(false);
         $this->addSubmenuItem('', JText::_('COM_COMMUNITY_EDIT'), "joms.api.videoEdit('" . $video->id . "');", true);
         $this->addSubmenuItem('', JText::_('COM_COMMUNITY_DELETE'), "joms.api.videoRemove('" . $video->id . "');", true);
     }
     $this->_addSubmenu();
     // Show the mini header when viewing other's photos
     if ($video->creator_type == VIDEO_USER_TYPE && $my->id != $video->creator) {
         // $this->attachMiniHeaderUser($video->creator);
     }
     // Check permission
     $user = CFactory::getUser($video->creator);
     $blocked = $user->isBlocked();
     if ($blocked && !COwnerHelper::isCommunityAdmin()) {
         $tmpl = new CTemplate();
         echo $tmpl->fetch('profile.blocked');
         return;
     }
     $sorted = $jinput->get('sort', 'latest', 'STRING');
     $limit = $jinput->get('limitstart', 6, 'INT');
     $permissions = $my->id == 0 ? 0 : 20;
     $cat_id = $jinput->get('cat_id', '', 'INT');
     $model = CFactory::getModel('videos');
     /* We get groupid from video table instead user input */
     $groupId = $video->groupid;
     if ($video->creator_type == VIDEO_GROUP_TYPE) {
         if (!CGroupHelper::allowViewMedia($groupId)) {
             /**
              * Opengraph
              */
             CHeadHelper::setType('website', JText::_('COM_COMMUNITY_RESTRICTED_ACCESS'));
             $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS', 'notice'));
             echo JText::_('COM_COMMUNITY_GROUPS_VIDEO_MEMBER_PERMISSION');
             return;
         }
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         // Set pathway
         $pathway = $mainframe->getPathway();
         $pathway->addItem(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
         $pathway->addItem($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId));
         $pathway->addItem(JText::_('COM_COMMUNITY_VIDEOS'), CRoute::_('index.php?option=com_community&view=videos&task=display&groupid=' . $groupId));
         $pathway->addItem($video->getTitle(), '');
         $otherVideos = $model->getGroupVideos($groupId, $cat_id, $limit);
     } else {
         if (!$this->isPermitted($my->id, $video->creator, $video->permissions)) {
             /**
              * Opengraph
              */
             CHeadHelper::setType('website', JText::_('COM_COMMUNITY_RESTRICTED_ACCESS'));
             $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS', 'notice'));
             switch ($video->permissions) {
                 case '40':
                     $this->noAccess(JText::_('COM_COMMUNITY_VIDEOS_OWNER_ONLY', 'notice'));
                     break;
                 case '30':
                     $owner = CFactory::getUser($video->creator);
                     $this->noAccess(JText::sprintf('COM_COMMUNITY_VIDEOS_FRIEND_PERMISSION_MESSAGE', $owner->getDisplayName()));
                     break;
                 default:
                     $this->noAccess();
                     break;
             }
             return;
         }
         // Set pathway
         $pathway = $mainframe->getPathway();
         $pathway->addItem('Video', CRoute::_('index.php?option=com_community&view=videos'));
         $pathway->addItem($video->getTitle(), '');
         $filters = array('status' => 'ready', 'category_id' => $cat_id, 'creator' => $user->id, 'permissions' => $permissions, 'or_group_privacy' => 0, 'sorting' => $sorted, 'limit' => $limit);
         $otherVideos = $model->getVideos($filters);
     }
     // Set the current user's active profile
     CFactory::setActiveProfile($video->creator);
     // Hit counter + 1
     $video->hit();
     // Get reporting html
     $reportHTML = '';
     $report = new CReportingLibrary();
     if ($user->id != $my->id) {
         $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_VIDEOS_REPORT_VIDEOS'), 'videos,reportVideo', array($video->id));
     }
     // Get bookmark html
     $bookmarks = new CBookmarks($video->getPermalink());
     $bookmarksHTML = $bookmarks->getHTML();
     // Get the walls
     $wallContent = CWallLibrary::getWallContents('videos', $video->id, COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0, $config->get('stream_default_comments'), 0, 'wall/content', 'videos,video');
     $wallCount = CWallLibrary::getWallCount('videos', $video->id);
     $viewAllLink = CRoute::_('index.php?option=com_community&view=videos&task=app&videoid=' . $video->id . '&app=walls');
     $wallViewAll = '';
     if ($wallCount > $config->get('stream_default_comments')) {
         $wallViewAll = CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     }
     $wallForm = '';
     if ($this->isPermitted($my->id, $video->creator, PRIVACY_FRIENDS) || !$config->get('lockvideoswalls')) {
         $wallForm = CWallLibrary::getWallInputForm($video->id, 'videos,ajaxSaveWall', 'videos,ajaxRemoveWall', $viewAllLink);
     }
     $redirectUrl = CRoute::getURI(false);
     // Get like information.
     $like = new CLike();
     $likeCount = $like->getLikeCount('videos', $video->id);
     $likeLiked = $like->userLiked('videos', $video->id, $my->id) === COMMUNITY_LIKE;
     $tmpl = new CTemplate();
     if ($video->creator_type == VIDEO_GROUP_TYPE) {
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         $document = JFactory::getDocument();
         $document->addHeadLink($group->getThumbAvatar(), 'image_src', 'rel');
     }
     if ($video->location !== '' && $videoMapsDefault) {
         $zoomableMap = CMapping::drawZoomableMap($video->location, 220, 150, $video->longitude, $video->latitude);
     } else {
         $zoomableMap = "";
     }
     //friend list for video tag
     $tagging = new CVideoTagging();
     $taggedList = $tagging->getTaggedList($video->id);
     for ($t = 0; $t < count($taggedList); $t++) {
         $tagItem = $taggedList[$t];
         $tagUser = CFactory::getUser($tagItem->userid);
         $canRemoveTag = 0;
         // 1st we check the tagged user is the video owner.
         //	If yes, canRemoveTag == true.
         //	If no, then check on user is the tag creator or not.
         //	If yes, canRemoveTag == true
         //	If no, then check on user whether user is being tagged
         if (COwnerHelper::isMine($my->id, $video->creator) || COwnerHelper::isMine($my->id, $tagItem->created_by) || COwnerHelper::isMine($my->id, $tagItem->userid)) {
             $canRemoveTag = 1;
         }
         $tagItem->user = $tagUser;
         $tagItem->canRemoveTag = $canRemoveTag;
     }
     if ($video->type == "file") {
         $storage = CStorage::getStorage($video->storage);
         $video->path = $storage->getURI($video->path);
     }
     $config = CFactory::getConfig();
     $canSearch = 1;
     if ($my->id == 0 && !$config->get('enableguestsearchvideos')) {
         $canSearch = 0;
     }
     CHeadHelper::addOpengraph('og:image', JUri::root() . $video->thumb, true);
     CHeadHelper::setType('website', $video->title);
     $video->tagged = $taggedList;
     echo $tmpl->setMetaTags('video', $video)->set('user', $user)->set('zoomableMap', $zoomableMap)->set('likeCount', $likeCount)->set('canSearch', $canSearch)->set('likeLiked', $likeLiked)->set('redirectUrl', $redirectUrl)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('wallCount', $wallCount)->set('wallViewAll', $wallViewAll)->set('bookmarksHTML', $bookmarksHTML)->set('reportHTML', $reportHTML)->set('video', $video)->set('otherVideos', $otherVideos)->set('videoMapsDefault', $videoMapsDefault)->set('wallCount', $wallCount)->set('isGroup', $groupId ? true : false)->set('groupId', $groupId ? $groupId : null)->set('submenu', $this->showSubmenu(false))->fetch('videos/single');
 }
Example #2
0
 public function ajaxRemoveVideoTag($videoId, $userId)
 {
     $filter = JFilterInput::getInstance();
     $videoId = $filter->clean($videoId, 'int');
     $userId = $filter->clean($userId, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $my = CFactory::getUser();
     $json = array();
     if (!$my->authorise('community.remove', 'videos.tag.' . $videoId)) {
         $json['error'] = JText::_('ACCESS FORBIDDEN');
         die(json_encode($json));
     }
     $tagging = new CVideoTagging();
     if (!$tagging->removeTag($videoId, $userId)) {
         $json['error'] = $tagging->getError();
         die(json_encode($json));
     }
     $json['success'] = true;
     die(json_encode($json));
 }