Esempio n. 1
0
 /**
  * Display the photo thumbnails from an album
  * */
 public function album()
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $config = CFactory::getConfig();
     $handler = $this->_getHandler();
     $my = CFactory::getUser();
     //CFactory::load( 'libraries' , 'activities' );
     // Get show photo location map by default
     $photoMapsDefault = $config->get('photosmapdefault');
     $albumId = $jinput->get('albumid', 0, 'INT');
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($albumId);
     $defaultId = $jinput->get('photoid', 0, 'INT');
     $userId = $jinput->get('userid', 0, 'INT');
     $limitstart = $jinput->get->get('limitstart', '0', 'INT');
     if (empty($limitstart)) {
         $limitstart = $jinput->get->get('start', '0', 'INT');
     }
     $user = CFactory::getUser($album->creator);
     // Set pathway for group photos
     // Community > Groups > Group Name > Photos > Album Name
     $pathway = $mainframe->getPathway();
     if ($album->type == 'group') {
         if (!$my->authorise('community.view', 'photos.group.album.' . $album->groupid, $album)) {
             echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
             return;
         }
     } else {
         if (!$my->authorise('community.view', 'photos.user.album.' . $album->id)) {
             echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
             return;
         }
     }
     $groupId = $album->groupid;
     if ($groupId > 0) {
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         $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_PHOTOS'), CRoute::_('index.php?option=com_community&view=photos&groupid=' . $groupId));
     } else {
         $pathway->addItem(JText::_('COM_COMMUNITY_PHOTOS'), CRoute::_('index.php?option=com_community&view=photos'));
         $pathway->addItem(JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $user->getDisplayName()), CRoute::_('index.php?option=com_community&view=photos&task=myphotos&userid=' . $userId));
     }
     $handler->setMiniHeader();
     if (empty($albumId)) {
         echo JText::_('COM_COMMUNITY_PHOTOS_NO_ALBUMID_ERROR');
         return;
     }
     if (is_null($album->id)) {
         echo JText::_('COM_COMMUNITY_ALBUM_DELETED');
         return;
     }
     if (!$handler->isAlbumBrowsable($albumId)) {
         return;
     }
     //$photos		= $handler->getAlbumPhotos( $album->id );
     $photoPaginationLimit = intval($config->get('pagination'));
     $photoThumbLimit = $photoPaginationLimit;
     $model = CFactory::getModel('photos');
     $photos = $model->getPhotos($album->id, $photoThumbLimit, $limitstart);
     $pagination = $model->getPagination();
     $photo = JTable::getInstance('Photo', 'CTable');
     $photo->load($album->photoid);
     if ($album->photoid == '0') {
         $album->thumbnail = $photo->getThumbURI();
     } else {
         $album->thumbnail = $photo->getImageURI();
     }
     // Increment album's hit each time this page is loaded.
     $album->hit();
     if ($groupId > 0) {
         $otherAlbums = $model->getGroupAlbums($groupId);
     } else {
         $otherAlbums = $model->getAlbums($user->id);
     }
     $totalAlbums = count($otherAlbums);
     $showOtherAlbum = 6;
     $randomAlbum = array();
     if (count($otherAlbums) > 0) {
         $randomId = $totalAlbums < $showOtherAlbum ? array_rand($otherAlbums, $totalAlbums) : array_rand($otherAlbums, $showOtherAlbum);
         $count = 0;
         for ($i = 0; $i < $totalAlbums; $i++) {
             $num = is_array($randomId) ? $randomId[$i] : $randomId;
             if ($otherAlbums[$num]->id != $album->id) {
                 $count++;
                 $randomAlbum[] = $otherAlbums[$num];
             }
             if (count($randomAlbum) == $showOtherAlbum - 1) {
                 break;
             }
         }
     }
     /* set head meta */
     if (strtolower(trim(JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()))) == strtolower(trim($album->name))) {
         /**
          * Opengraph
          */
         CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()), CStringHelper::escape($album->getDescription()));
     } else {
         /**
          * Opengraph
          */
         CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()) . ' - ' . $album->name, CStringHelper::escape($album->getDescription()));
     }
     $this->setTitle($album->name);
     $handler->setAlbumPathway(CStringHelper::escape($album->name));
     $handler->setRSSHeader($albumId);
     // Set album thumbnail and description for social bookmarking sites linking
     $document->addHeadLink($album->getCoverThumbURI(), 'image_src', 'rel');
     //$document->setDescription( CStringHelper::escape($album->getDescription()) );
     //CFactory::load( 'libraries' , 'phototagging' );
     $getTaggingUsers = new CPhotoTagging();
     $people = array();
     // @TODO temporary fix for undefined link
     $list = array();
     foreach ($photos as $photo) {
         $photo->link = $handler->getPhotoURI($photo->id, $photo->albumid);
         CHeadHelper::addOpengraph('og:image', JUri::root(true) . '/' . $photo->image, true);
         $list[] = $photo;
     }
     $photos = $list;
     $albumParam = new Cparameter($album->params);
     $tagged = $albumParam->get('tagged');
     if (!empty($tagged)) {
         $people = explode(',', $albumParam->get('tagged'));
     }
     //Update lastUpdated
     $lastUpdated = new JDate($album->lastupdated);
     $album->lastUpdated = CActivityStream::_createdLapse($lastUpdated, false);
     $people = array_unique($people);
     CFactory::loadUsers($people);
     foreach ($people as &$person) {
         $person = CFactory::getUser($person);
     }
     //CFactory::load( 'libraries' , 'bookmarks' );
     $bookmarks = new CBookmarks($handler->getAlbumExternalURI($album->id));
     // Get wall data.
     $wallCount = CWallLibrary::getWallCount('albums', $album->id);
     $viewAllLink = false;
     if ($jinput->request->get('task', '') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls');
     }
     $wallContent = CWallLibrary::getWallContents('albums', $album->id, COwnerHelper::isCommunityAdmin() || $my->id == $album->creator && $my->id != 0, $config->get('stream_default_comments'), 0, 'wall/content', 'photos,album');
     $wallForm = CWallLibrary::getWallInputForm($album->id, 'photos,ajaxAlbumSaveWall', 'photos,ajaxAlbumRemoveWall', $viewAllLink);
     $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls');
     $wallViewAll = '';
     if ($wallCount > $config->get('stream_default_comments')) {
         $wallViewAll = CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     }
     $redirectUrl = CRoute::getURI(false);
     $tmpl = new CTemplate();
     if ($album->location != "") {
         $zoomableMap = CMapping::drawZoomableMap($album->location, 220, 150);
     } else {
         $zoomableMap = "";
     }
     // Get the likes / dislikes item
     //CFactory::load( 'libraries' , 'like' );
     $like = new CLike();
     $likeCount = $like->getLikeCount('album', $album->id);
     $likeLiked = $like->userLiked('album', $album->id, $my->id) === COMMUNITY_LIKE;
     $owner = CFactory::getUser($album->creator);
     echo $tmpl->set('photosmapdefault', $photoMapsDefault)->set('my', $my)->set('bookmarksHTML', $bookmarks->getHTML())->set('isOwner', $handler->isAlbumOwner($album->id))->set('isAdmin', COwnerHelper::isCommunityAdmin())->set('owner', $owner)->set('photos', $photos)->set('people', $people)->set('album', $album)->set('groupId', $groupId)->set('otherAlbums', $randomAlbum)->set('likeCount', $likeCount)->set('likeLiked', $likeLiked)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('wallCount', $wallCount)->set('wallViewAll', $wallViewAll)->set('zoomableMap', $zoomableMap)->set('pagination', $pagination)->set('photoId', $defaultId)->set('submenu', $this->showSubmenu(false))->fetch('photos/list');
 }
Esempio n. 2
0
 /**
  * Trigger any necessary items that needs to be changed when the photo
  * is changed.
  * */
 public function ajaxSwitchPhotoTrigger($photoId, $showAll = false)
 {
     $filter = JFilterInput::getInstance();
     $photoId = $filter->clean($photoId, 'int');
     // $singleComment = $filter->clean($singleCommshowAll ? );
     $response = new JAXResponse();
     $json = array();
     // Load the default photo
     $photo = JTable::getInstance('Photo', 'CTable');
     $photo->load($photoId);
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($photo->albumid);
     // Since the only way for us to get the id is through the AJAX call,
     // we can only increment the hit when the ajax loads
     $photo->hit();
     // Update the hits each time the photo is switched
     $response->addAssign('photo-hits', 'innerHTML', $photo->hits);
     // Show creator
     $creator = CFactory::getUser($photo->creator);
     $creatorHTML = JText::sprintf('COM_COMMUNITY_UPLOADED_BY', CRoute::_('index.php?option=com_community&view=profile&userid=' . $creator->id), $creator->getDisplayName());
     $response->addAssign('uploadedBy', 'innerHTML', $creatorHTML);
     // Get the header info
     $header = $this->getPhotoInfoHeader($photo);
     // Get the wall form
     $wallInput = $this->_getWallFormHTML($photoId);
     // Get the wall contents
     $wallContents = $this->showWallContents($photoId, $showAll ? false : $config->get('stream_default_comments'));
     $totalComments = CWallLibrary::getWallCount('photos', $photo->id);
     // Photo info.
     $info = array();
     // JSON.
     $json['head'] = $header;
     $json['comments'] = $wallContents;
     $json['form'] = $wallInput;
     $json['comments_count'] = $totalComments;
     $description = $photo->caption;
     if (preg_match('/\\.(jpg|jpeg|png|gif|bmp)$/i', $description)) {
         $description = '';
     }
     $json['description'] = array('content' => $description, 'lang_cancel' => JText::_('COM_COMMUNITY_CANCEL'), 'lang_save' => JText::_('COM_COMMUNITY_SAVE'), 'lang_add' => JText::_('COM_COMMUNITY_ADD_DESCRIPTION'), 'lang_edit' => JText::_('COM_COMMUNITY_EDIT_DESCRIPTION'), 'lang_placeholder' => JText::_('COM_COMMUNITY_EDIT_DESCRIPTION_PLACEHOLDER'));
     // Only show if we are not showing all comments, and total comments is not 0.
     if (!$showAll) {
         $commentDiff = $totalComments - $config->get('stream_default_comments');
         if ($commentDiff > 0) {
             $json['showall'] = JText::_('COM_COMMUNITY_SHOW_PREVIOUS_COMMENTS') . ' (' . $commentDiff . ')';
         }
     }
     // Tag info.
     $json['tagged'] = $this->getPhotoTags($photo);
     $json['tagLabel'] = JText::_('COM_COMMUNITY_PHOTOS_IN_THIS_PHOTO');
     $json['tagRemoveLabel'] = JText::_('COM_COMMUNITY_REMOVE');
     // Get photo like info.
     $like = new CLike();
     $json['like'] = array('lang' => JText::_('COM_COMMUNITY_LIKE'), 'lang_like' => JText::_('COM_COMMUNITY_LIKE'), 'lang_liked' => JText::_('COM_COMMUNITY_LIKED'), 'count' => $like->getLikeCount('photo', $photoId), 'is_liked' => $like->userLiked('photo', $photoId, $my->id) === COMMUNITY_LIKE);
     die(json_encode($json));
 }
Esempio n. 3
0
 /**
  * Return formatted comment given the wall item
  */
 public static function formatComment($wall)
 {
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $actModel = CFactory::getModel('activities');
     $like = new CLike();
     $likeCount = $like->getLikeCount('comment', $wall->id);
     $isLiked = $like->userLiked('comment', $wall->id, $my->id);
     $user = CFactory::getUser($wall->post_by);
     // Censor if the user is banned
     if ($user->block) {
         $wall->comment = $origComment = JText::_('COM_COMMUNITY_CENSORED');
     } else {
         // strip out the comment data
         $CComment = new CComment();
         $wall->comment = $CComment->stripCommentData($wall->comment);
         // Need to perform basic formatting here
         // 1. support nl to br,
         // 2. auto-link text
         $CTemplate = new CTemplate();
         $wall->comment = $origComment = $CTemplate->escape($wall->comment);
         $wall->comment = CStringHelper::autoLink($wall->comment);
     }
     $commentsHTML = '';
     $commentsHTML .= '<div class="cComment wall-coc-item" id="wall-' . $wall->id . '"><a href="' . CUrlHelper::userLink($user->id) . '"><img src="' . $user->getThumbAvatar() . '" alt="" class="wall-coc-avatar" /></a>';
     $date = new JDate($wall->date);
     $commentsHTML .= '<a class="wall-coc-author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> ';
     $commentsHTML .= $wall->comment;
     $commentsHTML .= '<span class="wall-coc-time">' . CTimeHelper::timeLapse($date);
     $cid = isset($wall->contentid) ? $wall->contentid : null;
     $activity = $actModel->getActivity($cid);
     $ownPost = $my->id == $wall->post_by;
     $allowRemove = $my->authorise('community.delete', 'walls', $wall);
     $canEdit = $config->get('wallediting') && $my->id == $wall->post_by || COwnerHelper::isCommunityAdmin();
     // only poster can edit
     if ($allowRemove) {
         $commentsHTML .= ' <span class="wall-coc-remove-link">&#x2022; <a href="#removeComment">' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</a></span>';
     }
     $commentsHTML .= '</span>';
     $commentsHTML .= '</div>';
     $editHTML = '';
     if ($config->get('wallediting') && $ownPost || COwnerHelper::isCommunityAdmin()) {
         $editHTML .= '<a href="javascript:" class="joms-button--edit">';
         $editHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-pencil"></use></svg>';
         $editHTML .= '<span>' . JText::_('COM_COMMUNITY_EDIT') . '</span>';
         $editHTML .= '</a>';
     }
     $removeHTML = '';
     if ($allowRemove) {
         $removeHTML .= '<a href="javascript:" class="joms-button--remove">';
         $removeHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-remove"></use></svg>';
         $removeHTML .= '<span>' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</span>';
         $removeHTML .= '</a>';
     }
     $removeTagHTML = '';
     if (CActivitiesHelper::hasTag($my->id, $wall->comment)) {
         $removeTagHTML = '<span><a data-action="remove-tag" data-id="' . $wall->id . '" href="javascript:">' . JText::_('COM_COMMUNITY_WALL_REMOVE_TAG') . '</a></span>';
     }
     /* user deleted */
     if ($user->guest == 1) {
         $userLink = '<span class="cStream-Author">' . $user->getDisplayName() . '</span> ';
     } else {
         $userLink = '<a class="cStream-Avatar cStream-Author cFloat-L" href="' . CUrlHelper::userLink($user->id) . '"> <img class="cAvatar" src="' . $user->getThumbAvatar() . '"> </a> ';
     }
     $params = $wall->params;
     $paramsHTML = '';
     $image = (array) $params->get('image');
     $photoThumbnail = false;
     if ($params->get('attached_photo_id') > 0) {
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($params->get('attached_photo_id'));
         $photoThumbnail = $photo->getThumbURI();
         $paramsHTML .= '<div style="padding: 5px 0"><img class="joms-stream-thumb" src="' . $photoThumbnail . '" /></div>';
     } else {
         if ($params->get('title')) {
             $video = self::detectVideo($params->get('url'));
             if (is_object($video)) {
                 $paramsHTML .= '<div class="joms-media--video joms-js--video"';
                 $paramsHTML .= ' data-type="' . $video->type . '"';
                 $paramsHTML .= ' data-id="' . $video->id . '"';
                 $paramsHTML .= ' data-path="' . ($video->type === 'file' ? JURI::root(true) . '/' : '') . $video->path . '"';
                 $paramsHTML .= ' style="margin-top:10px;">';
                 $paramsHTML .= '<div class="joms-media__thumbnail">';
                 $paramsHTML .= '<img src="' . $video->getThumbnail() . '">';
                 $paramsHTML .= '<a href="javascript:" class="mejs-overlay mejs-layer mejs-overlay-play joms-js--video-play joms-js--video-play-' . $wall->id . '">';
                 $paramsHTML .= '<div class="mejs-overlay-button"></div>';
                 $paramsHTML .= '</a>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<h4 class="joms-media__title">' . JHTML::_('string.truncate', $video->title, 50, true, false) . '</h4>';
                 $paramsHTML .= '<p class="joms-media__desc">' . JHTML::_('string.truncate', $video->description, $config->getInt('streamcontentlength'), true, false) . '</p>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '</div>';
             } else {
                 $paramsHTML .= '<div class="joms-gap"></div>';
                 $paramsHTML .= '<div class="joms-media--album joms-relative joms-js--comment-preview">';
                 if ($user->id == $my->id || COwnerHelper::isCommunityAdmin()) {
                     $paramsHTML .= '<span class="joms-media__remove" data-action="remove-preview" onClick="joms.api.commentRemovePreview(\'' . $wall->id . '\');"><svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="#joms-icon-remove"></use></svg></span>';
                 }
                 if ($params->get('image')) {
                     $paramsHTML .= $params->get('link');
                     $paramsHTML .= '<div class="joms-media__thumbnail">';
                     $paramsHTML .= '<a href="' . $params->get('link') ? $params->get('link') : '#' . '">';
                     $paramsHTML .= '<img src="' . array_shift($image) . '" />';
                     $paramsHTML .= '</a>';
                     $paramsHTML .= '</div>';
                 }
                 $url = $params->get('url') ? $params->get('url') : '#';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<a href="' . $url . '">';
                 $paramsHTML .= '<h4 class="joms-media__title">' . $params->get('title') . '</h4>';
                 $paramsHTML .= '<p class="joms-media__desc reset-gap">' . CStringHelper::trim_words($params->get('description')) . '</p>';
                 if ($params->get('link')) {
                     $paramsHTML .= '<span class="joms-text--light"><small>' . preg_replace('#^https?://#', '', $params->get('link')) . '</small></span>';
                 }
                 $paramsHTML .= '</a></div></div>';
             }
         }
     }
     if (!$params->get('title') && $params->get('url')) {
         $paramsHTML .= '<div class="joms-gap"></div>';
         $paramsHTML .= '<div class="joms-media--album">';
         $paramsHTML .= '<a href="' . $params->get('url') . '">';
         $paramsHTML .= '<img class="joms-stream-thumb" src="' . $params->get('url') . '" />';
         $paramsHTML .= '</a>';
         $paramsHTML .= '</div>';
     }
     $wall->comment = nl2br($wall->comment);
     $wall->comment = CUserHelper::replaceAliasURL($wall->comment);
     $wall->comment = CStringHelper::getEmoticon($wall->comment);
     $wall->comment = CStringHelper::converttagtolink($wall->comment);
     // convert to hashtag
     $template = new CTemplate();
     $template->set('wall', $wall)->set('originalComment', $origComment)->set('date', $date)->set('isLiked', $isLiked)->set('likeCount', $likeCount)->set('canRemove', $allowRemove)->set('canEdit', $canEdit)->set('canRemove', $allowRemove)->set('user', $user)->set('photoThumbnail', $photoThumbnail)->set('paramsHTML', $paramsHTML);
     $commentsHTML = $template->fetch('stream/single-comment');
     return $commentsHTML;
 }
Esempio n. 4
0
 /**
  * Responsible for displaying the event page.
  * */
 public function viewevent()
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     CWindow::load();
     $eventLib = new CEvents();
     $eventid = JRequest::getInt('eventid', 0);
     $eventModel = CFactory::getModel('events');
     $event = JTable::getInstance('Event', 'CTable');
     $handler = CEventHelper::getHandler($event);
     $event->load($eventid);
     if (empty($event->id)) {
         return JError::raiseWarning(404, JText::_('COM_COMMUNITY_EVENTS_NOT_AVAILABLE_ERROR'));
     }
     if ($event->unlisted && !$event->isMember($my->id) && !$event->getUserStatus($my->id) == 0) {
         $text = JText::_('COM_COMMUNITY_EVENTS_UNLISTED_ERROR');
         $text .= ' <a href="javascript:" onclick="joms.api.eventJoin(\'' . $event->id . '\');">Request Invitation</a>';
         return JError::raiseWarning(403, $text);
     }
     if (!$handler->exists()) {
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_NOT_AVAILABLE_ERROR'), 'error');
         return;
     }
     if (!$handler->browsable()) {
         echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
         return;
     }
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$event->isPublished()) {
         echo JText::_('COM_COMMUNITY_EVENTS_UNDER_MODERATION');
         return;
     }
     //$this->showSubmenu();
     $event->hit();
     $isGroupAdmin = false;
     // Basic page presentation
     if ($event->type == 'group') {
         $groupId = $event->contentid;
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         // Set pathway for group videos
         // Community > Groups > Group Name > Events
         $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
         $this->addPathway($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId));
         $groupEventDetails = new stdClass();
         $groupEventDetails->creator = CFactory::getUser($event->creator);
         $groupEventDetails->groupName = $group->name;
         $groupEventDetails->groupLink = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
         $isGroupAdmin = $group->isAdmin($my->id);
     }
     $this->addPathway(JText::_('COM_COMMUNITY_EVENTS'), CRoute::_('index.php?option=com_community&view=events'));
     $this->addPathway($event->title);
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_EVENT_PAGE_TITLE', $event->title), null, array($event->getCover()));
     // Permissions and privacies
     $isEventGuest = $event->isMember($my->id);
     $isMine = $my->id == $event->creator;
     $isAdmin = $event->isAdmin($my->id) || $isGroupAdmin;
     $isCommunityAdmin = COwnerHelper::isCommunityAdmin();
     // Get Event Admins
     $eventAdmins = $event->getAdmins(12, CC_RANDOMIZE);
     $adminsInArray = array();
     // Attach avatar of the admin
     for ($i = 0; $i < count($eventAdmins); $i++) {
         $row = $eventAdmins[$i];
         $admin = CFactory::getUser($row->id);
         array_push($adminsInArray, '<a href="' . CUrlHelper::userLink($admin->id) . '">' . $admin->getDisplayName() . '</a>');
     }
     $adminsList = ltrim(implode(', ', $adminsInArray), ',');
     // Get Attending Event Guests
     $eventMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, CFactory::getConfig()->get('event_sidebar_members_show_total', 12), CC_RANDOMIZE);
     $eventMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_ATTEND);
     // Attach avatar of the admin
     // Pre-load multiple users at once
     $userids = array();
     foreach ($eventMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($eventMembers); $i++) {
         $row = $eventMembers[$i];
         $eventMembers[$i] = CFactory::getUser($row->id);
     }
     // Pre-load multiple users at once
     $waitingApproval = $event->isPendingApproval($my->id);
     $waitingRespond = false;
     $myStatus = $event->getUserStatus($my->id);
     $hasResponded = $myStatus == COMMUNITY_EVENT_STATUS_ATTEND || $myStatus == COMMUNITY_EVENT_STATUS_WONTATTEND || $myStatus == COMMUNITY_EVENT_STATUS_MAYBE;
     // Get Bookmark HTML
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id));
     $bookmarksHTML = $bookmarks->getHTML();
     // Get the Wall
     $wallContent = CWallLibrary::getWallContents('events', $event->id, $isAdmin, $config->get('stream_default_comments'), 0, 'wall/content', 'events,events');
     $wallCount = CWallLibrary::getWallCount('events', $event->id);
     $viewAllLink = false;
     if ($jinput->request->get('task', '', 'STRING') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=events&task=app&eventid=' . $event->id . '&app=walls');
     }
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     $wallForm = '';
     // Construct the RVSP radio list
     $arr = array(JHTML::_('select.option', COMMUNITY_EVENT_STATUS_ATTEND, JText::_('COM_COMMUNITY_EVENTS_YES')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_WONTATTEND, JText::_('COM_COMMUNITY_EVENTS_NO')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_MAYBE, JText::_('COM_COMMUNITY_EVENTS_MAYBE')));
     $status = $event->getMemberStatus($my->id);
     $radioList = JHTML::_('select.radiolist', $arr, 'status', '', 'value', 'text', $status, false);
     $unapprovedCount = $event->inviteRequestCount();
     //...
     $editEvent = $jinput->get->get('edit', false, 'NONE');
     $editEvent = $editEvent == 1 ? true : false;
     // Am I invited in this event?
     $isInvited = false;
     $join = '';
     $friendsCount = 0;
     $isInvited = $eventModel->isInvitedMe(0, $my->id, $event->id);
     // If I was invited, I want to know my invitation informations
     if ($isInvited) {
         $invitor = CFactory::getUser($isInvited[0]->invited_by);
         $join = '<a href="' . CUrlHelper::userLink($invitor->id) . '">' . $invitor->getDisplayName() . '</a>';
         // Get users friends in this group
         $friendsCount = $eventModel->getFriendsCount($my->id, $event->id);
     }
     // Get like
     $likes = new CLike();
     $isUserLiked = false;
     if ($isLikeEnabled = $likes->enabled('events')) {
         $isUserLiked = $likes->userLiked('events', $event->id, $my->id);
     }
     $totalLikes = $likes->getLikeCount('events', $event->id);
     // Is this event is a past event?
     $now = new JDate();
     $isPastEvent = $event->getEndDate(false)->toSql() < $now->toSql(true) ? true : false;
     // Get the formated date & time
     $format = $config->get('eventshowampm') ? JText::_('COM_COMMUNITY_EVENTS_TIME_FORMAT_12HR') : JText::_('COM_COMMUNITY_EVENTS_TIME_FORMAT_24HR');
     $startDate = $event->getStartDate(false);
     $endDate = $event->getEndDate(false);
     $allday = false;
     if ($startDate->format('%Y-%m-%d') == $endDate->format('%Y-%m-%d') && $startDate->format('%H:%M:%S') == '00:00:00' && $endDate->format('%H:%M:%S') == '23:59:59') {
         $format = JText::_('COM_COMMUNITY_EVENT_TIME_FORMAT_LC1');
         $allday = true;
     }
     $event->startdateHTML = CTimeHelper::getFormattedTime($event->startdate, $format);
     $event->enddateHTML = CTimeHelper::getFormattedTime($event->enddate, $format);
     if (!isset($event->params)) {
         $event->params = '';
     }
     $params = new CParameter($event->params);
     $event->defaultCover = $event->isDefaultCover();
     // Cover position.
     $event->coverPostion = $params->get('coverPosition', '');
     if (strpos($event->coverPostion, '%') === false) {
         $event->coverPostion = 0;
     }
     // Find cover album and photo.
     $event->coverAlbum = false;
     $event->coverPhoto = false;
     $album = JTable::getInstance('Album', 'CTable');
     $albumId = $album->isCoverExist('event', $event->id);
     if ($albumId) {
         $album->load($albumId);
         $event->coverAlbum = $albumId;
         $event->coverPhoto = $album->photoid;
     }
     $inviteHTML = CInvitation::getHTML(null, 'events,inviteUsers', $event->id, CInvitation::SHOW_FRIENDS, CInvitation::SHOW_EMAIL);
     $status = new CUserStatus($event->id, 'events');
     $tmpl = new CTemplate();
     $creator = new CUserStatusCreator('message');
     $creator->title = $isMine ? JText::_('COM_COMMUNITY_STATUS') : JText::_('COM_COMMUNITY_MESSAGE');
     $creator->html = $tmpl->fetch('status.message');
     $status->addCreator($creator);
     // Upgrade wall to stream @since 2.5
     $event->upgradeWallToStream();
     // Add custom stream
     $streamHTML = $eventLib->getStreamHTML($event);
     if ($event->getMemberStatus($my->id) == COMMUNITY_EVENT_STATUS_ATTEND) {
         $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_ATTENDING_EVENT_MESSAGE');
     } else {
         if ($event->getMemberStatus($my->id) == COMMUNITY_EVENT_STATUS_WONTATTEND) {
             $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_NOT_ATTENDING_EVENT_MESSAGE');
         } else {
             $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_NOT_RESPOND_RSVP_MESSAGE');
         }
     }
     // Get recurring event series
     $eventSeries = null;
     $seriesCount = 0;
     if ($event->isRecurring()) {
         $advance = array('expired' => false, 'return' => 'object', 'limit' => COMMUNITY_EVENT_SERIES_LIMIT, 'exclude' => $event->id, 'published' => 1);
         $tempseries = $eventModel->getEventChilds($event->parent, $advance);
         foreach ($tempseries as $series) {
             $table = JTable::getInstance('Event', 'CTable');
             $table->bind($series);
             $eventSeries[] = $table;
         }
         $seriesCount = $eventModel->getEventChildsCount($event->parent);
     }
     //pending request invitation guest
     $pendingRequestGuests = $event->getMembers(COMMUNITY_EVENT_STATUS_REQUESTINVITE, 0, false, false);
     // Pre-load multiple users at once
     $tempUserInfo = array();
     foreach ($pendingRequestGuests as $uid) {
         $tempUserInfo[] = CFactory::getUser($uid->id);
     }
     $pendingRequestGuests = $tempUserInfo;
     $featured = new CFeatured(FEATURED_EVENTS);
     $featuredList = $featured->getItemIds();
     // Get Attending Event Guests
     $maybeList = $event->getMembers(COMMUNITY_EVENT_STATUS_MAYBE, 12, CC_RANDOMIZE);
     $maybeCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_MAYBE);
     $tempUserInfo = array();
     foreach ($maybeList as $uid) {
         $tempUserInfo[] = CFactory::getUser($uid->id);
     }
     $maybeList = $tempUserInfo;
     $wontAttendList = $event->getMembers(COMMUNITY_EVENT_STATUS_WONTATTEND, 12, CC_RANDOMIZE);
     $wontAttendCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_WONTATTEND);
     $tempUserInfo = array();
     foreach ($wontAttendList as $uid) {
         $tempUserInfo[] = CFactory::getUser($uid->id);
     }
     $wontAttendList = $tempUserInfo;
     //gets all the albums related to this photo
     $photosModel = CFactory::getModel('photos');
     $albums = $photosModel->getEventAlbums($event->id);
     $totalPhotos = 0;
     foreach ($albums as $album) {
         $albumParams = new CParameter($album->params);
         $totalPhotos = $totalPhotos + $albumParams->get('count');
     }
     //get total videos
     $videosModel = CFactory::getModel('videos');
     $videos = $videosModel->getEventVideos($eventid);
     $totalVideos = count($videosModel->getEventVideos($eventid));
     // Output to template
     echo $tmpl->setMetaTags('event', $event)->set('status', $status)->set('albums', $albums)->set('videos', $videos)->set('pendingRequestGuests', $pendingRequestGuests)->set('streamHTML', $streamHTML)->set('timezone', CTimeHelper::getTimezone($event->offset))->set('handler', $handler)->set('isUserLiked', $isUserLiked)->set('totalLikes', $totalLikes)->set('inviteHTML', $inviteHTML)->set('guestStatus', $event->getUserStatus($my->id))->set('event', $event)->set('radioList', $radioList)->set('bookmarksHTML', $bookmarksHTML)->set('isLikeEnabled', $isLikeEnabled)->set('isEventGuest', $isEventGuest)->set('isMine', $isMine)->set('isAdmin', $isAdmin)->set('isCommunityAdmin', $isCommunityAdmin)->set('unapproved', $unapprovedCount)->set('waitingApproval', $waitingApproval)->set('wallContent', $wallContent)->set('eventMembers', $eventMembers)->set('eventMembersCount', $eventMembersCount)->set('editEvent', $editEvent)->set('my', $my)->set('creator', CFactory::getUser($event->creator))->set('memberStatus', $myStatus)->set('waitingRespond', $waitingRespond)->set('isInvited', $isInvited)->set('join', $join)->set('friendsCount', $friendsCount)->set('isPastEvent', $isPastEvent)->set('adminsList', $adminsList)->set('RSVPmessage', $RSVPmessage)->set('allday', $allday)->set('eventSeries', $eventSeries)->set('seriesCount', $seriesCount)->set('groupEventDetails', isset($groupEventDetails) ? $groupEventDetails : null)->set('featuredList', $featuredList)->set('photoPermission', $params->get('photopermission'))->set('videoPermission', $params->get('videopermission'))->set('showPhotos', $params->get('photopermission') != -1 && $config->get('enablephotos') && $config->get('eventphotos'))->set('showVideos', $params->get('videopermission') != -1 && $config->get('enablevideos') && $config->get('eventvideos'))->set('totalPhotos', $totalPhotos)->set('totalVideos', $totalVideos)->set('maybeList', $maybeList)->set('maybeCount', $maybeCount)->set('wontAttendList', $wontAttendList)->set('wontAttendCount', $wontAttendCount)->fetch('events/single');
 }
Esempio n. 5
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');
 }
Esempio n. 6
0
 public function ajaxShowVideoWindow($video_id)
 {
     $allowToView = true;
     //determine the view premission
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $video = JTable::getInstance('Video', 'CTable');
     if (!$video->load($video_id)) {
         $allowToView = false;
     }
     /* === Start Premission Checking === */
     $user = CFactory::getUser($video->creator);
     $blocked = $user->isBlocked();
     if ($blocked && !COwnerHelper::isCommunityAdmin()) {
         $allowToView = false;
     }
     if ($video->creator_type == VIDEO_GROUP_TYPE) {
         //CFactory::load( 'helpers' , 'group' );
         if (!CGroupHelper::allowViewMedia($video->groupid)) {
             $allowToView = false;
         }
     } else {
         if (!CPrivacy::isAccessAllowed($my->id, $video->creator, 'custom', $video->permissions)) {
             switch ($video->permissions) {
                 case '40':
                     $allowToView = false;
                     break;
                 case '30':
                     $allowToView = false;
                     $this->noAccess(JText::sprintf('COM_COMMUNITY_VIDEOS_FRIEND_PERMISSION_MESSAGE', $owner->getDisplayName()));
                     break;
                 default:
                     $allowToView = false;
                     break;
             }
         }
     }
     if ($video->published == 0) {
         $allowToView = false;
     }
     /* === End Permission Checking === */
     if (!$allowToView) {
         $json = array('error' => JText::_('COM_COMMUNITY_VIDEO_UNABLE_VIEW'));
         die(json_encode($json));
     }
     $video->hit();
     // JSON.
     $json = array();
     $json['playerHtml'] = $video->getPlayerHTML();
     $json['can_edit'] = $video->canEdit();
     $json['video_url'] = $video->getPermalink();
     $json['hits'] = $video->getHits();
     $json['hits'] = JText::sprintf(CStringHelper::isPlural($json['hits']) ? 'COM_COMMUNITY_VIDEOS_HITS_COUNT_MANY' : 'COM_COMMUNITY_VIDEOS_HITS_COUNT', $json['hits']);
     $json['my_id'] = (int) $my->id;
     $json['owner_id'] = (int) $video->creator;
     $json['is_admin'] = (int) COwnerHelper::isCommunityAdmin();
     $json['enableprofilevideo'] = $config->get('enableprofilevideo');
     $json['enablereporting'] = $config->get('enablereporting');
     $json['enablesharing'] = $config->get('enablesharethis') == 1;
     // Get photo like info.
     $like = new CLike();
     $json['like'] = array('lang' => JText::_('COM_COMMUNITY_LIKE'), 'lang_like' => JText::_('COM_COMMUNITY_LIKE'), 'lang_liked' => JText::_('COM_COMMUNITY_LIKED'), 'count' => $like->getLikeCount('videos', $video->id), 'is_liked' => $like->userLiked('videos', $video->id, $my->id) === COMMUNITY_LIKE);
     // Languages.
     $json['lang'] = array('comments' => JText::_('COM_COMMUNITY_COMMENTS'), 'tag_video' => JText::_('COM_COMMUNITY_TAG_THIS_VIDEO'), 'done_tagging' => JText::_('COM_COMMUNITY_PHOTO_DONE_TAGGING'), 'options' => JText::_('COM_COMMUNITY_OPTIONS'), 'fetch' => JText::_('COM_COMMUNITY_VIDEOS_FETCH_THUMBNAIL'), 'set_as_profile_video' => JText::_('COM_COMMUNITY_VIDEOS_SET_AS_PROFILE'), 'edit_video' => JText::_('COM_COMMUNITY_VIDEOS_EDIT_VIDEO'), 'delete_video' => JText::_('COM_COMMUNITY_VIDEOS_DELETE_VIDEO'), 'share' => JText::_('COM_COMMUNITY_SHARE'), 'report' => JText::_('COM_COMMUNITY_REPORT'));
     die(json_encode($json));
 }
Esempio n. 7
0
 public static function showEventMiniHeader($id)
 {
     $event = JTable::getInstance('Event', 'CTable');
     $event->load($id);
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $option = $jinput->request->get('option', '', 'STRING');
     //JRequest::getVar('option', '', 'REQUEST');
     $enableReporting = $config->get('enablereporting') == 1 && $config->get('enableguestreporting') != 1 && $my->id != 0;
     $handler = CEventHelper::getHandler($event);
     $myStatus = $event->getUserStatus($my->id);
     $isEventGuest = $event->isMember($my->id);
     $isAdmin = $event->isAdmin($my->id);
     $unapprovedCount = $event->inviteRequestCount();
     $eventMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_ATTEND);
     // Get like
     $likes = new CLike();
     $isUserLiked = false;
     if ($isLikeEnabled = $likes->enabled('events')) {
         $isUserLiked = $likes->userLiked('events', $event->id, $my->id);
     }
     $totalLikes = $likes->getLikeCount('events', $event->id);
     $params = new CParameter($event->params);
     $event->coverPostion = $params->get('coverPosition', '');
     $event->defaultCover = $event->isDefaultCover();
     $now = new JDate();
     $tmpl = new CTemplate();
     $tmpl->set('event', $event)->set('isAdmin', $isAdmin)->set('waitingRespond', false)->set('isUserLiked', $isUserLiked)->set('totalLikes', $totalLikes)->set('creator', CFactory::getUser($event->creator))->set('unapproved', $unapprovedCount)->set('isLikeEnabled', $isLikeEnabled)->set('eventMembersCount', $eventMembersCount)->set('memberStatus', $myStatus)->set('isEventGuest', $isEventGuest)->set('enableReporting', $enableReporting)->set('isPastEvent', $event->getEndDate(false)->toSql() < $now->toSql(true) ? true : false)->set('isMine', $event->isCreator($my->id))->set('handler', $handler);
     return $option == 'com_community' ? $tmpl->fetch('events/miniheader') : '<div id="community-wrap">' . $tmpl->fetch('events/miniheader') . '</div>';
 }
Esempio n. 8
0
 /**
  * Displays specific groups
  * */
 public function viewGroup($group)
 {
     CWindow::load();
     $config = CFactory::getConfig();
     $document = JFactory::getDocument();
     $groupLib = new CGroups();
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     // Load appropriate models
     $groupModel = CFactory::getModel('groups');
     $wallModel = CFactory::getModel('wall');
     $userModel = CFactory::getModel('user');
     $discussModel = CFactory::getModel('discussions');
     $bulletinModel = CFactory::getModel('bulletins');
     $photosModel = CFactory::getModel('photos');
     $activityModel = CFactory::getModel('activities');
     $fileModel = CFactory::getModel('files');
     $editGroup = $jinput->get->get('edit', FALSE, 'NONE');
     $editGroup = $editGroup == 1 ? true : false;
     $params = $group->getParams();
     /**
      * Opengraph
      * @todo Support group avatar og:image
      */
     CHeadHelper::setType('website', CStringHelper::escape($group->name), CStringHelper::escape(strip_tags($group->description)));
     $document->addCustomTag('<link rel="image_src" href="' . JURI::root(true) . '/' . $group->thumb . '" />');
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$group->published) {
         $this->_redirectUnpublishGroup();
         return;
     }
     $group->hit();
     $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
     $this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_NAME_TITLE', $group->name), '');
     // Load the current browsers data
     $my = CFactory::getUser();
     // If user are invited
     $isInvited = $groupModel->isInvited($my->id, $group->id);
     // Get members list for display
     //$members	= $groupModel->getAllMember($group->id);
     //Set limit for member listing on view group page
     $limit = 12;
     $approvedMembers = $groupModel->getMembers($group->id, $limit, true, false, true);
     CError::assert($approvedMembers, 'array', 'istype', __FILE__, __LINE__);
     $membersCount = count($groupModel->getAllMember($group->id));
     // Is there any my friend is the member of this group?
     $join = '';
     $friendsCount = 0;
     if ($isInvited) {
         // Get the invitors
         $invitors = $groupModel->getInvitors($my->id, $group->id);
         if (count($invitors) == 1) {
             $user = CFactory::getUser($invitors[0]->creator);
             $join = '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
         } else {
             for ($i = 0; $i < count($invitors); $i++) {
                 $user = CFactory::getUser($invitors[$i]->creator);
                 if ($i + 1 == count($invitors)) {
                     $join .= ' ' . JText::_('COM_COMMUNITY_AND') . ' ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
                 } else {
                     $join .= ', ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
                 }
             }
         }
         // Get users friends in this group
         $friendsCount = $groupModel->getFriendsCount($my->id, $group->id);
     }
     // Get list of unapproved members
     $unapproved = $groupModel->getMembers($group->id, null, false);
     $unapproved = count($unapproved);
     // Test if the current user is admin
     $isAdmin = $groupModel->isAdmin($my->id, $group->id);
     // Test if the current browser is a member of the group
     $isMember = $groupModel->isMember($my->id, $group->id);
     $waitingApproval = false;
     // Test if the current user is banned from this group
     $isBanned = $group->isBanned($my->id);
     // Attach avatar of the member
     // Pre-load multiple users at once
     $userids = array();
     $limitloop = $limit;
     foreach ($approvedMembers as $uid) {
         $userids[] = $uid->id;
         if (--$limitloop < 1) {
             break;
         }
     }
     CFactory::loadUsers($userids);
     $limitloop = $limit;
     for ($i = 0; $i < count($approvedMembers); $i++) {
         $row = $approvedMembers[$i];
         $approvedMembers[$i] = CFactory::getUser($row->id);
         if (--$limitloop < 1) {
             break;
         }
     }
     if ($isBanned) {
         $mainframe = JFactory::getApplication();
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_GROUPS_MEMBER_BANNED'), 'error');
         return;
     }
     // If I have tried to join this group, but not yet approved, display a notice
     if ($groupModel->isWaitingAuthorization($my->id, $group->id)) {
         $waitingApproval = true;
     }
     // Get like
     $likes = new CLike();
     $isUserLiked = false;
     if ($isLikeEnabled = $likes->enabled('groups')) {
         $isUserLiked = $likes->userLiked('groups', $group->id, $my->id);
     }
     $totalLikes = $likes->getLikeCount('groups', $group->id);
     // Get discussions data
     $discussionData = $this->_cachedCall('_getDiscussionListHTML', array($params, $group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL));
     $discussionsHTML = $discussionData['HTML'];
     $totalDiscussion = $discussionData['total'];
     $discussions = $discussionData['data'];
     // Get bulletins data
     $bulletinData = $this->_cachedCall('_getBulletinListHTML', array($group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL));
     $totalBulletin = $bulletinData['total'];
     $bulletinsHTML = $bulletinData['HTML'];
     $bulletins = $bulletinData['data'];
     // Get album data
     $albumData = $this->_cachedCall('_getAlbums', array($params, $group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL));
     $albums = $albumData['data'];
     $totalAlbums = $albumData['total'];
     // Get video data
     $videoData = $this->_getVideos($params, $group->id);
     $videos = $videoData['data'];
     $totalVideos = $videoData['total'];
     $tmpl = new CTemplate();
     $isMine = $my->id == $group->ownerid;
     $isSuperAdmin = COwnerHelper::isCommunityAdmin();
     if ($group->approvals == '1' && !$isMine && !$isMember && !$isSuperAdmin) {
         $this->addWarning(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE'));
     }
     $eventsModel = CFactory::getModel('Events');
     $tmpEvents = $eventsModel->getGroupEvents($group->id, $params->get('grouprecentevents', GROUP_EVENT_RECENT_LIMIT));
     $totalEvents = $eventsModel->getTotalGroupEvents($group->id);
     $events = array();
     foreach ($tmpEvents as $event) {
         $table = JTable::getInstance('Event', 'CTable');
         $table->bind($event);
         $events[] = $table;
     }
     $allowCreateEvent = CGroupHelper::allowCreateEvent($my->id, $group->id);
     if ($group->approvals == '0' || $isMine || $isMember && !$isBanned || $isSuperAdmin) {
         // Set feed url
         $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewbulletins&groupid=' . $group->id . '&format=feed');
         $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_BULLETIN_FEEDS') . '" href="' . $feedLink . '"/>';
         $document->addCustomTag($feed);
         $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id . '&format=feed');
         $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_DISCUSSION_FEEDS') . '" href="' . $feedLink . '"/>';
         $document->addCustomTag($feed);
         $feedLink = CRoute::_('index.php?option=com_community&view=photos&groupid=' . $group->id . '&format=feed');
         $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_PHOTOS_FEEDS') . '" href="' . $feedLink . '"/>';
         $document->addCustomTag($feed);
         $feedLink = CRoute::_('index.php?option=com_community&view=videos&groupid=' . $group->id . '&format=feed');
         $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_VIDEOS_FEEDS') . '"  href="' . $feedLink . '"/>';
         $document->addCustomTag($feed);
         $feedLink = CRoute::_('index.php?option=com_community&view=events&groupid=' . $group->id . '&format=feed');
         $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_EVENTS_FEEDS') . '"  href="' . $feedLink . '"/>';
         $document->addCustomTag($feed);
     }
     // Upgrade wall to stream @since 2.5
     if (!$params->get('stream', FALSE)) {
         $group->upgradeWallToStream();
     }
     $group->coverPostion = $params->get('coverPosition', '');
     $group->defaultCover = empty($group->cover) ? true : false;
     if (strpos($group->coverPostion, '%') === false) {
         $group->coverPostion = 0;
     }
     // Add custom stream
     $activities = new CActivities();
     $streamHTML = $activities->getOlderStream(1000000000, 'active-group', $group->id);
     $totalStream = $activityModel->getTotalActivities(array("`groupid` = '{$group->id}'"));
     $creators = array();
     $creators[] = CUserStatusCreator::getMessageInstance();
     if (($isAdmin || $isSuperAdmin) && $params->get('photopermission') == 1 || ($isMember || $isSuperAdmin) && $params->get('photopermission') == 2 || $isSuperAdmin) {
         $creators[] = CUserStatusCreator::getPhotoInstance();
     }
     if (($isAdmin || $isSuperAdmin) && $params->get('videopermission') == 1 || ($isMember || $isSuperAdmin) && $params->get('videopermission') == 2 || $isSuperAdmin) {
         $creators[] = CUserStatusCreator::getVideoInstance();
     }
     if (($allowCreateEvent || $isSuperAdmin) && $config->get('group_events') && $config->get('enableevents') && $config->get('createevents') || $isSuperAdmin) {
         $creators[] = CUserStatusCreator::getEventInstance();
     }
     $status = new CUserStatus($group->id, 'groups', $creators);
     // Get Event Admins
     $groupAdmins = $group->getAdmins(12, CC_RANDOMIZE);
     $adminsInArray = array();
     // Attach avatar of the admin
     for ($i = 0; $i < count($groupAdmins); $i++) {
         $row = $groupAdmins[$i];
         $admin = CFactory::getUser($row->id);
         array_push($adminsInArray, '<a href="' . CUrlHelper::userLink($admin->id) . '">' . $admin->getDisplayName() . '</a>');
     }
     $totalPhotos = 0;
     foreach ($albums as $album) {
         $albumParams = new CParameter($album->params);
         $totalPhotos = $totalPhotos + $albumParams->get('count');
     }
     $adminsList = ltrim(implode(', ', $adminsInArray), ',');
     $showMoreActivity = $totalStream <= $config->get('maxactivities') ? false : true;
     $groupsModel = CFactory::getModel('groups');
     $bannedMembers = $groupsModel->getBannedMembers($group->id);
     /* Opengraph */
     CHeadHelper::addOpengraph('og:image', $group->getAvatar('avatar'), true);
     CHeadHelper::addOpengraph('og:image', $group->getCover(), true);
     $featured = new CFeatured(FEATURED_GROUPS);
     $featuredList = $featured->getItemIds();
     echo $tmpl->setMetaTags('group', $group)->set('streamHTML', $streamHTML)->set('showMoreActivity', $showMoreActivity)->set('status', $status)->set('events', $events)->set('totalEvents', $totalEvents)->set('showEvents', $config->get('group_events') && $config->get('enableevents') && $params->get('eventpermission', 1) >= 1)->set('showPhotos', $params->get('photopermission') != -1 && $config->get('enablephotos') && $config->get('groupphotos'))->set('showVideos', $params->get('videopermission') != -1 && $config->get('enablevideos') && $config->get('groupvideos'))->set('eventPermission', $params->get('eventpermission'))->set('photoPermission', $params->get('photopermission'))->set('videoPermission', $params->get('videopermission'))->set('allowCreateEvent', $allowCreateEvent)->set('videos', $videos)->set('totalVideos', $totalVideos)->set('albums', $albums)->set('editGroup', $editGroup)->set('waitingApproval', $waitingApproval)->set('config', $config)->set('isMine', $isMine)->set('isAdmin', $isAdmin)->set('isSuperAdmin', $isSuperAdmin)->set('isMember', $isMember)->set('isInvited', $isInvited)->set('friendsCount', $friendsCount)->set('join', $join)->set('unapproved', $unapproved)->set('membersCount', $membersCount)->set('group', $group)->set('totalBulletin', $totalBulletin)->set('totalDiscussion', $totalDiscussion)->set('totalVideos', $totalVideos)->set('members', $approvedMembers)->set('bulletins', $bulletins)->set('discussions', $discussions)->set('discussionsHTML', $discussionsHTML)->set('bulletinsHTML', $bulletinsHTML)->set('isBanned', $isBanned)->set('totalBannedMembers', count($bannedMembers))->set('isPrivate', $group->approvals)->set('limit', $limit)->set('adminsList', $adminsList)->set('isFile', $fileModel->isfileAvailable($group->id, 'group'))->set('alertNewDiscussion', $my->count('group_discussion_' . $group->id) != $totalDiscussion)->set('alertNewBulletin', $my->count('group_bulletin_' . $group->id) != $totalBulletin)->set('alertNewStream', $my->count('group_activity_' . $group->id) != $totalStream)->set('isUserLiked', $isUserLiked)->set('totalLikes', $totalLikes)->set('isLikeEnabled', $isLikeEnabled)->set('totalPhotos', $totalPhotos)->set('totalAlbums', $totalAlbums)->set('profile', $my)->set('featuredList', $featuredList)->fetch('groups/single');
     // Update stream count cache, can only set this after we've set the alert aove
     $my->setCount('group_activity_' . $group->id, $totalStream);
 }