public function ajaxGetOlderActivities($streamid, $filter, $filterId, $filterValue = null) { $response = new JAXResponse(); $config = CFactory::getConfig(); $my = CFactory::getUser(); $html = ''; $activitiesLib = new CActivities(); $html = $activitiesLib->getOlderStream($streamid, $filter, $filterId, $filterValue); $json = array('html' => $html); die(json_encode($json)); }
/** * Return HTML formatted stream for events * @param type $eventid * @deprecated use CActivities directly instead */ public function getStreamHTML($event, $filters = array()) { $activities = new CActivities(); $streamHTML = $activities->getOlderStream(1000000000, 'active-event', $event->id, null, $filters); // $streamHTML = $activities->getAppHTML( // array( // 'app' => CActivities::APP_EVENTS, // 'eventid' => $event->id, // 'apptype' => 'event' // ) // ); return $streamHTML; }
/** * Return HTML formatted stream for groups * @param object $group * @deprecated use activities library instead */ public function getStreamHTML($group, $filters = array()) { $activities = new CActivities(); $streamHTML = $activities->getOlderStream(1000000000, 'active-group', $group->id, null, $filters); // $streamHTML = $activities->getAppHTML( // array( // 'app' => CActivities::APP_GROUPS, // 'groupid' => $group->id, // 'apptype' => 'group' // ) // ); return $streamHTML; }
/** * 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); }