public function load($userlist) { //FB::log($userlist, 'Preload JomSocial Userlist'); if (method_exists('CFactory', 'loadUsers')) { CFactory::loadUsers($userlist); } }
public function load($userlist) { KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null; if (class_exists('CFactory') && method_exists('CFactory', 'loadUsers')) { CFactory::loadUsers($userlist); } KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null; }
/** * Display the photo thumbnails from an album * */ public function album() { $document = JFactory::getDocument(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $config = CFactory::getConfig(); $handler = $this->_getHandler(); $my = CFactory::getUser(); //CFactory::load( 'libraries' , 'activities' ); // Get show photo location map by default $photoMapsDefault = $config->get('photosmapdefault'); $albumId = $jinput->get('albumid', 0, 'INT'); $album = JTable::getInstance('Album', 'CTable'); $album->load($albumId); $defaultId = $jinput->get('photoid', 0, 'INT'); $userId = $jinput->get('userid', 0, 'INT'); $limitstart = $jinput->get->get('limitstart', '0', 'INT'); if (empty($limitstart)) { $limitstart = $jinput->get->get('start', '0', 'INT'); } $user = CFactory::getUser($album->creator); // Set pathway for group photos // Community > Groups > Group Name > Photos > Album Name $pathway = $mainframe->getPathway(); if ($album->type == 'group') { if (!$my->authorise('community.view', 'photos.group.album.' . $album->groupid, $album)) { echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION'); return; } } else { if (!$my->authorise('community.view', 'photos.user.album.' . $album->id)) { echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION'); return; } } $groupId = $album->groupid; if ($groupId > 0) { $group = JTable::getInstance('Group', 'CTable'); $group->load($groupId); $pathway->addItem(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups')); $pathway->addItem($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId)); $pathway->addItem(JText::_('COM_COMMUNITY_PHOTOS'), CRoute::_('index.php?option=com_community&view=photos&groupid=' . $groupId)); } else { $pathway->addItem(JText::_('COM_COMMUNITY_PHOTOS'), CRoute::_('index.php?option=com_community&view=photos')); $pathway->addItem(JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $user->getDisplayName()), CRoute::_('index.php?option=com_community&view=photos&task=myphotos&userid=' . $userId)); } $handler->setMiniHeader(); if (empty($albumId)) { echo JText::_('COM_COMMUNITY_PHOTOS_NO_ALBUMID_ERROR'); return; } if (is_null($album->id)) { echo JText::_('COM_COMMUNITY_ALBUM_DELETED'); return; } if (!$handler->isAlbumBrowsable($albumId)) { return; } //$photos = $handler->getAlbumPhotos( $album->id ); $photoPaginationLimit = intval($config->get('pagination')); $photoThumbLimit = $photoPaginationLimit; $model = CFactory::getModel('photos'); $photos = $model->getPhotos($album->id, $photoThumbLimit, $limitstart); $pagination = $model->getPagination(); $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($album->photoid); if ($album->photoid == '0') { $album->thumbnail = $photo->getThumbURI(); } else { $album->thumbnail = $photo->getImageURI(); } // Increment album's hit each time this page is loaded. $album->hit(); if ($groupId > 0) { $otherAlbums = $model->getGroupAlbums($groupId); } else { $otherAlbums = $model->getAlbums($user->id); } $totalAlbums = count($otherAlbums); $showOtherAlbum = 6; $randomAlbum = array(); if (count($otherAlbums) > 0) { $randomId = $totalAlbums < $showOtherAlbum ? array_rand($otherAlbums, $totalAlbums) : array_rand($otherAlbums, $showOtherAlbum); $count = 0; for ($i = 0; $i < $totalAlbums; $i++) { $num = is_array($randomId) ? $randomId[$i] : $randomId; if ($otherAlbums[$num]->id != $album->id) { $count++; $randomAlbum[] = $otherAlbums[$num]; } if (count($randomAlbum) == $showOtherAlbum - 1) { break; } } } /* set head meta */ if (strtolower(trim(JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()))) == strtolower(trim($album->name))) { /** * Opengraph */ CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()), CStringHelper::escape($album->getDescription())); } else { /** * Opengraph */ CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()) . ' - ' . $album->name, CStringHelper::escape($album->getDescription())); } $this->setTitle($album->name); $handler->setAlbumPathway(CStringHelper::escape($album->name)); $handler->setRSSHeader($albumId); // Set album thumbnail and description for social bookmarking sites linking $document->addHeadLink($album->getCoverThumbURI(), 'image_src', 'rel'); //$document->setDescription( CStringHelper::escape($album->getDescription()) ); //CFactory::load( 'libraries' , 'phototagging' ); $getTaggingUsers = new CPhotoTagging(); $people = array(); // @TODO temporary fix for undefined link $list = array(); foreach ($photos as $photo) { $photo->link = $handler->getPhotoURI($photo->id, $photo->albumid); CHeadHelper::addOpengraph('og:image', JUri::root(true) . '/' . $photo->image, true); $list[] = $photo; } $photos = $list; $albumParam = new Cparameter($album->params); $tagged = $albumParam->get('tagged'); if (!empty($tagged)) { $people = explode(',', $albumParam->get('tagged')); } //Update lastUpdated $lastUpdated = new JDate($album->lastupdated); $album->lastUpdated = CActivityStream::_createdLapse($lastUpdated, false); $people = array_unique($people); CFactory::loadUsers($people); foreach ($people as &$person) { $person = CFactory::getUser($person); } //CFactory::load( 'libraries' , 'bookmarks' ); $bookmarks = new CBookmarks($handler->getAlbumExternalURI($album->id)); // Get wall data. $wallCount = CWallLibrary::getWallCount('albums', $album->id); $viewAllLink = false; if ($jinput->request->get('task', '') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls'); } $wallContent = CWallLibrary::getWallContents('albums', $album->id, COwnerHelper::isCommunityAdmin() || $my->id == $album->creator && $my->id != 0, $config->get('stream_default_comments'), 0, 'wall/content', 'photos,album'); $wallForm = CWallLibrary::getWallInputForm($album->id, 'photos,ajaxAlbumSaveWall', 'photos,ajaxAlbumRemoveWall', $viewAllLink); $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls'); $wallViewAll = ''; if ($wallCount > $config->get('stream_default_comments')) { $wallViewAll = CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount); } $redirectUrl = CRoute::getURI(false); $tmpl = new CTemplate(); if ($album->location != "") { $zoomableMap = CMapping::drawZoomableMap($album->location, 220, 150); } else { $zoomableMap = ""; } // Get the likes / dislikes item //CFactory::load( 'libraries' , 'like' ); $like = new CLike(); $likeCount = $like->getLikeCount('album', $album->id); $likeLiked = $like->userLiked('album', $album->id, $my->id) === COMMUNITY_LIKE; $owner = CFactory::getUser($album->creator); echo $tmpl->set('photosmapdefault', $photoMapsDefault)->set('my', $my)->set('bookmarksHTML', $bookmarks->getHTML())->set('isOwner', $handler->isAlbumOwner($album->id))->set('isAdmin', COwnerHelper::isCommunityAdmin())->set('owner', $owner)->set('photos', $photos)->set('people', $people)->set('album', $album)->set('groupId', $groupId)->set('otherAlbums', $randomAlbum)->set('likeCount', $likeCount)->set('likeLiked', $likeLiked)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('wallCount', $wallCount)->set('wallViewAll', $wallViewAll)->set('zoomableMap', $zoomableMap)->set('pagination', $pagination)->set('photoId', $defaultId)->set('submenu', $this->showSubmenu(false))->fetch('photos/list'); }
/** * Responsible to output the html codes for the task viewguest. * Outputs html codes for the viewguest page. * * @return none. **/ function viewguest() { if (!$this->accessAllowed('registered')) { return; } $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = CFactory::getConfig(); $my = CFactory::getUser(); $id = JRequest::getInt('eventid', 0); $type = JRequest::getCmd('type'); $approval = JRequest::getCmd('approve'); $event = JTable::getInstance('Event', 'CTable'); $event->load($id); CFactory::load('helpers', 'event'); $handler = CEventHelper::getHandler($event); $types = array(COMMUNITY_EVENT_ADMINISTRATOR, COMMUNITY_EVENT_STATUS_INVITED, COMMUNITY_EVENT_STATUS_ATTEND, COMMUNITY_EVENT_STATUS_BLOCKED, COMMUNITY_EVENT_STATUS_REQUESTINVITE); if (!in_array($type, $types)) { JError::raiseError('500', JText::_('Invalid status type')); } // Set the guest type for the title purpose switch ($type) { case COMMUNITY_EVENT_ADMINISTRATOR: $guestType = JText::_('CC ADMINS'); break; case COMMUNITY_EVENT_STATUS_INVITED: $guestType = JText::_('CC PENDING GUESTS'); break; case COMMUNITY_EVENT_STATUS_ATTEND: $guestType = JText::_('CC CONFIRMED GUESTS'); break; case COMMUNITY_EVENT_STATUS_BLOCKED: $guestType = JText::_('CC BLOCKED GUESTS'); break; case COMMUNITY_EVENT_STATUS_REQUESTINVITE: $guestType = JText::_('CC REQUESTED INVITATION'); break; } // Then we load basic page presentation $this->addPathway(JText::_('CC EVENTS'), CRoute::_('index.php?option=com_community&view=events')); $this->addPathway(JText::sprintf('CC VIEW EVENTS TITLE', $event->title), ''); // Set the specific title $document->setTitle(JText::sprintf("CC EVENT VIEW GUESTLIST", $event->title, $guestType)); CFactory::load('helpers', 'owner'); $status = $event->getUserStatus($my->id); $allowed = array(COMMUNITY_EVENT_STATUS_INVITED, COMMUNITY_EVENT_STATUS_ATTEND, COMMUNITY_EVENT_STATUS_WONTATTEND, COMMUNITY_EVENT_STATUS_MAYBE); $accessAllowed = in_array($status, $allowed) && $status != COMMUNITY_EVENT_STATUS_BLOCKED ? true : false; if ($handler->hasInvitation() && ($accessAllowed && $event->allowinvite || $event->isAdmin($my->id) || COwnerHelper::isCommunityAdmin())) { $this->addSubmenuItem('index.php?option=com_community&view=events&task=invitefriends&eventid=' . $event->id, JText::_('CC TAB INVITE'), '', SUBMENU_RIGHT); } $this->showSubmenu(); $isSuperAdmin = COwnerHelper::isCommunityAdmin(); // status = unsure | noreply | accepted | declined | blocked // permission = admin | guest | if ($type == COMMUNITY_EVENT_ADMINISTRATOR) { $guestsIds = $event->getAdmins(0); } else { $guestsIds = $event->getMembers($type, 0, false, $approval); } $guests = array(); // Pre-load multiple users at once $userids = array(); foreach ($guestsIds as $uid) { $userids[] = $uid->id; } CFactory::loadUsers($userids); for ($i = 0; $i < count($guestsIds); $i++) { $guests[$i] = CFactory::getUser($guestsIds[$i]->id); $guests[$i]->friendsCount = $guests[$i]->getFriendCount(); $guests[$i]->isMe = $my->id == $guests[$i]->id ? true : false; $guests[$i]->isAdmin = $event->isAdmin($guests[$i]->id); $guests[$i]->statusType = $guestsIds[$i]->statusCode; } $pagination = $event->getPagination(); // Output to template $tmpl = new CTemplate(); $tmpl->set('event', $event); $tmpl->set('handler', $handler); $tmpl->set('guests', $guests); $tmpl->set('eventid', $event->id); $tmpl->set('isMine', $event->isCreator($my->id)); $tmpl->set('isSuperAdmin', $isSuperAdmin); $tmpl->set('pagination', $pagination); $tmpl->set('my', $my); $tmpl->set('config', $config); echo $tmpl->fetch('events.viewguest'); }
/** * View method to display members of the groups * * @access public * @param string Group Id * @returns object An object of the specific group */ public function viewmembers($data) { $mainframe =& JFactory::getApplication(); $groupsModel =& CFactory::getModel('groups'); $friendsModel =& CFactory::getModel('friends'); $userModel =& CFactory::getModel('user'); $my = CFactory::getUser(); $config =& CFactory::getConfig(); $type = JRequest::getVar('approve', '', 'GET'); $group =& JTable::getInstance('Group', 'CTable'); $list = JRequest::getVar('list', '', 'GET'); if (!$group->load($data->id)) { echo JText::_('COM_COMMUNITY_GROUPS_NOT_FOUND_ERROR'); return; } // @rule: Test if the group is unpublished, don't display it at all. if (!$group->published) { $this->_redirectUnpublishGroup(); return; } $document = JFactory::getDocument(); $document->setTitle(JText::sprintf('COM_COMMUNITY_GROUPS_MEMBERS_TITLE', $group->name)); $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups')); $this->addPathway($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id)); $this->addPathway(JText::_('COM_COMMUNITY_MEMBERS')); CFactory::load('helpers', 'owner'); $isSuperAdmin = COwnerHelper::isCommunityAdmin(); $isAdmin = $groupsModel->isAdmin($my->id, $group->id); $isMember = $group->isMember($my->id); $isMine = $my->id == $group->ownerid; $isBanned = $group->isBanned($my->id); if ($group->approvals == '1' && !$isMine && !$isMember && !$isSuperAdmin) { $this->noAccess(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE')); return; } switch ($list) { case COMMUNITY_GROUP_ADMIN: $members = $groupsModel->getAdmins($data->id); break; case COMMUNITY_GROUP_BANNED: $members = $groupsModel->getBannedMembers($data->id); break; default: if (!empty($type) && $type == '1') { $members = $groupsModel->getMembers($data->id, 0, false); } else { $members = $groupsModel->getMembers($data->id, 0, true, false, SHOW_GROUP_ADMIN); } } $this->showSubmenu(); // Attach avatar of the member // Pre-load multiple users at once $userids = array(); foreach ($members as $uid) { $userids[] = $uid->id; } CFactory::loadUsers($userids); $membersList = array(); foreach ($members as $member) { $user = CFactory::getUser($member->id); $user->friendsCount = $user->getFriendCount(); $user->approved = $member->approved; $user->isMe = $my->id == $member->id ? true : false; $user->isAdmin = $groupsModel->isAdmin($user->id, $group->id); $user->isOwner = $member->id == $group->ownerid ? true : false; // Check user's permission $groupmember =& JTable::getInstance('GroupMembers', 'CTable'); $groupmember->load($member->id, $group->id); $user->isBanned = $groupmember->permissions == COMMUNITY_GROUP_BANNED ? true : false; $membersList[] = $user; } $pagination = $groupsModel->getPagination(); $tmpl = new CTemplate(); echo $tmpl->set('members', $membersList)->set('type', $type)->set('isMine', $groupsModel->isCreator($my->id, $group->id))->set('isAdmin', $isAdmin)->set('isMember', $isMember)->set('isSuperAdmin', $isSuperAdmin)->set('pagination', $pagination)->set('groupid', $group->id)->set('my', $my)->set('config', $config)->set('group', $group)->fetch('groups.viewmembers'); }
/** * Advance search with temporary table * */ public function getAdvanceSearch($filter = array(), $join = 'and', $avatarOnly = '', $sorting = '') { $limit = $this->getState('limit'); $limitstart = $this->getState('limitstart'); $db = $this->getDBO(); $query = $this->_buildCustomQuery($filter, $join, $avatarOnly); //lets try temporary table here $tmptablename = 'tmpadv'; $drop = 'DROP TEMPORARY TABLE IF EXISTS ' . $tmptablename; $db->setQuery($drop); $db->query(); $query = 'CREATE TEMPORARY TABLE ' . $tmptablename . ' ' . $query; $db->setQuery($query); $db->query(); $total = $db->getAffectedRows(); //setting pagination object. $this->_pagination = new JPagination($total, $limitstart, $limit); $query = 'SELECT * FROM ' . $tmptablename; // @rule: Sorting if required. if (!empty($sorting)) { $query .= $this->_getSort($sorting); } // execution of master query $query .= ' LIMIT ' . $limitstart . ',' . $limit; $db->setQuery($query); $result = $db->loadColumn(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } // Preload CUser objects if (!empty($result)) { CFactory::loadUsers($result); } $cusers = array(); for ($i = 0; $i < count($result); $i++) { $usr = CFactory::getUser($result[$i]); $cusers[] = $usr; } return $cusers; }
public function search() { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $data = new stdClass(); $view = $this->getView('search'); $model = $this->getModel('search'); $profileModel = $this->getModel('profile'); $fields = $profileModel->getAllFields(); $search = JRequest::get('REQUEST'); $data->query = $jinput->request->get('q', '', 'STRING'); $avatarOnly = $jinput->get('avatar', '', 'NONE'); //prefill the seach values. $fields = $this->_fillSearchValues($fields, $search); $data->fields = $fields; if (isset($search)) { $model = $this->getModel('search'); $data->result = $model->searchPeople($search, $avatarOnly); //pre-load cuser. $ids = array(); if (!empty($data->result)) { foreach ($data->result as $item) { $ids[] = $item->id; } CFactory::loadUsers($ids); } } $data->pagination = $model->getPagination(); echo $view->get('search', $data); }
/** * Return the basic user profile */ function getLatestMember($limit = 15) { if ($limit == 0) { return array(); } $limit = $limit < 0 ? 0 : $limit; $db =& $this->getDBO(); $query = 'SELECT * FROM ' . $db->nameQuote('#__users') . ' ' . 'WHERE ' . $db->nameQuote('block') . '=' . $db->Quote(0) . ' ' . 'ORDER BY ' . $db->nameQuote('registerDate') . ' ' . 'DESC 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; }
/** * Responsible to output the html codes for the task viewguest. * Outputs html codes for the viewguest page. * * @return none. * */ public function viewguest() { if (!$this->accessAllowed('registered')) { return; } $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = CFactory::getConfig(); $my = CFactory::getUser(); $id = JRequest::getInt('eventid', 0); $type = JRequest::getCmd('type'); $approval = JRequest::getCmd('approve'); $event = JTable::getInstance('Event', 'CTable'); $event->load($id); $handler = CEventHelper::getHandler($event); $types = array(COMMUNITY_EVENT_ADMINISTRATOR, COMMUNITY_EVENT_STATUS_INVITED, COMMUNITY_EVENT_STATUS_ATTEND, COMMUNITY_EVENT_STATUS_WONTATTEND, COMMUNITY_EVENT_STATUS_MAYBE, COMMUNITY_EVENT_STATUS_BLOCKED, COMMUNITY_EVENT_STATUS_REQUESTINVITE); if (!in_array($type, $types)) { JError::raiseError('500', JText::_('Invalid status type')); } // Set the guest type for the title purpose switch ($type) { case COMMUNITY_EVENT_ADMINISTRATOR: $guestType = JText::_('COM_COMMUNITY_ADMINS'); break; case COMMUNITY_EVENT_STATUS_INVITED: $guestType = JText::_('COM_COMMUNITY_EVENTS_PENDING_MEMBER'); break; case COMMUNITY_EVENT_STATUS_ATTEND: $guestType = JText::_('COM_COMMUNITY_EVENTS_CONFIRMED_GUESTS'); break; case COMMUNITY_EVENT_STATUS_WONTATTEND: $guestType = JText::_('COM_COMMUNITY_EVENTS_WONT_ATTEND'); break; case COMMUNITY_EVENT_STATUS_MAYBE: $guestType = JText::_('COM_COMMUNITY_EVENTS_MAYBE_ATTEND'); break; case COMMUNITY_EVENT_STATUS_BLOCKED: $guestType = JText::_('COM_COMMUNITY_EVENTS_BLOCKED'); break; case COMMUNITY_EVENT_STATUS_REQUESTINVITE: $guestType = JText::_('COM_COMMUNITY_REQUESTED_INVITATION'); break; } // Then we load basic page presentation $this->addPathway(JText::_('COM_COMMUNITY_EVENTS'), CRoute::_('index.php?option=com_community&view=events')); $this->addPathway(JText::sprintf('COM_COMMUNITY_EVENTS_TITLE_LABEL', $event->title), ''); /** * Opengraph */ CHeadHelper::setType('website', JText::sprintf('COM_COMMUNTIY_EVENTS_GUESTLIST', $event->title, $guestType)); $status = $event->getUserStatus($my->id); $allowed = array(COMMUNITY_EVENT_STATUS_INVITED, COMMUNITY_EVENT_STATUS_ATTEND, COMMUNITY_EVENT_STATUS_WONTATTEND, COMMUNITY_EVENT_STATUS_MAYBE); $accessAllowed = in_array($status, $allowed) && $status != COMMUNITY_EVENT_STATUS_BLOCKED ? true : false; if ($handler->hasInvitation() && ($accessAllowed && $event->allowinvite || $event->isAdmin($my->id) || COwnerHelper::isCommunityAdmin())) { $this->addSubmenuItem('javascript:void(0)', JText::_('COM_COMMUNITY_TAB_INVITE'), "joms.invitation.showForm('', 'events,inviteUsers','" . $event->id . "','1','1');", SUBMENU_RIGHT); } $this->showSubmenu(); $isSuperAdmin = COwnerHelper::isCommunityAdmin(); // status = unsure | noreply | accepted | declined | blocked // permission = admin | guest | if ($type == COMMUNITY_EVENT_ADMINISTRATOR) { $guestsIds = $event->getAdmins(0); } else { $guestsIds = $event->getMembers($type, 0, false, $approval); } $guests = array(); // Pre-load multiple users at once $userids = array(); foreach ($guestsIds as $uid) { $userids[] = $uid->id; } CFactory::loadUsers($userids); for ($i = 0; $i < count($guestsIds); $i++) { $guests[$i] = CFactory::getUser($guestsIds[$i]->id); $guests[$i]->friendsCount = $guests[$i]->getFriendCount(); $guests[$i]->isMe = $my->id == $guests[$i]->id ? true : false; $guests[$i]->isAdmin = $event->isAdmin($guests[$i]->id); $guests[$i]->statusType = $guestsIds[$i]->statusCode; } // Featured $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); $pagination = $event->getPagination(); // Output to template $tmpl = new CTemplate(); echo CMiniHeader::showEventMiniHeader($event->id); echo $tmpl->set('event', $event)->set('type', $type)->set('handler', $handler)->set('guests', $guests)->set('eventid', $event->id)->set('isMine', $event->isCreator($my->id))->set('isSuperAdmin', $isSuperAdmin)->set('pagination', $pagination)->set('my', $my)->set('config', $config)->set('isAdmin', $event->isAdmin($my->id))->set('featuredList', $featuredList)->fetch('events.viewguest'); }
/** * return the list of friend from approved connections * controller need to set the id * * @param id int user id of the person we want to searhc their friend * @param bool do we need to randomize the result * @param sorted boolean do we need sorting? * @return CUser objects */ function &getFriends($id, $sorted = 'latest', $useLimit = true, $filter = 'all', $maxLimit = 0) { $cusers = array(); // Deprecated since 1.8 . // Earlier versions the default $filter is empty but since we will now need to handle character filter, // we need to set the default to 'all' if (empty($filter)) { $filter = 'all'; } // For visitor with id=0, obviously he won't have any friend! if (empty($id)) { return $cusers; } $db =& $this->getDBO(); $wheres = array(); $wheres[] = 'block = 0'; $limit = $this->getState('limit'); $limitstart = $this->getState('limitstart'); $query = 'SELECT DISTINCT(a.connect_to) AS id '; if ($filter == 'suggestion') { $query = 'SELECT DISTINCT(b.connect_to) AS id '; } $query .= ', CASE WHEN c.userid IS NULL THEN 0 ELSE 1 END AS online'; switch ($filter) { case 'mutual': $user = CFactory::getUser(); $query .= ' FROM ' . $db->nameQuote('#__community_connection') . ' AS a ' . 'INNER JOIN ' . $db->nameQuote('#__community_connection') . ' AS b ON ( a.connect_to = b.connect_to ) ' . 'AND a.connect_from=' . $db->Quote($id) . ' ' . 'AND b.connect_from=' . $db->Quote($user->id) . ' ' . 'AND a.status=' . $db->Quote('1'); $query .= ' LEFT JOIN ' . $db->nameQuote('#__session') . ' AS c ON a.connect_to = c.userid'; $query .= ' WHERE NOT EXISTS ( SELECT d.`blocked_userid` FROM ' . $db->nameQuote('#__community_blocklist') . ' AS d WHERE d.`userid` = ' . $db->Quote($id) . ' AND d.`blocked_userid` = a.`connect_to`) '; // Search those we send connection $pagingQuery = "SELECT count(*) " . ' FROM #__community_connection as a, #__users as b' . ' WHERE a.`connect_from`=' . $db->Quote($id) . ' AND a.`status`=1 ' . ' AND a.`connect_to`=b.`id` ' . ' AND NOT EXISTS ( SELECT d.`blocked_userid` FROM ' . $db->nameQuote('#__community_blocklist') . ' AS d WHERE d.`userid` = ' . $db->Quote($id) . ' AND d.`blocked_userid` = a.`connect_to`) ' . ' ORDER BY a.`connection_id` DESC '; $db->setQuery($pagingQuery); $total = $db->loadResult(); // Appy pagination if (empty($this->_pagination)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination($total, $limitstart, $limit); } break; case 'suggestion': $user = CFactory::getUser(); $query .= ', COUNT(1) AS totalFriends, b.connect_to AS id' . ' FROM ' . $db->nameQuote('#__community_connection') . ' AS b' . ' LEFT JOIN ' . $db->nameQuote('#__session') . ' AS c ON c.`userid` = b.`connect_to`' . ' WHERE b.`connect_to` != ' . $db->Quote($user->id) . ' AND b.`connect_from` IN (SELECT a.`connect_to` FROM ' . $db->nameQuote('#__community_connection') . ' a WHERE a.`connect_from` = ' . $db->Quote($user->id) . ' AND a.status = ' . $db->Quote('1') . ')' . ' AND NOT EXISTS(SELECT d.`connect_to` FROM `#__community_connection` d WHERE (d.`connect_to` = ' . $db->Quote($user->id) . ' AND d.`connect_from` = b.`connect_to`) OR (d.`connect_to` = b.`connect_to` AND d.`connect_from` = ' . $db->Quote($user->id) . ') )' . ' AND NOT EXISTS ( SELECT e.`blocked_userid` FROM ' . $db->nameQuote('#__community_blocklist') . ' AS e WHERE e.`userid` = ' . $db->Quote($id) . ' AND e.`blocked_userid` = b.`connect_to`) '; // Search those we send connection $pagingQuery = "SELECT count(*) " . ' FROM #__community_connection as a, #__users as b' . ' WHERE a.`connect_from`=' . $db->Quote($id) . ' AND a.`status`=1 ' . ' AND a.`connect_to`=b.`id` ' . ' AND NOT EXISTS ( SELECT d.`blocked_userid` FROM ' . $db->nameQuote('#__community_blocklist') . ' AS d WHERE d.`userid` = ' . $db->Quote($id) . ' AND d.`blocked_userid` = a.`connect_to`) ' . ' ORDER BY a.`connection_id` DESC '; $db->setQuery($pagingQuery); $total = $db->loadResult(); // Appy pagination if (empty($this->_pagination)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination($total, $limitstart, $limit); } break; case 'all': $query .= ', b.name'; $query .= ' FROM ' . $db->nameQuote('#__community_connection') . ' AS a ' . 'INNER JOIN ' . $db->nameQuote('#__users') . ' AS b ' . 'ON a.connect_from=' . $db->Quote($id) . ' ' . 'AND a.connect_to=b.id ' . 'AND a.status=' . $db->Quote('1') . ' ' . 'LEFT JOIN ' . $db->nameQuote('#__session') . ' AS c ON a.connect_to = c.userid ' . 'WHERE NOT EXISTS ( SELECT d.`blocked_userid` FROM ' . $db->nameQuote('#__community_blocklist') . ' AS d WHERE d.`userid` = ' . $db->Quote($id) . ' AND d.`blocked_userid` = a.`connect_to`) '; // Search those we send connection $pagingQuery = "SELECT count(*) " . ' FROM #__community_connection as a, #__users as b' . ' WHERE a.`connect_from`=' . $db->Quote($id) . ' AND a.`status`=1 ' . ' AND a.`connect_to`=b.`id` ' . ' AND NOT EXISTS ( SELECT d.`blocked_userid` FROM ' . $db->nameQuote('#__community_blocklist') . ' AS d WHERE d.`userid` = ' . $db->Quote($id) . ' AND d.`blocked_userid` = a.`connect_to`) ' . ' ORDER BY a.`connection_id` DESC '; $db->setQuery($pagingQuery); $total = $db->loadResult(); // Appy pagination if (empty($this->_pagination)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination($total, $limitstart, $limit); } break; default: $filterCount = JString::strlen($filter); $filterQuery = ''; if ($filter == 'others') { $filterQuery = ' AND b.name REGEXP "^[^a-zA-Z]."'; } else { $config = CFactory::getConfig(); $filterQuery = ' AND('; for ($i = 0; $i < $filterCount; $i++) { $char = $filter[$i]; $filterQuery .= $i != 0 ? ' OR ' : ' '; $nameField = 'b.' . $db->nameQuote($config->get('displayname')); $filterQuery .= $nameField . ' LIKE "' . JString::strtoupper($char) . '%" OR ' . $nameField . ' LIKE "' . JString::strtolower($char) . '%"'; } $filterQuery .= ')'; } $query .= ', b.name'; $query .= ' FROM ' . $db->nameQuote('#__community_connection') . ' AS a ' . 'INNER JOIN ' . $db->nameQuote('#__users') . ' AS b ' . 'ON a.connect_from=' . $db->Quote($id) . ' ' . 'AND a.connect_to=b.id ' . 'AND a.status=' . $db->Quote('1'); $query .= $filterQuery; $query .= ' LEFT JOIN ' . $db->nameQuote('#__session') . ' AS c ON a.connect_to = c.userid'; $query .= ' WHERE NOT EXISTS ( SELECT d.`blocked_userid` FROM ' . $db->nameQuote('#__community_blocklist') . ' AS d WHERE d.`userid` = ' . $db->Quote($id) . ' AND d.`blocked_userid` = a.`connect_to`) '; // Search those we send connection $pagingQuery = "SELECT count(*) " . ' FROM #__community_connection as a, #__users as b' . ' WHERE a.`connect_from`=' . $db->Quote($id) . ' AND a.`status`=1 ' . ' AND a.`connect_to`=b.`id` ' . $filterQuery . ' AND NOT EXISTS ( SELECT d.`blocked_userid` FROM ' . $db->nameQuote('#__community_blocklist') . ' AS d WHERE d.`userid` = ' . $db->Quote($id) . ' AND d.`blocked_userid` = a.`connect_to`) ' . ' ORDER BY a.`connection_id` DESC '; $db->setQuery($pagingQuery); $total = $db->loadResult(); // Appy pagination if (empty($this->_pagination)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination($total, $limitstart, $limit); } break; } switch ($sorted) { // We only want the id since we use CFactory::getUser later to get their full details. case 'online': $query .= ' ORDER BY online DESC'; break; case 'suggestion': $query .= ' GROUP BY (b.`connect_to`)' . ' HAVING (totalFriends >= ' . FRIEND_SUGGESTION_LEVEL . ')'; break; case 'name': //sort by name only applicable to filter is not mutual and suggestion if ($filter != 'mutual' && $filter != 'suggestion') { $config = CFactory::getConfig(); $query .= ' ORDER BY b.' . $db->nameQuote($config->get('displayname')) . ' ASC'; } break; default: $query .= ' ORDER BY a.connection_id DESC'; break; } if ($useLimit) { $query .= " LIMIT {$limitstart}, {$limit} "; } else { if ($maxLimit > 0) { // we override the limit by specifying how many return need to be return. $query .= " LIMIT 0, {$maxLimit} "; } } $db->setQuery($query); $result = $db->loadObjectList(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } // preload all users $uids = array(); foreach ($result as $m) { $uids[] = $m->id; } CFactory::loadUsers($uids); for ($i = 0; $i < count($result); $i++) { $usr = CFactory::getUser($result[$i]->id); $cusers[] = $usr; } return $cusers; }
/** * Search Within Friends */ public function friendsearch() { CFactory::load('libraries', 'profile'); $mainframe =& JFactory::getApplication(); $data = new stdClass(); $view = $this->getView('friends'); $model = $this->getModel('search'); $profileModel = $this->getModel('profile'); $fields = $profileModel->getAllFields(); $search = JRequest::get('REQUEST'); $data->query = JRequest::getVar('q', '', 'REQUEST'); $friendId = JRequest::getVar('userid', '', 'REQUEST'); $avatarOnly = JRequest::getVar('avatar', ''); //prefill the search values. $fields = $this->_fillSearchValues($fields, $search); $data->fields =& $fields; if (isset($search)) { $model =& $this->getModel('search'); $data->result = $model->searchPeople($search, $avatarOnly, $friendId); //pre-load cuser. $ids = array(); if (!empty($data->result)) { foreach ($data->result as $item) { $ids[] = $item->id; } CFactory::loadUsers($ids); } } $data->pagination = $model->getPagination(); echo $view->get('friendsearch', $data); }
/** * Get the list of users from the site. * * @return Array An array of CUser objects. * */ public function getUsers() { $db = JFactory::getDBO(); $query = 'SELECT ' . $db->quoteName('id') . ' FROM ' . $db->quoteName('#__users'); $db->setQuery($query); $db->Query(); $ids = $db->loadColumn(); CFactory::loadUsers($ids); $users = array(); foreach ($ids as $id) { $users[] = CFactory::getUser($id); } return $users; }
/** * */ private function _getFriendsLocation($friends, $town_field_id, $state_field_id, $country_field_id, $zip_field_id, $address_field_id, $show_karma) { require_once JPATH_ROOT . '/components/com_community/libraries/core.php'; $db = JFactory::getDBO(); $friends_id = implode(',', $friends); $sql = 'SELECT a.' . $db->quoteName('user_id') . ', a.' . $db->quoteName('value') . ' AS country, b.' . $db->quoteName('value') . ' AS state, c.' . $db->quoteName('value') . ' AS town, d.' . $db->quoteName('value') . ' AS address, e.' . $db->quoteName('value') . ' AS zip' . ' FROM ' . $db->quoteName('#__community_fields_values') . ' AS a' . ' LEFT JOIN ' . $db->quoteName('#__community_fields_values') . ' AS b' . ' ON a.' . $db->quoteName('user_id') . '=b.' . $db->quoteName('user_id') . ' AND b.' . $db->quoteName('field_id') . ' = ' . $db->Quote($state_field_id) . ' LEFT JOIN ' . $db->quoteName('#__community_fields_values') . ' AS c' . ' ON a.' . $db->quoteName('user_id') . '=c.' . $db->quoteName('user_id') . ' AND c.' . $db->quoteName('field_id') . ' = ' . $db->Quote($town_field_id) . ' LEFT JOIN ' . $db->quoteName('#__community_fields_values') . ' AS d' . ' ON a.' . $db->quoteName('user_id') . '=d.' . $db->quoteName('user_id') . ' AND d.' . $db->quoteName('field_id') . ' = ' . $db->Quote($address_field_id) . ' LEFT JOIN ' . $db->quoteName('#__community_fields_values') . ' AS e' . ' ON a.' . $db->quoteName('user_id') . '=e.' . $db->quoteName('user_id') . ' AND e.' . $db->quoteName('field_id') . ' = ' . $db->Quote($zip_field_id) . ' WHERE a.' . $db->quoteName('field_id') . ' = ' . $db->Quote($country_field_id) . ' AND a.' . $db->quoteName('user_id') . ' IN (' . $friends_id . ')'; $db->setQuery($sql); $row = $db->loadObjectList(); // preload all users $CFactoryMethod = get_class_methods('CFactory'); if (in_array('loadUsers', $CFactoryMethod)) { $uids = array(); foreach ($row as $m) { $uids[] = $m->user_id; } CFactory::loadUsers($uids); } $location = JArrayHelper::toObject($location); $location = new stdClass(); foreach ($row as $data) { $user = CFactory::getUser($data->user_id); $country = JText::_($data->country); $state = JText::_($data->state); $town = JText::_($data->town); $address = $data->address; $zip = $data->zip; $fullAddress = $address . ", " . $town . ", " . $zip . ", " . $state . ", " . ", " . $country; $location->{$fullAddress} = new stdClass(); $location->{$fullAddress}->{$data->user_id} = new stdClass(); $location->{$fullAddress}->{$data->user_id}->username = $user->getDisplayName(); $location->{$fullAddress}->{$data->user_id}->avatar = $user->getThumbAvatar(); $location->{$fullAddress}->{$data->user_id}->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $data->user_id); switch ($show_karma) { case 1: $location->{$fullAddress}->{$data->user_id}->karma_points = "<div><img src='" . CUserPoints::getPointsImage($user) . "' alt=''/></div>"; break; case 2: $location->{$fullAddress}->{$data->user_id}->karma_points = "<div><small>" . JText::_('MOD_TOPMEMBERS_POINTS') . ": " . $user->_points . "</small></div>"; break; default: $location->{$fullAddress}->{$data->user_id}->karma_points = "<div></div>"; } } return $location; }
function getAdvanceSearch($filter = array(), $join = 'and', $avatarOnly = '', $sorting = '') { $limit = $this->getState('limit'); $limitstart = $this->getState('limitstart'); $db =& $this->getDBO(); $query = $this->_buildCustomQuery($filter, $join, $avatarOnly); //ok now get the count 1st $queryCnt = 'SELECT COUNT(1) FROM (' . $query . ') AS z'; $db->setQuery($queryCnt); $total = $db->loadResult(); //setting pagination object. $this->_pagination = new JPagination($total, $limitstart, $limit); // @rule: Sorting if required. if (!empty($sorting)) { switch ($sorting) { case 'online': $query .= 'ORDER BY online DESC'; break; case 'alphabetical': $config = CFactory::getConfig(); $query .= ' ORDER BY ' . $config->get('displayname') . ' ASC'; break; default: $query .= ' ORDER BY registerDate DESC'; break; } } // execution of master query $query .= ' LIMIT ' . $limitstart . ',' . $limit; $db->setQuery($query); $result = $db->loadResultArray(); // Preload CUser objects if (!empty($result)) { CFactory::loadUsers($result); } $cusers = array(); for ($i = 0; $i < count($result); $i++) { //$usr = CFactory::getUser( $result[$i]->user_id ); $usr = CFactory::getUser($result[$i]); $cusers[] = $usr; } return $cusers; }
* @copyright (C) 2013 iJoomla, Inc. - All rights reserved. * @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html) * @author iJoomla.com <*****@*****.**> * @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 */ // no direct access defined('_JEXEC') or die('Restricted access'); require_once dirname(__FILE__) . '/helper.php'; //CFactory::load( 'helpers' , 'string' ); $config = CFactory::getConfig(); $enablekarma = 0; if ($config->get('enablekarma')) { $enablekarma = $params->get('show_karma', 1); } $params->def('enablekarma', $enablekarma); $modTopMembersHelper = new modTopMembersHelper(); $users = $modTopMembersHelper->getMembersData($params); $document = JFactory::getDocument(); // $document->addStyleSheet(JURI::root(true) . '/components/com_community/assets/modules/module.css'); // preload users $CFactoryMethod = get_class_methods('CFactory'); if (in_array('loadUsers', $CFactoryMethod)) { $uids = array(); foreach ($users as $m) { $uids[] = $m->id; } CFactory::loadUsers($uids); } require JModuleHelper::getLayoutPath('mod_topmembers', $params->get('layout', 'default'));
public function search() { CFactory::load('libraries', 'profile'); $mainframe =& JFactory::getApplication(); $data = new stdClass(); $view = $this->getView('search'); $model = $this->getModel('search'); $profileModel = $this->getModel('profile'); $fields = $profileModel->getAllFields(); $search = JRequest::get('REQUEST'); $data->query = JRequest::getVar('q', '', 'REQUEST'); $avatarOnly = JRequest::getVar('avatar', ''); //prefill the seach values. if (isset($search)) { foreach ($fields as $group) { $field = $group->fields; for ($i = 0; $i < count($field); $i++) { $fieldid = $field[$i]->id; if (!empty($search['field' . $fieldid])) { $tmpEle = $search['field' . $fieldid]; if (is_array($tmpEle)) { $tmpStr = ""; foreach ($tmpEle as $ele) { $tmpStr .= $ele . ','; } $field[$i]->value = $tmpStr; } else { $field[$i]->value = $search['field' . $fieldid]; } } } //end for i } //end foreach } $data->fields =& $fields; if (isset($search)) { $model =& $this->getModel('search'); $data->result = $model->searchPeople($search, $avatarOnly); //pre-load cuser. $ids = array(); if (!empty($data->result)) { foreach ($data->result as $item) { $ids[] = $item->id; } CFactory::loadUsers($ids); } } $data->pagination = $model->getPagination(); echo $view->get('search', $data); }