/** * Get Featured Videos * * @return array Objects of random featured videos * @since 1.5 */ public function _getFeatVideos() { $featured = new CFeatured(FEATURED_VIDEOS); $featuredVideos = $featured->getItemIds(); $featuredList = array(); foreach ($featuredVideos as $videoId) { $table = JTable::getInstance('Video', 'CTable'); $table->load($videoId); $table->loadExtra(); $featuredList[] = $table; } return $featuredList; }
/** * Get Featured Videos * * @return array Objects of random featured videos * @since 1.5 */ private function _getFeatVideos() { CFactory::load('libraries', 'featured'); CFactory::load('helpers', 'videos'); $featured = new CFeatured(FEATURED_VIDEOS); $featuredVideos = $featured->getItemIds(); $featuredList = array(); foreach ($featuredVideos as $videoId) { $table =& JTable::getInstance('Video', 'CTable'); $table->load($videoId); $featuredList[] = $table; } return $featuredList; }
/** * Get Featured Videos * * @return array Objects of random featured videos * @since 1.5 */ private function _getFeatVideos() { $featured = new CFeatured(FEATURED_VIDEOS); $featuredVideos = $featured->getItemIds(); $featuredList = array(); foreach ($featuredVideos as $videoId) { $table = JTable::getInstance('Video', 'CTable'); $table->load($videoId); if (empty($table->id)) { continue; } $featuredList[] = $table; } return $featuredList; }
$categories = $model->getAllCategories(); $categoryIds = CCategoryHelper::getCategoryChilds($categories, $category->id); if (!$eventType) { //upcoming events $result = $model->getEvents($categoryIds, $userid, $sorted, null, true, false, null, array('parent' => $eventparent), CEventHelper::ALL_TYPES, 0, $limit, $upcomingOnly, false); } else { //my event if (!$userid) { //if no id is provided and this is user type, the result should be empty $result = array(); } else { $result = $model->getEvents(null, $userid, $sorted); } } $events = array(); $featuredOnly = $params->get('filter_by', 0); if ($featuredOnly) { //1 = featured only $featured = new CFeatured(FEATURED_EVENTS); $featuredEvents = $featured->getItemIds(); } foreach ($result as $row) { if ($featuredOnly && !in_array($row->id, $featuredEvents)) { //if we only show featured item, and the item does not exists. continue; } $event = JTable::getInstance('Event', 'CTable'); $event->bind($row); $events[] = $event; } require JModuleHelper::getLayoutPath('mod_community_events', $params->get('layout', 'default'));
/** * Display a list of pending friend requests * */ public function pending($data = null) { if (!$this->accessAllowed('registered')) { return; } $mainframe = JFactory::getApplication(); $config = CFactory::getConfig(); CWindow::load(); $my = CFactory::getUser(); if ($my->id == 0) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_PLEASE_LOGIN_WARNING'), 'error'); return; } // Set pathway $this->addPathway(JText::_('COM_COMMUNITY_FRIENDS'), CRoute::_('index.php?option=com_community&view=friends')); $this->addPathway(JText::_('COM_COMMUNITY_FRIENDS_AWAITING_AUTHORIZATION'), ''); /** * Opengraph */ CHeadHelper::setType('website', JText::_('COM_COMMUNITY_FRIENDS_AWAITING_AUTHORIZATION')); // Load submenu //$this->showSubMenu(); $rows = !empty($data->pending) ? $data->pending : array(); for ($i = 0; $i < count($rows); $i++) { $row = $rows[$i]; $row->user = CFactory::getUser($row->id); $row->user->friendsCount = $row->user->getFriendCount(); $row->user->profileLink = CUrlHelper::userLink($row->id); $row->msg = $this->escape($row->msg); } //Featured $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); $tmpl = new CTemplate(); echo $tmpl->set('rows', $rows)->setRef('my', $my)->set('config', $config)->set('pagination', $data->pagination)->set('submenu', $this->showSubmenu(false))->set('featuredList', $featuredList)->fetch('friends/request-received'); }
public function _getEventsFeaturedList() { CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_EVENTS); $featuredEvents = $featured->getItemIds(); $featuredList = array(); foreach ($featuredEvents as $event) { $table =& JTable::getInstance('Event', 'CTable'); $table->load($event); $featuredList[] = $table; } return $featuredList; }
/** * //@todo Use usort to sort the data when PHP 5.3 is the minimal requirement * Sort album key based on the key data comparison given * @param $albums * @param string $sort * @return array */ private function sortAlbums($albums, $sort = 'date') { $data = array(); foreach ($albums as $row) { $album = JTable::getInstance('Album', 'CTable'); $album->bind($row); $album->thumbnail = $album->getCoverThumbPath(); $lastupdated = new DateTime($album->lastupdated); //sorting happens here switch ($sort) { case 'hit': //$key = $this->getNextUniqueAlbumKey($album->hits,$data); $data[] = $album; break; case 'name': if (array_key_exists($album->name, $data)) { $data[strtolower($album->name) . (strtotime("now") + rand('1', '100000'))] = $album; } else { $data[strtolower($album->name) . strtotime("now")] = $album; } break; case 'featured_only': $featured = new CFeatured(FEATURED_ALBUMS); $featuredAlbums = $featured->getItemIds(); foreach ($featuredAlbums as $featuredAlbum) { if ($album->id == $featuredAlbum) { $data[] = $album; } } break; case 'featured': $data[] = $album; break; /* removed in 4.0 very heavy to filter case 'like' : $like = new CLike(); $totalLikes = $like->getLikeCount('album', $album->id); $key = $this->getNextUniqueAlbumKey($totalLikes,$data); $data[$key] = $album; break; case 'comment'; $totalComments = CWallLibrary::getWallCount('albums',$album->id); $key = $this->getNextUniqueAlbumKey($totalComments,$data); $data[$key] = $album; break; */ /* removed in 4.0 very heavy to filter case 'like' : $like = new CLike(); $totalLikes = $like->getLikeCount('album', $album->id); $key = $this->getNextUniqueAlbumKey($totalLikes,$data); $data[$key] = $album; break; case 'comment'; $totalComments = CWallLibrary::getWallCount('albums',$album->id); $key = $this->getNextUniqueAlbumKey($totalComments,$data); $data[$key] = $album; break; */ default: //date $key = $this->getNextUniqueAlbumKey($lastupdated->format('U'), $data); $data[$key] = $album; } } //sort by the key if ($sort != 'featured') { krsort($data); } if ($sort == 'name' || $sort == 'hit') { $data = array_reverse($data); } return $data; }
* @url https://www.jomsocial.com/license-agreement * The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0 * More info at https://www.jomsocial.com/license-agreement */ defined('_JEXEC') or die; $isMine = COwnerHelper::isMine($my->id, $user->id); $avatar = $user->getAvatarInfo(); $loggedIn = $my->id != 0; $profileFields = ''; $themeModel = CFactory::getModel('theme'); $profileModel = CFactory::getModel('profile'); $settings = $themeModel->getSettings('profile'); $my = CFactory::getUser($profile->id); $config = CFactory::getConfig(); $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); if (isset($settings['profile']['tagline']) && strlen($settings['profile']['tagline'])) { $blocks = json_decode($settings['profile']['tagline'], true); $blockEnabled = true; foreach ($blocks as $block) { $blockString = ""; if ($block['spacebefore']) { $blockString .= " "; } if (strlen($block['before'])) { $blockString .= JText::_($block['before']) . " "; } if (strlen($block['field'])) { if (isset($profile->fieldsById->{$block['field']}) && strlen($profile->fieldsById->{$block['field']}->value)) { # var_dump($profile->fieldsById->{$block['field']}); $blockString .= $themeModel->formatField($profile->fieldsById->{$block['field']});
public function display($tpl = null) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $id = $jinput->get('listid', '', 'INT'); //JRequest::getVar( 'listid' , '' ); $list = JTable::getInstance('MemberList', 'CTable'); $list->load($id); if (empty($list->id) || is_null($list->id)) { echo JText::_('COM_COMMUNITY_INVALID_ID'); return; } /** * Opengraph */ CHeadHelper::setType('website', $list->getTitle()); $tmpCriterias = $list->getCriterias(); $criterias = array(); foreach ($tmpCriterias as $criteria) { $obj = new stdClass(); $obj->field = $criteria->field; $obj->condition = $criteria->condition; $obj->fieldType = $criteria->type; switch ($criteria->type) { case 'date': case 'birthdate': if ($criteria->condition == 'between') { $date = explode(',', $criteria->value); if (isset($date[1])) { $delimeter = '-'; if (strpos($date[0], '/')) { $delimeter = '/'; } $startDate = explode($delimeter, $date[0]); $endDate = explode($delimeter, $date[1]); if (isset($startDate[2]) && isset($endDate[2])) { //date format $obj->value = array($startDate[2] . '-' . intval($startDate[1]) . '-' . $startDate[0] . ' 00:00:00', $endDate[2] . '-' . intval($endDate[1]) . '-' . $endDate[0] . ' 23:59:59'); } else { //age format $obj->value = array($date[0], $date[1]); } } else { //wrong data, set to default $obj->value = array(0, 0); } } else { $delimeter = '-'; if (strpos($criteria->value, '/')) { $delimeter = '/'; } $startDate = explode($delimeter, $criteria->value); if (isset($startDate[2])) { //date format $obj->value = $startDate[2] . '-' . intval($startDate[1]) . '-' . $startDate[0] . ' 00:00:00'; } else { //age format $obj->value = $criteria->value; } } break; case 'checkbox': default: $obj->value = $criteria->value; break; } $criterias[] = $obj; } //CFactory::load( 'helpers' , 'time'); $created = CTimeHelper::getDate($list->created); //CFactory::load( 'libraries' , 'advancesearch' ); //CFactory::load( 'libraries' , 'filterbar' ); $sortItems = array('latest' => JText::_('COM_COMMUNITY_SORT_LATEST'), 'online' => JText::_('COM_COMMUNITY_SORT_ONLINE'), 'alphabetical' => JText::_('COM_COMMUNITY_SORT_ALPHABETICAL')); $sorting = $jinput->get->get('sort', 'latest', 'STRING'); //JRequest::getVar( 'sort' , 'latest' , 'GET' ); $data = CAdvanceSearch::getResult($criterias, $list->condition, $list->avataronly, $sorting); $tmpl = new CTemplate(); $html = $tmpl->set('list', $list)->set('created', $created)->set('sorting', CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest'))->fetch('memberlist.result'); unset($tmpl); //CFactory::load( 'libraries' , 'tooltip' ); //CFactory::load( 'helpers' , 'owner' ); //CFactory::load( 'libraries' , 'featured' ); $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); $my = CFactory::getUser(); $resultRows = array(); $friendsModel = CFactory::getModel('friends'); $alreadyfriend = array(); //CFactory::load( 'helpers' , 'friends' ); foreach ($data->result as $user) { $obj = new stdClass(); $obj->user = $user; $obj->friendsCount = $user->getFriendCount(); $obj->profileLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id); $isFriend = CFriendsHelper::isConnected($user->id, $my->id); $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $user->id ? true : false; //record friends if ($obj->addFriend) { $alreadyfriend[$user->id] = $user->id; } $resultRows[] = $obj; } $tmpl = new CTemplate(); echo $tmpl->set('data', $resultRows)->set('alreadyfriend', $alreadyfriend)->set('sortings', '')->set('pagination', $data->pagination)->set('filter', '')->set('featuredList', $featuredList)->set('my', $my)->set('showFeaturedList', false)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->fetch('people.browse'); }
public function ajaxGetFeaturedVideos($limit) { $filter = JFilterInput::getInstance(); $limit = $filter->clean($limit, 'int'); $limit = max(0, $limit); $my = CFactory::getUser(); $permissions = $my->id == 0 ? 10 : 20; $permissions = COwnerHelper::isCommunityAdmin() ? 40 : $permissions; //CFactory::load( 'libraries', 'featured' ); $featured = new CFeatured(FEATURED_VIDEOS); $featuredVideos = $featured->getItemIds(); if (!empty($featuredVideos)) { $videoId = array(); foreach ($featuredVideos as $featuredVideo) { $videoId[] = $featuredVideo; } $objResponse = new JAXResponse(); $oversampledTotal = $limit * COMMUNITY_OVERSAMPLING_FACTOR; $model = CFactory::getModel('videos'); $filter = array('id' => $videoId, 'status' => 'ready', 'permissions' => $permissions, 'sorting' => 'latest', 'limit' => $oversampledTotal); $featuredVideos = $model->getVideos($filter, true); if (!empty($featuredVideos)) { shuffle($featuredVideos); $maxLatestCount = count($featuredVideos) > $limit ? $limit : count($featuredVideos); $html = $this->prepareVideosData($featuredVideos, $maxLatestCount, $objResponse); } else { $html = JText::_('COM_COMMUNITY_VIDEOS_NO_FEATURED_VIDEOS_YET'); } } else { $html = JText::_('COM_COMMUNITY_VIDEOS_NO_FEATURED_VIDEOS_YET'); } $json = array('success' => true, 'html' => $html); die(json_encode($json)); }
function _getGroupsHTML($tmpGroups, $tmpPagination = NULL) { $tmpl = new CTemplate(); CFactory::load('helpers', 'owner'); CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_GROUPS); $featuredList = $featured->getItemIds(); $task = JRequest::getVar('task', '', 'GET'); $showFeatured = empty($task) ? true : false; $groups = array(); CFactory::load('models', 'groups'); if ($tmpGroups) { foreach ($tmpGroups as $row) { $group =& JTable::getInstance('Group', 'CTable'); $group->load($row->id); $groups[] = $group; } unset($tmpGroups); } $tmpl->set('showFeatured', $showFeatured); $tmpl->set('featuredList', $featuredList); $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin()); $tmpl->set('groups', $groups); $tmpl->set('pagination', $tmpPagination); $groupsHTML = $tmpl->fetch('groups.list'); unset($tmpl); return $groupsHTML; }
/** * Search list of friends * * if no $_GET['id'] is set, we're viewing our own friends */ public function friendsearch($data) { //return $this->search($data); require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'profile.php'; require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'friends.php'; $document = JFactory::getDocument(); $document->setTitle(JText::_('COM_COMMUNITY_SEARCH_FRIENDS_TITLE')); $avatarOnly = JRequest::getVar('avatar', ''); $this->addPathway(JText::_('COM_COMMUNITY_SEARCH_FRIENDS_TITLE')); $my = CFactory::getUser(); $friendsModel = CFactory::getModel('friends'); $resultRows = array(); $id = JRequest::getInt('userid', null); if ($id == null) { $id = $my->id; } $user = CFactory::getUser($id); $isMine = $id == $my->id && $my->id != 0; $pagination = !empty($data) ? $data->pagination : ''; $tmpl = new CTemplate(); for ($i = 0; $i < count($data->result); $i++) { $row =& $data->result[$i]; $user = CFactory::getUser($row->id); $row->profileLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->id); $row->friendsCount = $user->getFriendCount(); $isFriend = CFriendsHelper::isConnected($row->id, $my->id); $row->user = $user; $row->addFriend = !$isFriend && $my->id != 0 && $my->id != $row->id ? true : false; $resultRows[] = $row; } $tmpl->set('data', $resultRows); $tmpl->set('sortings', ''); $tmpl->set('pagination', $pagination); CFactory::load('libraries', 'tooltip'); //JHTML::_('behavior.tooltip'); CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); $tmpl->set('featuredList', $featuredList); CFactory::load('helpers', 'owner'); $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin()); $tmpl->set('showFeaturedList', false); $tmpl->set('my', $my); $resultHTML = $tmpl->fetch('people.browse'); unset($tmpl); $searchLinks = parent::getAppSearchLinks('people'); if ($isMine) { $this->showSubmenu(); $document->setTitle(JText::_('COM_COMMUNITY_FRIENDS_MY_FRIENDS')); } else { $this->addSubmenuItem('index.php?option=com_community&view=profile&userid=' . $user->id, JText::_('COM_COMMUNITY_PROFILE_BACK_TO_PROFILE')); $this->addSubmenuItem('index.php?option=com_community&view=friends&userid=' . $user->id, JText::_('COM_COMMUNITY_FRIENDS_VIEW_ALL')); $this->addSubmenuItem('index.php?option=com_community&view=friends&task=mutualFriends&userid=' . $user->id . '&filter=mutual', JText::_('COM_COMMUNITY_MUTUAL_FRIENDS')); $tmpl = new CTemplate(); $tmpl->set('view', "friends"); $tmpl->set('url', CRoute::_('index.php?option=com_community&view=friends&task=viewfriends')); $html = $tmpl->fetch('friendsearch.submenu'); $this->addSubmenuItem('index.php?option=com_community&view=friends&task=viewfriends', JText::_('COM_COMMUNITY_SEARCH_FRIENDS'), 'joms.videos.toggleSearchSubmenu(this)', SUBMENU_LEFT, $html); parent::showSubmenu(); $document->setTitle(JText::sprintf('COM_COMMUNITY_FRIENDS_ALL_FRIENDS', $user->getDisplayName())); } $tmpl = new CTemplate(); $tmpl->set('avatarOnly', $avatarOnly); $tmpl->set('results', $data->result); $tmpl->set('resultHTML', $resultHTML); $tmpl->set('query', $data->query); $tmpl->set('searchLinks', $searchLinks); echo $tmpl->fetch('friendsearch'); }
public function display() { $id = JRequest::getVar('listid', ''); $list =& JTable::getInstance('MemberList', 'CTable'); $list->load($id); if (empty($list->id) || is_null($list->id)) { echo JText::_('CC INVALID ID'); return; } $document =& JFactory::getDocument(); $document->setTitle($list->getTitle()); $tmpCriterias = $list->getCriterias(); $criterias = array(); foreach ($list->getCriterias() as $criteria) { $obj = new stdClass(); $obj->field = $criteria->field; $obj->condition = $criteria->condition; $obj->fieldType = $criteria->type; switch ($criteria->type) { case 'date': if ($criteria->condition == 'between') { $date = explode(',', $criteria->value); $startDate = explode('/', $date[0]); $endDate = explode('/', $date[1]); $obj->value = array($startDate[2] . '-' . intval($startDate[1]) . '-' . $startDate[0] . ' 00:00:00', $endDate[2] . '-' . intval($endDate[1]) . '-' . $endDate[0] . ' 23:59:59'); } else { $startDate = explode('/', $criteria->value); $obj->value = $startDate[2] . '-' . intval($startDate[1]) . '-' . $startDate[0] . ' 00:00:00'; } break; case 'checkbox': default: $obj->value = $criteria->value; break; } $criterias[] = $obj; } CFactory::load('helpers', 'time'); $created = CTimeHelper::getDate($list->created); CFactory::load('libraries', 'advancesearch'); CFactory::load('libraries', 'filterbar'); $sortItems = array('latest' => JText::_('CC SORT LATEST'), 'online' => JText::_('CC SORT ONLINE'), 'alphabetical' => JText::_('CC SORT ALPHABETICAL')); $sorting = JRequest::getVar('sort', 'latest', 'GET'); $data = CAdvanceSearch::getResult($criterias, $list->condition, $list->avataronly, $sorting); $tmpl = new CTemplate(); $tmpl->set('list', $list); $tmpl->set('created', $created); $tmpl->set('sorting', CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest')); $html = $tmpl->fetch('memberlist.result'); unset($tmpl); CFactory::load('libraries', 'tooltip'); CFactory::load('helpers', 'owner'); CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); $my = CFactory::getUser(); $resultRows = array(); $friendsModel = CFactory::getModel('friends'); CFactory::load('helpers', 'friends'); foreach ($data->result as $user) { $obj = new stdClass(); $obj->user = $user; $obj->friendsCount = $user->getFriendCount(); $obj->profileLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id); $isFriend = CFriendsHelper::isConnected($user->id, $my->id); $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $user->id ? true : false; $resultRows[] = $obj; } $tmpl = new CTemplate(); $tmpl->set('data', $resultRows); $tmpl->set('sortings', ''); $tmpl->set('pagination', $data->pagination); $tmpl->set('filter', ''); $tmpl->set('featuredList', $featuredList); $tmpl->set('my', $my); $tmpl->set('showFeaturedList', false); $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin()); $html .= $tmpl->fetch('people.browse'); echo $html; }
function advanceSearch() { CFactory::load('libraries', 'advancesearch'); CFactory::load('libraries', 'messaging'); CFactory::load('helpers', 'friends'); CFactory::load('helpers', 'owner'); $document =& JFactory::getDocument(); $document->addStyleSheet("includes/js/calendar/calendar-mos.css"); $document->addScript("includes/js/joomla.javascript.js"); $document->addScript("includes/js/calendar/calendar_mini.js"); $document->addScript("includes/js/calendar/lang/calendar-en-GB.js"); $document->setTitle(JText::_('CC TITLE CUSTOM SEARCH')); $this->showSubMenu(); $this->addPathway(JText::_('CC TITLE CUSTOM SEARCH')); $my = CFactory::getUser(); $config = CFactory::getConfig(); $result = null; $fields = CAdvanceSearch::getFields(); $data = new stdClass(); $post = JRequest::get('GET'); $keyList = isset($post['key-list']) ? $post['key-list'] : ''; $avatarOnly = JRequest::getVar('avatar', ''); if (JString::strlen($keyList) > 0) { //formatting the assoc array $filter = array(); $key = explode(',', $keyList); $joinOperator = $post['operator']; foreach ($key as $idx) { $obj = new stdClass(); $obj->field = $post['field' . $idx]; $obj->condition = $post['condition' . $idx]; $obj->fieldType = $post['fieldType' . $idx]; if ($obj->fieldType == 'email') { $obj->condition = 'equal'; } // we need to check whether the value contain start and end kind of values. // if yes, make them an array. if (isset($post['value' . $idx . '_2'])) { if ($obj->fieldType == 'date') { $startDate = empty($post['value' . $idx]) ? '01/01/1970' : $post['value' . $idx]; $endDate = empty($post['value' . $idx . '_2']) ? '01/01/1970' : $post['value' . $idx . '_2']; $sdate = explode('/', $startDate); $edate = explode('/', $endDate); $obj->value = array($sdate[2] . '-' . intval($sdate[1]) . '-' . $sdate[0] . ' 00:00:00', $edate[2] . '-' . intval($edate[1]) . '-' . $edate[0] . ' 23:59:59'); } else { $obj->value = array($post['value' . $idx], $post['value' . $idx . '_2']); } } else { if ($obj->fieldType == 'date') { $startDate = empty($post['value' . $idx]) ? '01/01/1970' : $post['value' . $idx]; $sdate = explode('/', $startDate); $obj->value = $sdate[2] . '-' . intval($sdate[1]) . '-' . $sdate[0] . ' 00:00:00'; } else { if ($obj->fieldType == 'checkbox') { if (empty($post['value' . $idx])) { //this mean user didnot check any of the option. $obj->value = ''; } else { $obj->value = isset($post['value' . $idx]) ? implode(',', $post['value' . $idx]) : ''; } } else { $obj->value = isset($post['value' . $idx]) ? $post['value' . $idx] : ''; } } } $filter[] = $obj; } $data->search = CAdvanceSearch::getResult($filter, $joinOperator, $avatarOnly); $data->filter = $post; } $rows = !empty($data->search) ? $data->search->result : array(); $pagination = !empty($data->search) ? $data->search->pagination : ''; $filter = !empty($data->filter) ? $data->filter : array(); $resultRows = array(); $friendsModel = CFactory::getModel('friends'); for ($i = 0; $i < count($rows); $i++) { $row =& $rows[$i]; $obj = new stdClass(); $obj->user =& $row; $obj->friendsCount = $row->getFriendCount(); $obj->profileLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->id); $isFriend = CFriendsHelper::isConnected($row->id, $my->id); $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $row->id ? true : false; $resultRows[] = $obj; } if (class_exists('Services_JSON')) { $json = new Services_JSON(); } else { require_once JPATH_ROOT . DS . 'plugins' . DS . 'system' . DS . 'pc_includes' . DS . 'JSON.php'; $json = new Services_JSON(); } $tmpl = new CTemplate(); $tmpl->set('fields', $fields); $tmpl->set('keyList', $keyList); $tmpl->set('avatarOnly', $avatarOnly); $tmpl->set('filterJson', $json->encode($filter)); $tmpl->set('postresult', isset($post['key-list'])); $searchForm = $tmpl->fetch('search.advancesearch'); if (isset($post['key-list'])) { //result template $tmplResult = new CTemplate(); $tmplResult->set('data', $resultRows); $tmplResult->set('sortings', ''); $tmplResult->set('pagination', $pagination); $tmplResult->set('filter', $filter); CFactory::load('libraries', 'tooltip'); CFactory::load('helpers', 'owner'); //JHTML::_('behavior.tooltip'); CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); $tmpl->set('featuredList', $featuredList); $tmplResult->set('my', $my); $tmplResult->set('showFeaturedList', false); $tmplResult->set('featuredList', $featuredList); $tmplResult->set('featuredList', $featuredList); $tmplResult->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin()); $searchForm .= $tmplResult->fetch('people.browse'); } echo $searchForm; }
function _getAlbumsHTML($albums, $type = PHOTOS_USER_TYPE, $pagination = NULL) { $my = CFactory::getUser(); $groupId = JRequest::getVar('groupid', '', 'REQUEST'); $tmpl = new CTemplate(); CFactory::load('libraries', 'activities'); CFactory::load('models', 'groups'); CFactory::load('helpers', 'owner'); for ($i = 0; $i < count($albums); $i++) { $albums[$i]->user = CFactory::getUser($albums[$i]->creator); $albums[$i]->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}"); $albums[$i]->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}"); $albums[$i]->uploadLink = CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}"); $albums[$i]->isOwner = $my->id == $albums[$i]->creator; if ($type == PHOTOS_GROUP_TYPE) { $group =& JTable::getInstance('Group', 'CTable'); $group->load($groupId); $albums[$i]->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}"); $albums[$i]->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}"); $albums[$i]->uploadLink = CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}"); $params = $group->getParams(); $photopermission = $params->get('photopermission', GROUP_PHOTO_PERMISSION_ADMINS); if ($photopermission == GROUP_PHOTO_PERMISSION_MEMBERS && $group->isMember($my->id)) { $albums[$i]->isOwner = $my->id == $albums[$i]->creator; } else { if ($photopermission == GROUP_PHOTO_PERMISSION_ADMINS && $group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin()) { $albums[$i]->isOwner = true; } else { $albums[$i]->isOwner = false; } } } // If new albums that has just been created and // does not contain any images, the lastupdated will always be 0000-00-00 00:00:00:00 // Try to use the albums creation date instead. if ($albums[$i]->lastupdated == '0000-00-00 00:00:00' || $albums[$i]->lastupdated == '') { $albums[$i]->lastupdated = $albums[$i]->created; if ($albums[$i]->lastupdated == '' || $albums[$i]->lastupdated == '0000-00-00 00:00:00') { $albums[$i]->lastupdated = JText::_('CC NO LAST ACTIVITY'); } else { $lastUpdated = new JDate($albums[$i]->lastupdated); $albums[$i]->lastupdated = CActivityStream::_createdLapse($lastUpdated); } } else { $lastUpdated = new JDate($albums[$i]->lastupdated); $albums[$i]->lastupdated = CActivityStream::_createdLapse($lastUpdated); } } CFactory::load('helpers', 'owner'); CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_ALBUMS); $featuredList = $featured->getItemIds(); $task = JRequest::getVar('task', '', 'GET'); $showFeatured = empty($task) ? true : false; $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&userid=' . $my->id); if ($type == PHOTOS_GROUP_TYPE) { $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $groupId); CFactory::load('helpers', 'group'); $isOwner = CGroupHelper::allowManagePhoto($groupId); } else { $userId = JRequest::getInt('userid', '', 'REQUEST'); $user = CFactory::getUser($userId); $isOwner = $my->id == $user->id ? true : false; } $task = JRequest::getCmd('task', ''); $tmpl->set('isMember', $my->id != 0); $tmpl->set('isOwner', $isOwner); $tmpl->set('type', $type); $tmpl->set('createLink', $createLink); $tmpl->set('currentTask', $task); $tmpl->set('showFeatured', $showFeatured); $tmpl->set('featuredList', $featuredList); $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin()); $tmpl->set('my', $my); $tmpl->set('albums', $albums); $tmpl->set('pagination', $pagination); $tmpl->set('isSuperAdmin', COwnerHelper::isCommunityAdmin()); return $tmpl->fetch('albums.list'); }
public function _getAlbumsHTML($albums, $type = PHOTOS_USER_TYPE, $pagination = NULL) { $my = CFactory::getUser(); $groupId = JRequest::getVar('groupid', '', 'REQUEST'); $tmpl = new CTemplate(); CFactory::load('libraries', 'activities'); CFactory::load('models', 'groups'); CFactory::load('helpers', 'owner'); $handler = $this->_getHandler(); $photoTag = CFactory::getModel('phototagging'); $photos = array(); foreach ($albums as &$album) { $album->user = CFactory::getUser($album->creator); $album->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$album->id}&userid={$album->creator}"); $album->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$album->id}&userid={$album->creator}&referrer=myphotos"); $album->uploadLink = "javascript:joms.notifications.showUploadPhoto({$album->id});"; //CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$album->id}&userid={$album->creator}"); $album->isOwner = $my->id == $album->creator; // Get all photos from album $photos[$album->id] = $handler->getAlbumPhotos($album->id); $photoCount = count($photos[$album->id]); $tagRecords[$album->id] = array(); // get tag users from photos if ($photoCount > 0) { for ($i = 0; $i < $photoCount; $i++) { $tempTagRecords = $photoTag->getTaggedList($photos[$album->id][$i]->id); if (count($tempTagRecords) > 0) { $tagRecords[$album->id][] = $tempTagRecords; } } } if ($type == PHOTOS_GROUP_TYPE) { $album->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$album->id}&groupid={$album->groupid}"); $album->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$album->id}&groupid={$album->groupid}&referrer=myphotos"); $album->uploadLink = CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$album->id}&groupid={$album->groupid}"); $albums[$i]->isOwner = $my->authorise('community.view', 'photos.group.album.' . $groupId, $albums[$i]); } // If new albums that has just been created and // does not contain any images, the lastupdated will always be 0000-00-00 00:00:00:00 // Try to use the albums creation date instead. if ($album->lastupdated == '0000-00-00 00:00:00' || $album->lastupdated == '') { $album->lastupdated = $album->created; if ($album->lastupdated == '' || $album->lastupdated == '0000-00-00 00:00:00') { $album->lastupdated = JText::_('COM_COMMUNITY_PHOTOS_NO_ACTIVITY'); } else { $lastUpdated = new JDate($album->lastupdated); $album->lastupdated = CActivityStream::_createdLapse($lastUpdated, false); } } else { $lastUpdated = new JDate($album->lastupdated); $album->lastupdated = CActivityStream::_createdLapse($lastUpdated, false); } } CFactory::load('helpers', 'owner'); $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&userid=' . $my->id); if ($type == PHOTOS_GROUP_TYPE) { $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $groupId); CFactory::load('helpers', 'group'); $isOwner = CGroupHelper::allowManagePhoto($groupId); } else { $userId = JRequest::getInt('userid', '', 'REQUEST'); $user = CFactory::getUser($userId); $isOwner = $my->id == $user->id ? true : false; } CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_ALBUMS); $featuredList = $featured->getItemIds(); $task = JRequest::getCmd('task', ''); return $tmpl->set('isMember', $my->id != 0)->set('isOwner', $isOwner)->set('type', $type)->set('createLink', $createLink)->set('currentTask', $task)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('my', $my)->set('albums', $albums)->set('pagination', $pagination)->set('isSuperAdmin', COwnerHelper::isCommunityAdmin())->set('featuredList', $featuredList)->fetch('albums.list'); }
public function _getEventsFeaturedList() { //CFactory::load( 'libraries' , 'featured' ); $featured = new CFeatured(FEATURED_EVENTS); $featuredEvents = $featured->getItemIds(); $featuredList = array(); $now = new JDate(); foreach ($featuredEvents as $event) { $table = JTable::getInstance('Event', 'CTable'); $table->load($event); $expiry = new JDate($table->enddate); if ($expiry->toUnix() >= $now->toUnix()) { if ($table->id != '') { $featuredList[] = $table; } } } if (!empty($featuredList)) { foreach ($featuredList as $key => $row) { $orderByDate[$key] = strtotime($row->startdate); } array_multisort($orderByDate, SORT_ASC, $featuredList); } return $featuredList; }
/** * @param int $limit * get members and order by featured first */ public function getFeaturedMember($limit = 15) { if ($limit == 0) { return array(); } $limit = $limit < 0 ? 0 : $limit; $db = $this->getDBO(); $featured = new CFeatured(FEATURED_USERS); $featuredUsers = implode(',', $featured->getItemIds()); $order = ' ORDER BY ' . $db->quoteName('id'); if (!$featuredUsers || count($featuredUsers) == 0) { return array(); } $filterquery = ''; $config = CFactory::getConfig(); if (!$config->get('privacy_show_admins')) { $userModel = CFactory::getModel('User'); $tmpAdmins = $userModel->getSuperAdmins(); $admins = array(); $filterquery .= ' AND ' . $db->quoteName('id') . ' NOT IN('; for ($i = 0; $i < count($tmpAdmins); $i++) { $admin = $tmpAdmins[$i]; $filterquery .= $db->Quote($admin->id); $filterquery .= $i < count($tmpAdmins) - 1 ? ',' : ''; } $filterquery .= ')'; } $query = 'SELECT * FROM ' . $db->quoteName('#__users') . ' ' . ' WHERE ' . $db->quoteName('block') . '=' . $db->Quote(0) . ' ' . $filterquery . ' AND id IN (' . $featuredUsers . ') ' . ' LIMIT ' . $limit; $db->setQuery($query); $result = $db->loadObjectList(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } $latestMembers = array(); $uids = array(); foreach ($result as $m) { $uids[] = $m->id; } CFactory::loadUsers($uids); foreach ($result as $row) { $latestMembers[] = CFactory::getUser($row->id); } return $latestMembers; }
public function _getGroupsHTML($tmpGroups, $tmpPagination = NULL) { $config = CFactory::getConfig(); $tmpl = new CTemplate(); CFactory::load('helpers', 'owner'); CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_GROUPS); $featuredList = $featured->getItemIds(); $groups = array(); if ($tmpGroups) { foreach ($tmpGroups as $row) { $group =& JTable::getInstance('Group', 'CTable'); $group->bind($row); $group->updateStats(); //ensure that stats are up-to-date $group->description = CStringHelper::clean(CStringHelper::truncate($group->description, $config->get('tips_desc_length'))); $groups[] = $group; } unset($tmpGroups); } $groupsHTML = $tmpl->set('showFeatured', $config->get('show_featured'))->set('featuredList', $featuredList)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('groups', $groups)->set('pagination', $tmpPagination)->fetch('groups.list'); unset($tmpl); return $groupsHTML; }
/** * Loads the videos * * @public * @param array $filters The video's filter * @return array An array of videos object * @since 1.2 */ public function getVideos($filters = array(), $tableBind = false, $limitSetting = true, $useCache = true, $pagination = true) { /* use caching */ if ($useCache) { $cache = CFactory::getFastCache(); $cacheid = serialize(func_get_args()) . serialize(JRequest::get()); if ($data = $cache->get($cacheid)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination($data['total'], $data['limitstart'], $data['limit']); return $data['entries']; } } $db = $this->getDBO(); $where = array(); $limiter = ''; $defaultFilters = array('published' => 1); $filters = array_merge($defaultFilters, $filters); foreach ($filters as $field => $value) { if ($value || $value === 0) { switch (strtolower($field)) { case 'id': if (is_array($value)) { JArrayHelper::toInteger($value); $value = implode(',', $value); } $where[] = 'v.' . $db->quoteName('id') . ' IN (' . $value . ')'; break; case 'title': $where[] = 'v.' . $db->quoteName('title') . ' LIKE ' . $db->quote('%' . $value . '%'); break; case 'type': $where[] = 'v.' . $db->quoteName('type') . ' = ' . $db->quote($value); break; case 'description': $where[] = 'v.' . $db->quoteName('description') . ' LIKE ' . $db->quote('%' . $value . '%'); break; case 'creator': $where[] = 'v.' . $db->quoteName('creator') . ' = ' . $db->quote((int) $value); break; case 'creator_type': $where[] = 'v.' . $db->quoteName('creator_type') . ' = ' . $db->quote($value); break; case 'created': $value = JFactory::getDate($value)->toSql(); $where[] = 'v.' . $db->quoteName('created') . ' BETWEEN ' . $db->quote('1970-01-01 00:00:01') . ' AND ' . $db->quote($value); break; case 'permissions': if (isset($filters['friendsvideos']) && $filters['friendsvideos']) { $my = CFactory::getUser(); $extrasql = ''; if ($my->id != 0) { if (empty($filters['groupid'])) { $friendmodel = CFactory::getModel('friends'); $friends = $friendmodel->getFriendIds($my->id); if (!empty($friends)) { $extrasql .= ' OR (creator IN(' . implode(',', $friends) . ') AND permissions = ' . $db->Quote(30) . ') '; } } } $where[] = '( v.' . $db->quoteName('permissions') . ' <= ' . $db->quote((int) $value) . ' ' . $extrasql . ' OR ( creator=' . $db->Quote($my->id) . ' AND permissions <=' . $db->Quote(40) . ' ) )'; } else { $where[] = 'v.' . $db->quoteName('permissions') . ' <= ' . $db->quote((int) $value); } break; case 'category_id': if (is_array($value)) { JArrayHelper::toInteger($value); $value = implode(',', $value); } if ($value != 0) { $where[] = 'v.' . $db->quoteName('category_id') . ' IN (' . $value . ')'; } break; case 'hits': $where[] = 'v.' . $db->quoteName('hits') . ' >= ' . $db->quote((int) $value); break; case 'published': $where[] = 'v.' . $db->quoteName('published') . ' = ' . $db->quote((bool) $value); break; case 'featured': $where[] = 'v.' . $db->quoteName('featured') . ' = ' . $db->quote((bool) $value); break; case 'duration': $where[] = 'v.' . $db->quoteName('duration') . ' >= ' . $db->quote((int) $value); break; case 'status': $where[] = 'v.' . $db->quoteName('status') . ' = ' . $db->quote($value); break; case 'groupid': $where[] = 'v.' . $db->quoteName('groupid') . ' = ' . $db->quote($value); break; case 'eventid': $where[] = 'v.' . $db->quoteName('eventid') . ' = ' . $db->quote($value); break; case 'limitstart': $limitstart = (int) $value; break; case 'limit': $limit = (int) $value; break; } } } $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : ''; // Joint with group table $join = ''; if (isset($filters['or_group_privacy'])) { $approvals = (int) $filters['or_group_privacy']; $join = ' LEFT JOIN ' . $db->quoteName('#__community_groups') . ' AS g'; $join .= ' ON g.' . $db->quoteName('id') . ' = v.' . $db->quoteName('groupid'); $where .= ' AND (g.' . $db->quoteName('approvals') . ' = ' . $db->Quote('0') . ' OR g.' . $db->quoteName('approvals') . ' IS NULL)'; } $limit = isset($limit) ? $limit : $this->getState('limit'); $limit = $limit < 0 ? 0 : $limit; if ($pagination) { $limitstart = isset($limitstart) ? $limitstart : $this->getState('limitstart'); } else { $limitstart = 0; } if ($limitSetting == true) { /* Temporary fix for ajaxGetFeaturedVideos LIMIT 0,0 */ if ($limit != 0) { $limiter = ' LIMIT ' . $limitstart . ', ' . $limit; } } else { $limiter = ''; } $order = ''; $sorting = isset($filters['sorting']) ? $filters['sorting'] : 'latest'; switch ($sorting) { case 'mostwalls': // do a query to get the most commented items ids $wallquery = ' SELECT contentid' . ' FROM ' . $db->quoteName('#__community_wall') . ' WHERE ' . $db->quoteName('type') . ' = ' . $db->quote('videos') . ' AND ' . $db->quoteName('published') . ' = ' . $db->quote(1) . ' group by id ' . ' order by count(*) DESC '; $db->setQuery($wallquery); $wallResult = $db->loadColumn(); $sortedResult = array(); // key represents content id, and value is the total comment that exists foreach ($wallResult as $result) { if (!isset($sortedResult[$result])) { $sortedResult[$result] = 0; } $sortedResult[$result]++; } asort($sortedResult); //sort the result based on value //implode array key $wallResult = array(); foreach ($sortedResult as $key => $value) { $wallResult[] = $key; } //sort by specific id using FIELD $order .= !empty($wallResult) ? ' ORDER BY FIELD( v.' . $db->quoteName('id') . ' , ' . implode(',', $wallResult) . ') DESC' : ' ORDER BY v.' . $db->quoteName('created') . ' DESC'; break; case 'mostviews': $order = ' ORDER BY v.' . $db->quoteName('hits') . ' DESC'; break; case 'title': $order = ' ORDER BY v.' . $db->quoteName('title') . ' ASC'; break; case 'featured': $featured = new CFeatured(FEATURED_VIDEOS); $featuredVideos = implode(',', $featured->getItemIds()); if (count($featuredVideos) > 0) { if ($featuredVideos) { $order = " ORDER BY (v.`id` IN (" . $featuredVideos . ")) DESC, v.id "; } //this is added to filter the result instead of sorting if (isset($filters['filterResult']) && $filters['filterResult']) { $where .= " AND v.`id` IN (" . $featuredVideos . ")"; } } break; case 'latest': default: $order = ' ORDER BY v.' . $db->quoteName('created') . ' DESC'; break; } $query = ' SELECT v.*, v.' . $db->quoteName('created') . ' AS lastupdated' . ' FROM ' . $db->quoteName('#__community_videos') . ' AS v' . $join . $where . $order . $limiter; $db->setQuery($query); $result = $db->loadObjectList(); // bind to JTable $data = array(); foreach ($result as $row) { $video = JTable::getInstance('Video', 'CTable'); $video->bind($row); $video->lastupdated = $video->created; $data[] = $video; } if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } // Get total of records to be used in the pagination $query = ' SELECT COUNT(*)' . ' FROM ' . $db->quoteName('#__community_videos') . ' AS v' . $join . $where; $db->setQuery($query); $total = $db->loadResult(); $this->total = $total; if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } // Apply pagination if (empty($this->_pagination)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination($total, $limitstart, $limit); } // Add the wallcount property for sorting purpose // foreach ($data as $video) { // // Wall post count // $query = ' SELECT COUNT(*)' // . ' FROM ' . $db->quoteName('#__community_wall') // . ' WHERE ' . $db->quoteName('type') . ' = ' . $db->quote('videos') // . ' AND ' . $db->quoteName('published') . ' = ' . $db->quote(1) // . ' AND ' . $db->quoteName('contentid') . ' = ' . $db->quote($video->id) // ; // $db->setQuery($query); // $video->wallcount = $db->loadResult(); // } // // Sort videos according to wall post count // if ($sorting == 'mostwalls') // JArrayHelper::sortObjects( $data, 'wallcount', -1); $resultentriesdata = array('entries' => $data, 'total' => $total, 'limitstart' => $limitstart, 'limit' => $limit); if ($useCache) { $cache->store($resultentriesdata, $cacheid, array(COMMUNITY_CACHE_TAG_VIDEOS)); } return $data; }
function _getAllAlbums() { $mainframe = JFactory::getApplication(); $document =& JFactory::getDocument(); $my = CFactory::getUser(); $userId = JRequest::getInt('userid', ''); CFactory::load('models', 'groups'); $model = CFactory::getModel('photos'); $groupId = JRequest::getInt('groupid', '', 'REQUEST'); $type = PHOTOS_USER_TYPE; if (!empty($userId)) { $user = CFactory::getUser($userId); // Set document title CFactory::load('helpers', 'owner'); $blocked = $user->isBlocked(); if ($blocked && !COwnerHelper::isCommunityAdmin()) { $tmpl = new CTemplate(); echo $tmpl->fetch('profile.blocked'); return; } if ($my->id == $user->id) { $title = JText::_('CC MY PHOTOS'); } else { $title = JText::sprintf('CC USERS PHOTO TITLE', $user->getDisplayName()); } } else { $title = JText::_('CC ALL PHOTOS TITLE'); } if (!empty($groupId)) { $title = JText::_('CC SUBSCRIBE TO GROUP PHOTOS FEEDS'); $group =& JTable::getInstance('Group', 'CTable'); $group->load($groupId); //@rule: Do not allow non members to view albums for private group if ($group->approvals == COMMUNITY_PRIVATE_GROUP && !$group->isMember($my->id) && !$group->isAdmin($my->id)) { echo JText::_('CC ACCESS FORBIDDEN'); return; } $type = PHOTOS_GROUP_TYPE; $albumsData = $model->getGroupAlbums($groupId, false, false, $mainframe->getCfg('feed_limit')); } else { // Get ALL albums or USER albums if (!empty($userId)) { $albumsData = $model->_getAlbums($userId, $type, false, false, $mainframe->getCfg('feed_limit')); } else { $albumsData = $model->getAllAlbums($userId, $mainframe->getCfg('feed_limit')); } } CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_ALBUMS); $featuredAlbums = $featured->getItemIds(); $featuredList = array(); // Prepare feeds $document->setTitle($title); foreach ($albumsData as $album) { $table =& JTable::getInstance('Album', 'CTable'); $table->bind($album); $table->thumbnail = $table->getCoverThumbPath(); $albumAuthor = CFactory::getUser($table->creator); $description = '<img src="' . $table->thumbnail . '" alt="" /> '; $description .= $albumAuthor->getDisplayName() . ' posted ' . $album->count . ' photos '; //print_r($albumAuthor); exit; $item = new JFeedItem(); $item->title = $table->name; $item->link = CRoute::_('index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $albumAuthor->id); $item->description = $description . $table->description; $item->date = $table->created; $item->author = $albumAuthor->getDisplayName(); // Make sure url is absolute $item->description = JString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description); $document->addItem($item); } $content = $document->render(); }
public function ajaxGetFeaturedVideos($limit) { $filter = JFilterInput::getInstance(); $limit = $filter->clean($limit, 'int'); $limit = max(0, $limit); $cache = CFactory::getCache('Core'); $intRandom = rand(COMMUNITY_CACHE_RANDOM_MIN, COMMUNITY_CACHE_RANDOM_MAX); $my = CFactory::getUser(); $permissions = $my->id == 0 ? 0 : 20; if (!($html = $cache->load('frontpage_ajaxGetFeaturedVideos_' . $permissions . '_' . $intRandom))) { CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_VIDEOS); $featuredVideos = $featured->getItemIds(); if (!empty($featuredVideos)) { $videoId = array(); foreach ($featuredVideos as $featuredVideo) { $videoId[] = $featuredVideo; } $objResponse = new JAXResponse(); $oversampledTotal = $limit * COMMUNITY_OVERSAMPLING_FACTOR; $model = CFactory::getModel('videos'); $filter = array('id' => $videoId, 'status' => 'ready', 'permissions' => $permissions, 'sorting' => 'latest', 'limit' => $oversampledTotal); $featuredVideos = $model->getVideos($filter, true); if (!empty($featuredVideos)) { shuffle($featuredVideos); $maxLatestCount = count($featuredVideos) > $limit ? $limit : count($featuredVideos); $html = $this->prepareVideosData($featuredVideos, $maxLatestCount, $objResponse); } else { $html = JText::_('COM_COMMUNITY_VIDEOS_NO_FEATURED_VIDEOS_YET'); } } else { $html = JText::_('COM_COMMUNITY_VIDEOS_NO_FEATURED_VIDEOS_YET'); } $cache->save($html, NULL, array(COMMUNITY_CACHE_TAG_VIDEOS)); } $objResponse = new JAXResponse(); $objResponse->addAssign('latest-videos-container', 'innerHTML', $html); $objResponse->addScriptCall("joms.filters.hideLoading();"); return $objResponse->sendResponse(); }
public function advanceSearch() { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $document = JFactory::getDocument(); //load calendar behavior JHtml::_('behavior.calendar'); JHtml::_('behavior.tooltip'); /** * Opengraph */ CHeadHelper::setType('website', JText::_('COM_COMMUNITY_TITLE_CUSTOM_SEARCH')); //$this->showSubMenu(); $this->addPathway(JText::_('COM_COMMUNITY_TITLE_CUSTOM_SEARCH')); $profileType = $jinput->get('profiletype', 0, 'INT'); $my = CFactory::getUser(); $config = CFactory::getConfig(); $result = null; $fields = CAdvanceSearch::getFields($profileType); $data = new stdClass(); $post = JRequest::get('GET'); $keyList = isset($post['key-list']) ? $post['key-list'] : ''; $avatarOnly = $jinput->get('avatar', '', 'NONE'); if (JString::strlen($keyList) > 0) { //formatting the assoc array $filter = array(); $key = explode(',', $keyList); $joinOperator = isset($post['operator']) ? $post['operator'] : ''; foreach ($key as $idx) { $obj = new stdClass(); $obj->field = $post['field' . $idx]; $obj->condition = $post['condition' . $idx]; $obj->fieldType = $post['fieldType' . $idx]; if ($obj->fieldType == 'email') { $obj->condition = 'equal'; } // we need to check whether the value contain start and end kind of values. // if yes, make them an array. if (isset($post['value' . $idx . '_2'])) { if ($obj->fieldType == 'date') { $startDate = empty($post['value' . $idx]) ? '01/01/1970' : $post['value' . $idx]; $endDate = empty($post['value' . $idx . '_2']) ? '01/01/1970' : $post['value' . $idx . '_2']; // Joomla 1.5 uses "/" // Joomla 1.6 uses "-" $delimeter = '-'; if (strpos($startDate, '/')) { $delimeter = '/'; } $sdate = explode($delimeter, $startDate); $edate = explode($delimeter, $endDate); if (isset($sdate[2]) && isset($edate[2])) { $obj->value = array($sdate[0] . '-' . $sdate[1] . '-' . $sdate[2] . ' 00:00:00', $edate[0] . '-' . $edate[1] . '-' . $edate[2] . ' 23:59:59'); } else { $obj->value = array(0, 0); } } else { $obj->value = array($post['value' . $idx], $post['value' . $idx . '_2']); } } else { if ($obj->fieldType == 'date') { $startDate = empty($post['value' . $idx]) ? '01/01/1970' : $post['value' . $idx]; $delimeter = '-'; if (strpos($startDate, '/')) { $delimeter = '/'; } $sdate = explode($delimeter, $startDate); if (isset($sdate[2])) { $obj->value = $sdate[2] . '-' . $sdate[1] . '-' . $sdate[0] . ' 00:00:00'; } else { $obj->value = 0; } } else { if ($obj->fieldType == 'checkbox') { if (empty($post['value' . $idx])) { //this mean user didnot check any of the option. $obj->value = ''; } else { $obj->value = isset($post['value' . $idx]) ? implode(',', $post['value' . $idx]) : ''; } } else { $obj->value = isset($post['value' . $idx]) ? $post['value' . $idx] : ''; } } } $filter[] = $obj; } $data->search = CAdvanceSearch::getResult($filter, $joinOperator, $avatarOnly, '', $profileType); $data->filter = $post; } $rows = !empty($data->search) ? $data->search->result : array(); $pagination = !empty($data->search) ? $data->search->pagination : ''; $filter = !empty($data->filter) ? $data->filter : array(); $resultRows = array(); $friendsModel = CFactory::getModel('friends'); for ($i = 0; $i < count($rows); $i++) { $row = $rows[$i]; //filter the user profile type if ($profileType && $row->_profile_id != $profileType) { continue; } $obj = new stdClass(); $obj->user = $row; $obj->friendsCount = $row->getFriendCount(); $obj->profileLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->id); $isFriend = CFriendsHelper::isConnected($row->id, $my->id); $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $row->id ? true : false; $resultRows[] = $obj; } if (class_exists('Services_JSON')) { $json = new Services_JSON(); } else { require_once AZRUL_SYSTEM_PATH . '/pc_includes/JSON.php'; $json = new Services_JSON(); } $tmpl = new CTemplate(); $multiprofileArr = array(); $hasMultiprofile = false; //let see if we have any multiprofile enabled if ($config->get('profile_multiprofile')) { $hasMultiprofile = true; //lets get the available profile $profileModel = CFactory::getModel('Profile'); $profiles = $profileModel->getProfileTypes(); if ($profiles) { $multiprofileArr[] = array('url' => CRoute::_('index.php?option=com_community&view=search&task=advancesearch'), 'name' => JText::_('COM_COMMUNITY_ALL_PROFILE'), 'selected' => !$profileType ? 1 : 0); foreach ($profiles as $profile) { $multiprofileArr[] = array('url' => CRoute::_('index.php?option=com_community&view=search&task=advancesearch&profiletype=' . $profile->id), 'name' => $profile->name, 'selected' => $profile->id == $profileType ? 1 : 0); } } } $searchForm = $tmpl->set('fields', $fields)->set('hasMultiprofile', $hasMultiprofile)->set('multiprofileArr', $multiprofileArr)->set('keyList', $keyList)->set('profileType', $profileType)->set('avatarOnly', $avatarOnly)->set('filterJson', $json->encode($filter))->set('postresult', isset($post['key-list']))->set('submenu', $this->showSubmenu(false))->fetch('search.advancesearch'); if (isset($post['key-list'])) { //result template $tmplResult = new CTemplate(); $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); $tmpl->set('featuredList', $featuredList); $searchForm .= $tmplResult->set('my', $my)->set('showFeaturedList', false)->set('multiprofileArr', $multiprofileArr)->set('featuredList', $featuredList)->set('data', $resultRows)->set('isAdvanceSearch', true)->set('hasMultiprofile', $hasMultiprofile)->set('sortings', '')->set('pagination', $pagination)->set('filter', $filter)->set('featuredList', $featuredList)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->fetch('people.browse'); } echo $searchForm; }
/** * Returns an object of events which the user has registered. * * @access public * @param string User's id. * @param string sorting criteria. * @returns array An objects of event fields. */ public function getEvents($categoryId = null, $userId = null, $sorting = null, $search = null, $hideOldEvent = true, $showOnlyOldEvent = false, $pending = null, $advance = null, $type = CEventHelper::ALL_TYPES, $contentid = 0, $limit = null, $upcomingOnly = false, $pagination = true, $hidePrivate = false) { $db = $this->getDBO(); $join = ''; $extraSQL = ''; $input = JFactory::getApplication()->input; $my = CFactory::getUser(); //get current user results as well if this is a private event/private group events if (!empty($userId) || $my->id) { $join = 'LEFT JOIN ' . $db->quoteName('#__community_events_members') . ' AS b ON a.' . $db->quoteName('id') . '=b.' . $db->quoteName('eventid'); if ($my->id && empty($userId)) { $extraSQL .= ' AND (b.' . $db->quoteName('memberid') . '=' . $db->Quote($my->id) . ' OR 1)'; } else { $extraSQL .= ' AND b.' . $db->quoteName('memberid') . '=' . $db->Quote($userId); } $pendingFlag = 1; if (!is_null($pending)) { $pendingFlag = $pending; } $extraSQL .= ' AND b.' . $db->quoteName('status') . '=' . $db->Quote($pendingFlag); } $user = CFactory::getUser(); if ($user->id > 0) { if (!COwnerHelper::isCommunityAdmin()) { $extraSQL .= ' AND(' . 'a.' . $db->quoteName('unlisted') . ' = ' . $db->Quote('0') . ' OR(' . 'a.' . $db->quoteName('unlisted') . ' = ' . $db->Quote('1') . ' AND' . '(SELECT COUNT(' . $db->quoteName('eventid') . ') FROM ' . $db->quoteName('#__community_events_members') . ' as b WHERE b.' . $db->quoteName('memberid') . '=' . $db->quote($user->id) . ' and b.' . $db->quoteName('eventid') . '=a.' . $db->quoteName('id') . ') > 0 ) )'; } } else { $extraSQL .= ' AND a.' . $db->quoteName('unlisted') . ' = ' . $db->Quote('0'); } if ($hidePrivate) { //hide the private event if current viewer is not the part of the event if (!COwnerHelper::isCommunityAdmin()) { $extraSQL .= ' AND(' . 'a.' . $db->quoteName('permission') . ' = ' . $db->Quote('0') . ' OR(' . 'a.' . $db->quoteName('permission') . ' = ' . $db->Quote('1') . ' AND' . '(SELECT COUNT(' . $db->quoteName('eventid') . ') FROM ' . $db->quoteName('#__community_events_members') . ' as b WHERE b.' . $db->quoteName('memberid') . '=' . $db->quote($my->id) . ' and b.' . $db->quoteName('eventid') . '=a.' . $db->quoteName('id') . ') > 0 ) )'; } } if (!empty($search)) { $extraSQL .= ' AND a.' . $db->quoteName('title') . ' LIKE ' . $db->Quote('%' . $search . '%'); } if (!empty($categoryId) && $categoryId != 0) { if (is_array($categoryId)) { $categoryIds = implode(',', $categoryId); $extraSQL .= ' AND a.' . $db->quoteName('catid') . ' IN(' . $categoryIds . ')'; } else { $extraSQL .= ' AND a.' . $db->quoteName('catid') . '=' . $db->Quote($categoryId); } } /* Begin : ADVANCE SEARCH */ if (!empty($advance)) { if (!empty($advance['startdate'])) { $startDate = CTimeHelper::getDate(strtotime($advance['startdate'])); $extraSQL .= ' AND a.' . $db->quoteName('startdate') . ' >= ' . $db->Quote($startDate->toSql()); } else { if (!isset($advance['date'])) { // If empty, don't select the past event // $now = CTimeHelper::getDate(); // $extraSQL .= ' AND a.' . $db->quoteName('enddate') . ' >= ' . $db->Quote($now->toSql()); } } if (!empty($advance['date'])) { // to get event within this date $between_date = date('Ymd', strtotime($advance['date'])); $extraSQL .= ' AND DATE_FORMAT(a.' . $db->quoteName('startdate') . ',"%Y%m%d") <= ' . $db->Quote($between_date) . ' AND DATE_FORMAT(a.' . $db->quoteName('enddate') . ',"%Y%m%d") >= ' . $db->Quote($between_date); //show old/current event as well $hideOldEvent = false; $upcomingOnly = false; } if (!empty($advance['enddate'])) { $endDate = CTimeHelper::getDate(strtotime($advance['enddate'])); $extraSQL .= ' AND a.' . $db->quoteName('startdate') . ' <= ' . $db->Quote($endDate->toSql()); } /* Begin : SEARCH WITHIN */ if (!empty($advance['radius']) && !empty($advance['fromlocation'])) { $longitude = null; $latitude = null; $data = CMapping::getAddressData($advance['fromlocation']); if ($data) { if ($data->status == 'OK') { $latitude = (double) $data->results[0]->geometry->location->lat; $longitude = (double) $data->results[0]->geometry->location->lng; } } $now = new JDate(); $lng_min = $longitude - $advance['radius'] / abs(cos(deg2rad($latitude)) * 69); $lng_max = $longitude + $advance['radius'] / abs(cos(deg2rad($latitude)) * 69); $lat_min = $latitude - $advance['radius'] / 69; $lat_max = $latitude + $advance['radius'] / 69; $extraSQL .= ' AND a.' . $db->quoteName('longitude') . ' > ' . $db->quote($lng_min) . ' AND a.' . $db->quoteName('longitude') . ' < ' . $db->quote($lng_max) . ' AND a.' . $db->quoteName('latitude') . ' > ' . $db->quote($lat_min) . ' AND a.' . $db->quoteName('latitude') . ' < ' . $db->quote($lat_max); } if (!empty($advance['parent'])) { $extraSQL .= ' AND a.' . $db->quoteName('parent') . ' = ' . $db->Quote($advance['parent']); } if (!empty($advance['id'])) { if (is_array($advance['id']) && count($advance['id']) > 0) { $ids = implode(',', $advance['id']); $extraSQL .= ' AND a.' . $db->quoteName('id') . 'IN (' . $ids . ')'; } } /* End : SEARCH WITHIN */ } /* End : ADVANCE SEARCH */ if ($pagination) { $limitstart = $this->getState('limitstart'); } else { $limitstart = 0; } $limit = $limit === null ? $this->getState('limit') : $limit; if ($type != CEventHelper::ALL_TYPES && $type != 'featured_only') { $extraSQL .= ' AND a.' . $db->quoteName('type') . '=' . $db->Quote($type); if (is_array($contentid)) { $contentids = implode(',', $contentid); $extraSQL .= ' AND a.' . $db->quoteName('contentid') . ' IN(' . $contentids . ')'; } elseif ($contentid > 0) { $extraSQL .= ' AND a.' . $db->quoteName('contentid') . '=' . $contentid; } } if ($type == 'featured_only') { $featured = new CFeatured(FEATURED_EVENTS); $featuredEvents = implode(',', $featured->getItemIds()); if ($featuredEvents) { $extraSQL .= ' AND a.' . $db->quoteName('id') . ' IN (' . $featuredEvents . ')'; } else { $extraSQL .= ' AND 0 '; } } if ($type == CEventHelper::GROUP_TYPE || $type == CEventHelper::ALL_TYPES) { // @rule: Respect group privacy $join .= ' LEFT JOIN ' . $db->quoteName('#__community_groups') . ' AS g'; $join .= ' ON g.' . $db->quoteName('id') . ' = a.' . $db->quoteName('contentid'); if ($type != CEventHelper::GROUP_TYPE) { $extraSQL .= ' AND (g.' . $db->quoteName('approvals') . ' = ' . $db->Quote('0') . ' OR g.' . $db->quoteName('approvals') . ' IS NULL'; $extraSQL .= ' OR (g.' . $db->quoteName('approvals') . '=' . $db->Quote('1') . ' AND (SELECT COUNT(' . $db->quoteName('groupid') . ') FROM ' . $db->quoteName('#__community_groups_members') . ' as t WHERE t.' . $db->quoteName('memberid') . '=' . $db->quote($user->id) . ' AND t.' . $db->quoteName('approved') . '=' . $db->Quote('1') . ' and t.' . $db->quoteName('groupid') . '=g.' . $db->quoteName('id') . ') > 0) '; if (!empty($userId)) { $extraSQL .= ' OR b.' . $db->quoteName('memberid') . '=' . $db->Quote($userId); } $extraSQL .= ')'; } } $orderBy = ''; $total = 0; switch ($sorting) { case 'latest': if (empty($orderBy)) { $orderBy = ' ORDER BY a.' . $db->quoteName('created') . ' DESC'; } break; case 'alphabetical': if (empty($orderBy)) { $orderBy = ' ORDER BY a.' . $db->quoteName('title') . ' ASC'; } break; case 'startdate': if (empty($orderBy)) { $orderBy = ' ORDER BY a.startdate ASC'; } break; default: $orderBy = ' ORDER BY a.' . $db->quoteName('startdate') . ' ASC'; break; } $now = new JDate(); /** * @todo need check and improve get correctly time with offset */ $CTimeHelper = new CTimeHelper(); $pastDate = $CTimeHelper->getLocaleDate(); if ($hideOldEvent && !$upcomingOnly) { $extraSQL .= ' AND a.' . $db->quoteName('enddate') . ' >= ' . $db->Quote($pastDate->format('Y-m-d H:i:s', true, false)); } if ($upcomingOnly) { $extraSQL .= ' AND a.' . $db->quoteName('startdate') . ' > ' . $db->Quote($pastDate->format('Y-m-d H:i:s', true, false)); } if ($showOnlyOldEvent) { $extraSQL .= ' AND a.' . $db->quoteName('enddate') . ' < ' . $db->Quote($pastDate->format('Y-m-d H:i:s', true, false)); } // Filtering on repeat event's parent $extraSQL .= ' AND ((a.' . $db->quoteName('parent') . '=' . $db->quote(0) . ' && (a.' . $db->quoteName('repeat') . '=' . $db->quote('') . ' || a.' . $db->quoteName('repeat') . ' IS NULL)) || (a.' . $db->quoteName('parent') . '!= 0 && a.' . $db->quoteName('repeat') . ' IS NOT NULL))'; $limit = empty($limit) ? 0 : $limit; $query = 'SELECT DISTINCT a.* FROM ' . $db->quoteName('#__community_events') . ' AS a ' . $join . 'WHERE a.' . $db->quoteName('published') . '=' . $db->Quote('1') . $extraSQL . $orderBy . ' LIMIT ' . $limitstart . ', ' . $limit; $db->setQuery($query); $result = $db->loadObjectList(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } $query = 'SELECT COUNT(DISTINCT(a.' . $db->quoteName('id') . ')) FROM ' . $db->quoteName('#__community_events') . ' AS a ' . $join . 'WHERE a.' . $db->quoteName('published') . '=' . $db->Quote('1') . ' ' . $extraSQL; $db->setQuery($query); $total = $db->loadResult(); $this->total = $total; if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } if (empty($this->_pagination)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination($total, $limitstart, $limit); } return $result; }
public function _getAlbumsHTML($albums, $type = PHOTOS_USER_TYPE, $pagination = NULL) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $my = CFactory::getUser(); $groupId = $jinput->request->get('groupid', '', 'INT'); //JRequest::getVar( 'groupid' , '' ,'REQUEST'); $tmpl = new CTemplate(); $handler = $this->_getHandler(); $photoTag = CFactory::getModel('phototagging'); $photos = array(); foreach ($albums as &$album) { $album->user = CFactory::getUser($album->creator); $album->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$album->id}&userid={$album->creator}"); $album->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$album->id}&userid={$album->creator}&referrer=myphotos"); $album->uploadLink = "javascript:joms.notifications.showUploadPhoto({$album->id});"; //CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$album->id}&userid={$album->creator}"); $album->isOwner = $my->id == $album->creator; // Get all photos from album $photos[$album->id] = $handler->getAlbumPhotos($album->id); $photoCount = count($photos[$album->id]); if ($type == PHOTOS_GROUP_TYPE) { $album->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$album->id}&groupid={$album->groupid}"); $album->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$album->id}&groupid={$album->groupid}&referrer=myphotos"); $album->uploadLink = CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$album->id}&groupid={$album->groupid}"); $albums[$i]->isOwner = $my->authorise('community.view', 'photos.group.album.' . $groupId, $albums[$i]); } } $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&userid=' . $my->id); if ($type == PHOTOS_GROUP_TYPE) { $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $groupId); $baselink = "index.php?option=com_community&view=photos&task=display&groupid=" . $groupId; $isOwner = CGroupHelper::allowManagePhoto($groupId); } else { $userId = JRequest::getInt('userid', '', 'REQUEST'); $baselink = "index.php?option=com_community&view=photos&task=myphotos&userid=" . $userId; $user = CFactory::getUser($userId); $isOwner = $my->id == $user->id ? true : false; } $featured = new CFeatured(FEATURED_ALBUMS); $featuredList = $featured->getItemIds(); $config = CFactory::getConfig(); $task = JRequest::getCmd('task', ''); return $tmpl->set('isMember', $my->id != 0)->set('isOwner', $isOwner)->set('type', $type)->set('baseLink', $baselink)->set('createLink', $createLink)->set('currentTask', $task)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('my', $my)->set('albums', $albums)->set('pagination', $pagination)->set('isSuperAdmin', COwnerHelper::isCommunityAdmin())->set('featuredList', $featuredList)->set('showFeatured', $config->get('show_featured'))->set('groupId', $groupId)->set('config', $config)->fetch('album/list'); }
if (!CFactory::getUser()->id) { //since this is my group only and if there is no userid provided, it should be empty $tmpGroups = array(); } else { $model->setState('limit', $limit); // limit the results $tmpGroups = $model->getGroups(CFactory::getUser()->id); } } else { //0 = show upcoming only $tmpGroups = $model->getAllGroups(null, null, null, $limit, true, false, false); } $groups = array(); $data = array(); $featuredOnly = $params->get('filter_by', 0); if ($featuredOnly) { //1 = featured only $featured = new CFeatured(FEATURED_GROUPS); $featuredGroups = $featured->getItemIds(); } foreach ($tmpGroups as $row) { if ($featuredOnly && !in_array($row->id, $featuredGroups)) { //if we only show featured item, and the item does not exists. continue; } $group = JTable::getInstance('Group', 'CTable'); $group->bind($row); $group->description = JHTML::_('string.truncate', $group->description, 30); $groups[] = $group; } require JModuleHelper::getLayoutPath('mod_community_groups', $params->get('layout', 'default'));