예제 #1
0
 public function search($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'));
     $this->showSubMenu();
     $avatarOnly = JRequest::getVar('avatar', '');
     $this->addPathway(JText::_('COM_COMMUNITY_SEARCH_FRIENDS_TITLE'));
     $my = CFactory::getUser();
     $friendsModel = CFactory::getModel('friends');
     $resultRows = array();
     $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)->set('sortings', '')->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');
     $resultHTML = $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('showFeaturedList', false)->set('my', $my)->fetch('people.browse');
     unset($tmpl);
     $searchLinks = parent::getAppSearchLinks('people');
     $tmpl = new CTemplate();
     echo $tmpl->set('avatarOnly', $avatarOnly)->set('results', $data->result)->set('resultHTML', $resultHTML)->set('query', $data->query)->set('searchLinks', $searchLinks)->fetch('search');
 }
예제 #2
0
 public function search($data)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_SEARCH_FRIENDS_TITLE'));
     //$this->showSubMenu();
     $avatarOnly = $jinput->get('avatar', '', 'NONE');
     $this->addPathway(JText::_('COM_COMMUNITY_SEARCH_FRIENDS_TITLE'));
     $my = CFactory::getUser();
     $friendsModel = CFactory::getModel('friends');
     $resultRows = array();
     $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)->set('sortings', '')->set('pagination', $pagination);
     $featured = new CFeatured(FEATURED_USERS);
     $featuredList = $featured->getItemIds();
     $tmpl->set('featuredList', $featuredList);
     $resultHTML = $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('showFeaturedList', false)->set('my', $my)->fetch('people.browse');
     unset($tmpl);
     $searchLinks = parent::getAppSearchLinks('people');
     $tmpl = new CTemplate();
     echo $tmpl->set('avatarOnly', $avatarOnly)->set('results', $data->result)->set('resultHTML', $resultHTML)->set('query', $data->query)->set('searchLinks', $searchLinks)->set('submenu', $this->showSubmenu(false))->fetch('search');
 }
예제 #3
0
 public function showSubmenu($display = true)
 {
     $this->_addSubmenu();
     return parent::showSubmenu($display);
 }
예제 #4
0
 function showSubmenu()
 {
     $this->_addSubmenu();
     parent::showSubmenu();
 }
예제 #5
0
 /**
  * View method to search groups
  *
  * @access	public
  *
  * @returns object  An object of the specific group
  */
 public function search()
 {
     // Get the document object and set the necessary properties of the document
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_COMMUNITY_GROUPS_SEARCH_TITLE'));
     $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
     $this->addPathway(JText::_("COM_COMMUNITY_SEARCH"), '');
     // Display the submenu
     $this->showSubmenu();
     $search = JRequest::getVar('search', '');
     $catId = JRequest::getVar('catid', '');
     $groups = '';
     $pagination = null;
     $posted = false;
     $count = 0;
     $model = CFactory::getModel('groups');
     $categories = $model->getCategories();
     // Test if there are any post requests made
     if (!empty($search) || !empty($catId)) {
         JRequest::checkToken('get') or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
         CFactory::load('libraries', 'apps');
         $appsLib =& CAppPlugins::getInstance();
         $saveSuccess = $appsLib->triggerEvent('onFormSave', array('jsform-groups-search'));
         if (empty($saveSuccess) || !in_array(false, $saveSuccess)) {
             $posted = true;
             $groups = $model->getAllGroups($catId, null, $search);
             $pagination = $model->getPagination();
             $count = count($groups);
         }
     }
     // Get the template for the group lists
     $groupsHTML = $this->_getGroupsHTML($groups, $pagination);
     CFactory::load('libraries', 'apps');
     $app =& CAppPlugins::getInstance();
     $appFields = $app->triggerEvent('onFormDisplay', array('jsform-groups-search'));
     $beforeFormDisplay = CFormElement::renderElements($appFields, 'before');
     $afterFormDisplay = CFormElement::renderElements($appFields, 'after');
     $searchLinks = parent::getAppSearchLinks('groups');
     $tmpl = new CTemplate();
     echo $tmpl->set('beforeFormDisplay', $beforeFormDisplay)->set('afterFormDisplay', $afterFormDisplay)->set('posted', $posted)->set('groupsCount', $count)->set('groupsHTML', $groupsHTML)->set('search', $search)->set('categories', $categories)->set('catId', $catId)->set('searchLinks', $searchLinks)->fetch('groups.search');
 }
예제 #6
0
 public function search()
 {
     // Get the document object and set the necessary properties of the document
     $document = JFactory::getDocument();
     $this->addPathway(JText::_('COM_COMMUNITY_EVENTS'), CRoute::_('index.php?option=com_community&view=events'));
     $this->addPathway(JText::_('COM_COMMUNITY_EVENTS_SEARCH'), '');
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_SEARCH_EVENTS_TITLE'));
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     // $script = '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>';
     // $document->addCustomTag($script);
     $config = CFactory::getConfig();
     // Display the submenu
     $this->showSubmenu();
     //New search features
     $model = CFactory::getModel('events');
     $categories = $model->getCategories();
     // input filtered to remove tags
     $search = trim($jinput->get('search', '', 'STRING'));
     // Input for advance search
     $catId = JRequest::getInt('catid', '');
     $unit = $jinput->get('unit', $config->get('eventradiusmeasure'), 'NONE');
     $category = JTable::getInstance('EventCategory', 'CTable');
     $category->load($catId);
     $advance = array();
     $advance['startdate'] = $jinput->get('startdate', '', 'NONE');
     $advance['enddate'] = $jinput->get('enddate', '', 'NONE');
     $advance['radius'] = $jinput->get('radius', '', 'NONE');
     $advance['fromlocation'] = $jinput->get('location', '', 'NONE');
     if ($unit === COMMUNITY_EVENT_UNIT_KM) {
         //COM_COMMUNITY_EVENTS_MILES
         // Since our searching need a value in Miles unit, we need to convert the KM value to Miles
         // 1 kilometre	=   0.621371192 miles
         // 1 mile = 1.6093 km
         $advance['radius'] = $advance['radius'] * 0.621371192;
     }
     $events = '';
     $pagination = null;
     $posted = JRequest::getInt('posted', '');
     $count = 0;
     $eventsHTML = '';
     // Test if there are any post requests made
     if (!empty($search) || !empty($catId) || (!empty($advance['startdate']) || !empty($advance['enddate']) || !empty($advance['radius']) || !empty($advance['fromlocation']))) {
         // Check for request forgeries
         JRequest::checkToken('get') or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
         //CFactory::load( 'libraries' , 'apps' );
         $appsLib = CAppPlugins::getInstance();
         $saveSuccess = $appsLib->triggerEvent('onFormSave', array('jsform-events-search'));
         if (empty($saveSuccess) || !in_array(false, $saveSuccess)) {
             $events = $model->getEvents($category->id, null, null, $search, null, null, null, $advance);
             $pagination = $model->getPagination();
             $count = $model->getEventsSearchTotal();
         }
     }
     // Get the template for the events lists
     $eventsHTML = $this->_getEventsHTML($events, false, $pagination, true);
     $app = CAppPlugins::getInstance();
     $appFields = $app->triggerEvent('onFormDisplay', array('jsform-events-search'));
     $beforeFormDisplay = CFormElement::renderElements($appFields, 'before');
     $afterFormDisplay = CFormElement::renderElements($appFields, 'after');
     $searchLinks = parent::getAppSearchLinks('events');
     // Revert back the radius value
     $advance['radius'] = $jinput->get('radius', '', 'NONE');
     $tmpl = new CTemplate();
     echo $tmpl->set('beforeFormDisplay', $beforeFormDisplay)->set('afterFormDisplay', $afterFormDisplay)->set('posted', $posted)->set('eventsCount', $count)->set('eventsHTML', $eventsHTML)->set('search', $search)->set('catId', $category->id)->set('categories', $categories)->set('advance', $advance)->set('unit', $unit)->set('searchLinks', $searchLinks)->fetch('events.search');
 }
예제 #7
0
 /**
  * Search list of friends
  *
  * if no $_GET['id'] is set, we're viewing our own friends
  */
 public function friendsearch($data)
 {
     require_once JPATH_COMPONENT . '/libraries/profile.php';
     require_once JPATH_COMPONENT . '/helpers/friends.php';
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_SEARCH_FRIENDS_TITLE'));
     $avatarOnly = $jinput->get('avatar', '', 'NONE');
     $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 : '';
     $alreadyfriend = array();
     $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;
         if ($row->addFriend) {
             $alreadyfriend[$row->id] = $row->id;
         }
         $resultRows[] = $row;
     }
     $tmpl->set('alreadyfriend', $alreadyfriend);
     $tmpl->set('data', $resultRows);
     $tmpl->set('sortings', '');
     $tmpl->set('pagination', $pagination);
     $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();
         /**
          * Opengraph
          */
         CHeadHelper::setType('website', 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);
         return parent::showSubmenu($display);
         /**
          * Opengraph
          */
         CHeadHelper::setType('website', 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');
 }
예제 #8
0
 /**
  * View to display the search form
  * */
 public function search()
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $this->addPathway(JText::_('COM_COMMUNITY_VIDEOS'), CRoute::_('index.php?option=com_community&view=videos'));
     $this->addPathway(JText::_('COM_COMMUNITY_VIDEOS_SEARCH_VIDEOS'), '');
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_VIDEOS_SEARCH_VIDEOS'));
     $this->_addSubmenu();
     $search = $jinput->request->get('search-text', '', 'STRING');
     $result = array();
     $pagination = null;
     $total = 0;
     if (!empty($search)) {
         $searchModel = CFactory::getModel('Search');
         $result = $searchModel->searchVideo($search);
         $pagination = $searchModel->getPagination();
         $total = $searchModel->getTotal();
     }
     $searchLinks = parent::getAppSearchLinks('videos');
     $pagination = is_null($pagination) ? '' : $pagination->getPagesLinks();
     $videosHTML = $this->_getVideosHTML($result);
     $tmpl = new CTemplate();
     $my = CFactory::getUser();
     echo $tmpl->set('videosHTML', $videosHTML)->set('pagination', $pagination)->set('videosCount', $total)->set('search', $search)->set('searchLinks', $searchLinks)->set('canCreate', $my->authorise('community.create', 'videos'))->set('submenu', $this->showSubmenu(false))->fetch('videos/base');
 }
예제 #9
0
 /**
  * Application full view
  **/
 function discussAppFullView()
 {
     $document =& JFactory::getDocument();
     $document->setTitle(JText::_('CC REPLY TO DISCUSSION TITLE'));
     $applicationName = JString::strtolower(JRequest::getVar('app', '', 'GET'));
     if (empty($applicationName)) {
         JError::raiseError(500, 'CC APP ID REQUIRED');
     }
     $output = '';
     $topicId = JRequest::getVar('topicid', '', 'GET');
     $model = CFactory::getModel('discussions');
     $discussion =& JTable::getInstance('Discussion', 'CTable');
     $discussion->load($topicId);
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($discussion->groupid);
     $this->addSubmenuItem('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $topicId, JText::_('CC BACK TO TOPIC'));
     parent::showSubmenu();
     //@todo: Since group walls doesn't use application yet, we process it manually now.
     if ($applicationName == 'walls') {
         CFactory::load('libraries', 'wall');
         $limit = JRequest::getVar('limit', 5, 'REQUEST');
         $limitstart = JRequest::getVar('limitstart', 0, 'REQUEST');
         $my = CFactory::getUser();
         $config = CFactory::getConfig();
         CFactory::load('helpers', 'owner');
         if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && $group->isMember($my->id) || COwnerHelper::isCommunityAdmin()) {
             $outputLock = '<div class="warning">' . JText::_('CC DISCUSSION LOCKED NOTICE') . '</div>';
             $outputUnLock = CWallLibrary::getWallInputForm($discussion->id, 'groups,ajaxSaveDiscussionWall', 'groups,ajaxRemoveWall');
             $wallForm = $discussion->lock ? $outputLock : $outputUnLock;
             $output .= $wallForm;
         }
         // Get the walls content
         $output .= '<div id="wallContent">';
         $output .= CWallLibrary::getWallContents('discussions', $discussion->id, $my->id == $discussion->creator, $limit, $limitstart, 'wall.content', 'groups,discussion');
         $output .= '</div>';
         jimport('joomla.html.pagination');
         $wallModel = CFactory::getModel('wall');
         $pagination = new JPagination($wallModel->getCount($discussion->id, 'discussions'), $limitstart, $limit);
         $output .= '<div class="pagination-container">' . $pagination->getPagesLinks() . '</div>';
     } else {
         CFactory::load('libraries', 'apps');
         $model = CFactory::getModel('apps');
         $applications =& CAppPlugins::getInstance();
         $applicationId = $model->getUserApplicationId($applicationName);
         $application = $applications->get($applicationName, $applicationId);
         // Get the parameters
         $manifest = JPATH_PLUGINS . DS . 'community' . DS . $applicationName . DS . $applicationName . '.xml';
         $params = new JParameter($model->getUserAppParams($applicationId), $manifest);
         $application->params =& $params;
         $application->id = $applicationId;
         $output = $application->onAppDisplay($params);
     }
     echo $output;
 }
예제 #10
0
 /**
  * View method to search groups
  *
  * @access	public
  *
  * @returns object  An object of the specific group
  */
 public function search()
 {
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_GROUPS_SEARCH_TITLE'));
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
     $this->addPathway(JText::_("COM_COMMUNITY_SEARCH"), '');
     $search = $jinput->get('search', '', 'STRING');
     $catId = $jinput->get('catid', '', 'INT');
     $groups = '';
     $pagination = null;
     $posted = false;
     $count = 0;
     $model = CFactory::getModel('groups');
     $categories = $model->getCategories();
     // Test if there are any post requests made
     if (!empty($search) || !empty($catId)) {
         JRequest::checkToken('get') or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
         $appsLib = CAppPlugins::getInstance();
         $saveSuccess = $appsLib->triggerEvent('onFormSave', array('jsform-groups-search'));
         if (empty($saveSuccess) || !in_array(false, $saveSuccess)) {
             $posted = true;
             $groups = $model->getAllGroups($catId, null, $search);
             $pagination = $model->getPagination();
             $count = count($groups);
         }
     }
     // Get the template for the group lists
     $groupsHTML = $this->_getGroupsHTML($groups, $pagination);
     $app = CAppPlugins::getInstance();
     $appFields = $app->triggerEvent('onFormDisplay', array('jsform-groups-search'));
     $beforeFormDisplay = CFormElement::renderElements($appFields, 'before');
     $afterFormDisplay = CFormElement::renderElements($appFields, 'after');
     $searchLinks = parent::getAppSearchLinks('groups');
     $tmpl = new CTemplate();
     echo $tmpl->set('beforeFormDisplay', $beforeFormDisplay)->set('afterFormDisplay', $afterFormDisplay)->set('posted', $posted)->set('groupsCount', $count)->set('groupsHTML', $groupsHTML)->set('search', $search)->set('categories', $categories)->set('catId', $catId)->set('searchLinks', $searchLinks)->set('submenu', $this->showSubmenu(false))->fetch('groups.search');
 }
예제 #11
0
 /**
  * View to display the search form
  **/
 public function search()
 {
     $document = JFactory::getDocument();
     $this->addPathway(JText::_('COM_COMMUNITY_VIDEOS'), CRoute::_('index.php?option=com_community&view=videos'));
     $this->addPathway(JText::_('COM_COMMUNITY_VIDEOS_SEARCH_VIDEOS'), '');
     $document->setTitle(JText::_('COM_COMMUNITY_VIDEOS_SEARCH_VIDEOS'));
     $this->_addSubmenu();
     $this->showSubmenu();
     $search = JRequest::getVar('search-text', '', 'REQUEST');
     $result = array();
     $pagination = null;
     $total = 0;
     if (!empty($search)) {
         $searchModel = CFactory::getModel('Search');
         $result = $searchModel->searchVideo($search);
         $pagination = $searchModel->getPagination();
         $total = $searchModel->getTotal();
     }
     $searchLinks = parent::getAppSearchLinks('videos');
     $pagination = is_null($pagination) ? '' : $pagination->getPagesLinks();
     $videosHTML = $this->_getVideosHTML($result);
     $tmpl = new CTemplate();
     echo $tmpl->set('videosHTML', $videosHTML)->set('pagination', $pagination)->set('videosCount', $total)->set('search', $search)->set('searchLinks', $searchLinks)->fetch('videos.search');
 }
예제 #12
0
 /**
  * DIsplay list of friends
  * 
  * if no $_GET['id'] is set, we're viewing our own friends	 	 
  */
 function friends($data = null)
 {
     // Load window library
     CFactory::load('libraries', 'window');
     // Load required filterbar library that will be used to display the filtering and sorting.
     CFactory::load('libraries', 'filterbar');
     // Load necessary window css / javascript headers.
     CWindow::load();
     $mainframe =& JFactory::getApplication();
     $my = CFactory::getUser();
     $id = JRequest::getCmd('userid', 0);
     if ($id == 0) {
         $id = $my->id;
     }
     // Display mini header if user is viewing other user's friend
     if ($id != $my->id) {
         $this->attachMiniHeaderUser($id);
     }
     $feedLink = CRoute::_('index.php?option=com_community&view=friends&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO FRIENDS FEEDS') . '" href="' . $feedLink . '"/>';
     $mainframe->addCustomHeadTag($feed);
     $friendsModel = CFactory::getModel('friends');
     $user = CFactory::getUser($id);
     $params = $user->getParams();
     CFactory::load('helpers', 'friends');
     $people = CFactory::getModel('search');
     $userModel = CFactory::getModel('user');
     $avatar = CFactory::getModel('avatar');
     $friends = CFactory::getModel('friends');
     $sorted = JRequest::getVar('sort', 'latest', 'GET');
     $filter = JRequest::getWord('filter', 'all', 'GET');
     CFactory::load('helpers', 'friends');
     $rows = $friends->getFriends($id, $sorted, true, $filter);
     $isMine = $id == $my->id && $my->id != 0;
     $document =& JFactory::getDocument();
     $this->addPathway(JText::_('CC FRIENDS'), CRoute::_('index.php?option=com_community&view=friends'));
     if ($my->id == $id) {
         $this->addPathway(JText::_('CC MY FRIENDS'));
     } else {
         $this->addPathway(JText::sprintf('CC ALL FRIENDS', $user->getDisplayName()));
     }
     // Hide submenu if we are viewing other's friends
     if ($isMine) {
         $this->showSubmenu();
         $document->setTitle(JText::_('CC MY FRIENDS'));
     } else {
         $this->addSubmenuItem('index.php?option=com_community&view=profile&userid=' . $user->id, JText::_('CC BACK TO PROFILE'));
         parent::showSubmenu();
         $document->setTitle(JText::sprintf('CC ALL FRIENDS', $user->getDisplayName()));
     }
     $sortItems = array('latest' => JText::_('CC RECENT FRIENDS'), 'online' => JText::_('CC ONLINE'), 'name' => JText::_('CC SORT ALPHABETICAL'));
     $config = CFactory::getConfig();
     $filterItems = array();
     if ($config->get('alphabetfiltering')) {
         $filterItems = array('all' => JText::_('CC ALL'), 'abc' => JText::_('CC ABC'), 'def' => JText::_('CC DEF'), 'ghi' => JText::_('CC GHI'), 'jkl' => JText::_('CC JKL'), 'mno' => JText::_('CC MNO'), 'pqr' => JText::_('CC PQR'), 'stu' => JText::_('CC STU'), 'vwx' => JText::_('CC VWX'), 'yz' => JText::_('CC YZ'), 'others' => JText::_('CC OTHERS'));
     }
     // Check if friend is banned
     $blockModel = CFactory::getModel('block');
     $tmpl = new CTemplate();
     $resultRows = array();
     // @todo: preload all friends
     foreach ($rows as $row) {
         $user = CFactory::getUser($row->id);
         $obj = clone $row;
         $obj->friendsCount = $user->getFriendCount();
         $obj->profileLink = CUrlHelper::userLink($row->id);
         $obj->isFriend = true;
         $obj->isBlocked = $blockModel->getBlockStatus($user->id, $my->id);
         $resultRows[] = $obj;
     }
     unset($rows);
     $tmpl->set('isMine', $isMine);
     $tmpl->setRef('my', $my);
     $tmpl->setRef('friends', $resultRows);
     // Should not show recently added filter to otehr people
     $sortingHTML = '';
     if ($isMine) {
         $sortingHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest', $filterItems, 'all');
     }
     $tmpl->set('sortings', $sortingHTML);
     $tmpl->set('config', CFactory::getConfig());
     $html = $tmpl->fetch('friends.list');
     $html .= '<div class="pagination-container">';
     $pagination = $friends->getPagination();
     $html .= $pagination->getPagesLinks();
     $html .= '</div>';
     echo $html;
 }