function getMembersData(&$params) { $model = CFactory::getModel('user'); $db = JFactory::getDBO(); $limit = $params->get('count', '5'); $query = 'SELECT ' . $db->quoteName('userid') . ' FROM ' . $db->quoteName('#__community_users') . ' AS a ' . ' INNER JOIN ' . $db->quoteName('#__users') . ' AS b ON a.' . $db->quoteName('userid') . '=b.' . $db->quoteName('id') . ' WHERE ' . $db->quoteName('thumb') . '!=' . $db->Quote('components/com_community/assets/default_thumb.jpg') . ' ' . ' AND ' . $db->quoteName('block') . '=' . $db->Quote(0) . ' ' . ' ORDER BY ' . $db->quoteName('points') . ' DESC ' . ' LIMIT ' . $limit; $db->setQuery($query); $row = $db->loadObjectList(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } $_members = array(); if (!empty($row)) { foreach ($row as $data) { $user = CFactory::getUser($data->userid); $_obj = new stdClass(); $_obj->id = $data->userid; $_obj->name = $user->getDisplayName(); $_obj->avatar = $user->getThumbAvatar(); $CUserPoints = new CUserPoints(); $_obj->karma = $CUserPoints->getPointsImage($user); $_obj->userpoints = $user->_points; $_obj->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $data->userid); $_members[] = $_obj; } } return $_members; }
* @license GNU/GPL, see LICENSE.php */ defined('_JEXEC') or die('Restricted access'); if ($my->isOnline() && $my->id != 0) { $inboxModel = CFactory::getModel('inbox'); $filter = array(); $filter['user_id'] = $my->id; $friendModel = CFactory::getModel('friends'); $profileid = JRequest::getVar('userid', 0, 'GET'); $params->def('unreadCount', $inboxModel->countUnRead($filter)); $params->def('pending', $friendModel->countPending($my->id)); $params->def('myLink', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id)); $params->def('myName', $my->getDisplayName()); $params->def('myAvatar', $my->getAvatar()); $params->def('myId', $my->id); $params->def('myKarma', CUserPoints::getPointsImage($my)); $params->def('enablephotos', $config->get('enablephotos')); $params->def('enablevideos', $config->get('enablevideos')); $params->def('enablegroups', $config->get('enablegroups')); $params->def('enableevents', $config->get('enableevents')); $enablekarma = $config->get('enablekarma') ? $params->get('show_karma', 1) : $config->get('enablekarma'); $params->def('enablekarma', $enablekarma); $js = modHelloMeHelper::getHelloMeScript($my->getStatus(), COwnerHelper::isMine($my->id, $profileid)); $document = JFactory::getDocument(); $document->addScriptDeclaration($js); if ($params->get('enable_facebookconnect', '1')) { $params->def('facebookuser', modHelloMeHelper::isFacebookUser()); } else { $params->def('facebookuser', false); } CFactory::load('helpers', 'string');
$toolbar = CToolbarLibrary::getInstance(); $newMessageCount = $toolbar->getTotalNotifications('inbox'); $newEventInviteCount = $toolbar->getTotalNotifications('events'); $newFriendInviteCount = $toolbar->getTotalNotifications('friends'); $newGroupInviteCount = $toolbar->getTotalNotifications('groups'); $myParams = $my->getParams(); $newNotificationCount = $notifModel->getNotificationCount($my->id, '0', $myParams->get('lastnotificationlist', '')); $newEventInviteCount = $newEventInviteCount + $newNotificationCount; $params->def('unreadCount', $inboxModel->countUnRead($filter)); $params->def('pending', $friendModel->countPending($my->id)); $params->def('myLink', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id)); $params->def('myName', $my->getDisplayName()); $params->def('myAvatar', $my->getAvatar()); $params->def('myId', $my->id); $CUserPoints = new CUserPoints(); $params->def('myKarma', $CUserPoints->getPointsImage($my)); $params->def('enablephotos', $config->get('enablephotos')); $params->def('enablevideos', $config->get('enablevideos')); $params->def('enablegroups', $config->get('enablegroups')); $params->def('enableevents', $config->get('enableevents')); $enablekarma = $config->get('enablekarma') ? $params->get('show_karma', 1) : $config->get('enablekarma'); $params->def('enablekarma', $enablekarma); $modHelloMeHelper = new modHelloMeHelper(); $COwnerHelper = new COwnerHelper(); $js = $modHelloMeHelper->getHelloMeScript($my->getStatus(), $COwnerHelper->isMine($my->id, $profileid)); $document = JFactory::getDocument(); $document->addScriptDeclaration($js); if ($params->get('enable_facebookconnect', '1')) { $params->def('facebookuser', $modHelloMeHelper->isFacebookUser()); } else { $params->def('facebookuser', false);
/** * Show the main profile header */ function _showHeader(&$data) { jimport('joomla.utilities.arrayhelper'); $my =& JFactory::getUser(); $userid = JRequest::getVar('userid', $my->id); $user = CFactory::getUser($userid); $userModel = CFactory::getModel('user'); CFactory::load('libraries', 'messaging'); CFactory::load('helpers', 'owner'); // Get the admin controls HTML data $adminControlHTML = ''; $tmpl = new CTemplate(); $editStatus = ''; $editLink = ''; if (COwnerHelper::isMine($my->id, $user->id)) { $editStatus = '<input id="new-status" style="border:1px solid #cccccc;" type="text" value="" size="38" onkeyup="if(event.keyCode == 13) {cStatusAct()}"/>'; $editLink = '<span id="profile-status-edit" onclick="cStatusAct()">[' . JText::_('CC EDIT') . ']</span>'; } // get how many unread message $filter = array(); $inboxModel = CFactory::getModel('inbox'); $filter['user_id'] = $my->id; $unread = $inboxModel->countUnRead($filter); // get how many pending connection $friendModel = CFactory::getModel('friends'); $pending = $friendModel->countPending($my->id); $tmpl->set('karmaImgUrl', CUserPoints::getPointsImage($user)); $tmpl->set('editStatus', $editStatus); $tmpl->set('editLink', $editLink); $tmpl->set('isMine', COwnerHelper::isMine($my->id, $user->id)); $profile = JArrayHelper::toObject($data->profile); $profile->largeAvatar = $user->getAvatar(); $profile->status = $user->getStatus(); CFactory::load('libraries', 'activities'); $postedOn = new JDate($user->_posted_on); $postedOn = CActivityStream::_createdLapse($postedOn); $profile->posted_on = $user->_posted_on == '0000-00-00 00:00:00' ? '' : $postedOn; // Assign videoId $profile->profilevideo = $data->videoid; $addbuddy = "joms.friends.connect('{$profile->id}')"; $sendMsg = CMessaging::getPopup($profile->id); $config = CFactory::getConfig(); $lastLogin = JText::_('CC NEVER LOGGED IN'); if ($user->lastvisitDate != '0000-00-00 00:00:00') { //$now =& JFactory::getDate(); $userLastLogin = new JDate($user->lastvisitDate); CFactory::load('libraries', 'activities'); $lastLogin = CActivityStream::_createdLapse($userLastLogin); } // @todo : beside checking the owner, maybe we want to check for a cookie, // say every few hours only the hit get increment by 1. if (!COwnerHelper::isMine($my->id, $user->id)) { $user->viewHit(); } $tmpl->set('lastLogin', $lastLogin); $tmpl->setRef('user', $user); $tmpl->set('addBuddy', $addbuddy); $tmpl->set('sendMsg', $sendMsg); $tmpl->set('config', $config); // @rule: myblog integrations $showBlogLink = false; CFactory::load('libraries', 'myblog'); $myblog =& CMyBlog::getInstance(); if ($config->get('enablemyblogicon') && $myblog) { if ($myblog->userCanPost($user->id)) { $showBlogLink = true; } $tmpl->set('blogItemId', $myblog->getItemId()); } $multiprofile =& JTable::getInstance('MultiProfile', 'CTable'); $multiprofile->load($user->getProfileType()); // Get like $likesHTML = ''; if ($user->getParams()->get('profileLikes', true)) { CFactory::load('libraries', 'like'); $likes = new CLike(); $likesHTML = $my->id == 0 ? $likes->getHtmlPublic('profile', $user->id) : $likes->getHTML('profile', $user->id, $my->id); } $tmpl->set('multiprofile', $multiprofile); $tmpl->set('showBlogLink', $showBlogLink); $tmpl->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id); $tmpl->set('profile', $profile); $tmpl->set('unread', $unread); $tmpl->set('pending', $pending); $tmpl->set('registerDate', $user->registerDate); $tmpl->set('adminControlHTML', $adminControlHTML); $tmpl->set('likesHTML', $likesHTML); $html = $tmpl->fetch('profile.header'); return $html; }
/** * */ 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; }
public function modProfileUserinfo() { jimport('joomla.utilities.arrayhelper'); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $my = CFactory::getUser(); $userid = $jinput->get('userid', $my->id, 'INT'); $user = CFactory::getUser($userid); $params = $user->getParams(); $userModel = CFactory::getModel('user'); $profileModel = CFactory::getModel('profile'); //Reassign needed variable $data = new stdClass(); $data->user = $user; $data->profile = $profileModel->getViewableProfile($userid, $user->getProfileType()); $data->videoid = $params->get('profileVideo', 0); CFactory::load('libraries', 'messaging'); $isMine = COwnerHelper::isMine($my->id, $user->id); // Get the admin controls HTML data $adminControlHTML = ''; $tmpl = new CTemplate(); // get how many unread message $filter = array(); $inboxModel = CFactory::getModel('inbox'); $filter['user_id'] = $my->id; $unread = $inboxModel->countUnRead($filter); // get how many pending connection $friendModel = CFactory::getModel('friends'); $pending = $friendModel->countPending($my->id); $profile = JArrayHelper::toObject($data->profile); $profile->largeAvatar = $user->getAvatar(); $profile->defaultAvatar = $user->isDefaultAvatar(); $profile->status = $user->getStatus(); $profile->defaultCover = $user->isDefaultCover(); $profile->cover = $user->getCover(); $profile->coverPostion = $params->get('coverPosition', ''); if (strpos($profile->coverPostion, '%') === false) { $profile->coverPostion = 0; } $groupmodel = CFactory::getModel('groups'); $profile->_groups = $groupmodel->getGroupsCount($profile->id); $eventmodel = CFactory::getModel('events'); $profile->_events = $eventmodel->getEventsCount($profile->id); $profile->_friends = $user->_friendcount; $videoModel = CFactory::getModel('Videos'); $profile->_videos = $videoModel->getVideosCount($profile->id); $photosModel = CFactory::getModel('photos'); $profile->_photos = $photosModel->getPhotosCount($profile->id); if ($profile->status !== '') { $postedOn = new JDate($user->_posted_on); $postedOn = CActivityStream::_createdLapse($postedOn); $profile->posted_on = $user->_posted_on == '0000-00-00 00:00:00' ? '' : $postedOn; } else { $profile->posted_on = ''; } /* is featured */ $modelFeatured = CFactory::getModel('Featured'); $profile->featured = $modelFeatured->isExists(FEATURED_USERS, $profile->id); // Assign videoId $profile->profilevideo = $data->videoid; $video = JTable::getInstance('Video', 'CTable'); $video->load($profile->profilevideo); $profile->profilevideoTitle = $video->getTitle(); $addbuddy = "joms.api.friendAdd('{$profile->id}')"; $sendMsg = CMessaging::getPopup($profile->id); $config = CFactory::getConfig(); $jConfig = JFactory::getConfig(); $lastLogin = JText::_('COM_COMMUNITY_PROFILE_NEVER_LOGGED_IN'); if ($user->lastvisitDate != '0000-00-00 00:00:00') { $userLastLogin = new JDate($user->lastvisitDate); $lastLogin = CActivityStream::_createdLapse($userLastLogin); } // @todo : beside checking the owner, maybe we want to check for a cookie, // say every few hours only the hit get increment by 1. if (!$isMine) { $user->viewHit(); } // @rule: myblog integrations $showBlogLink = false; $myblog = CMyBlog::getInstance(); if ($config->get('enablemyblogicon') && $myblog) { if ($myblog->userCanPost($user->id)) { $showBlogLink = true; } $tmpl->set('blogItemId', $myblog->getItemId()); } $photoEnabled = $config->get('enablephotos') ? true : false; $eventEnabled = $config->get('enableevents') ? true : false; $groupEnabled = $config->get('enablegroups') ? true : false; $videoEnabled = $config->get('enablevideos') ? true : false; $isSEFEnabled = $jConfig->get('sef') ? true : false; $multiprofile = JTable::getInstance('MultiProfile', 'CTable'); $multiprofile->load($user->getProfileType()); CFactory::load('libraries', 'like'); $like = new Clike(); $isLikeEnabled = $like->enabled('profile') && $params->get('profileLikes', 1) ? 1 : 0; $isUserLiked = $like->userLiked('profile', $user->id, $my->id); /* likes count */ $likes = $like->getLikeCount('profile', $user->id); /* User status */ $status = new CUserStatus($user->id, 'profile'); //respect wall setting if ($my->id && (!$config->get('lockprofilewalls') || $config->get('lockprofilewalls') && CFriendsHelper::isConnected($my->id, $profile->id)) || COwnerHelper::isCommunityAdmin()) { // Add default status box CUserHelper::addDefaultStatusCreator($status); } //$isblocked = $user->isBlocked(); $isMine = COwnerHelper::isMine($my->id, $user->id); $isCommunityAdmin = COwnerHelper::isCommunityAdmin($user->id); // Check if user is blocked $getBlockStatus = new blockUser(); $isblocked = $getBlockStatus->isUserBlocked($user->id, 'profile'); // Get block user html //$blockUserHTML = $isMine || $isCommunityAdmin ? '' : CUserHelper::getBlockUserHTML($user->id, $isBlocked); $isMine = COwnerHelper::isMine($my->id, $user->id); $isCommunityAdmin = COwnerHelper::isCommunityAdmin($user->id); // Get reporting html $report = new CReportingLibrary(); $reportsHTML = $isMine ? '' : $report->getReportingHTML(JText::_('COM_COMMUNITY_REPORT_USER'), 'profile,reportProfile', array($user->id)); $tmpl = new CTemplate(); echo $tmpl->set('karmaImgUrl', CUserPoints::getPointsImage($user))->set('reportsHTML', $reportsHTML)->set('isMine', $isMine)->set('lastLogin', $lastLogin)->set('addBuddy', $addbuddy)->set('sendMsg', $sendMsg)->set('config', $config)->set('multiprofile', $multiprofile)->set('showBlogLink', $showBlogLink)->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id)->set('isWaitingApproval', CFriendsHelper::isWaitingApproval($my->id, $user->id))->set('isWaitingResponse', CFriendsHelper::isWaitingApproval($user->id, $my->id))->set('isBlocked', $isblocked)->set('profile', $profile)->set('unread', $unread)->set('pending', $pending)->set('registerDate', $user->registerDate)->set('adminControlHTML', $adminControlHTML)->set('userstatus', $status)->set('user', $user)->set('isUserLiked', $isUserLiked)->set('likes', $likes)->set('isLikeEnabled', $isLikeEnabled)->set('photoEnabled', $photoEnabled)->set('eventEnabled', $eventEnabled)->set('groupEnabled', $groupEnabled)->set('videoEnabled', $videoEnabled)->set('about', $this->_getProfileHTML($data->profile))->set('isSEFEnabled', $isSEFEnabled)->set('blocked', $user->isBlocked())->fetch('profile/focus'); }
/** * Show the main profile header */ public function _showHeader(&$data) { jimport('joomla.utilities.arrayhelper'); $my =& JFactory::getUser(); $userid = JRequest::getVar('userid', $my->id); $user = CFactory::getUser($userid); $params = $user->getParams(); $userModel = CFactory::getModel('user'); CFactory::load('libraries', 'messaging'); CFactory::load('helpers', 'owner'); $isMine = COwnerHelper::isMine($my->id, $user->id); // Get the admin controls HTML data $adminControlHTML = ''; $tmpl = new CTemplate(); // get how many unread message $filter = array(); $inboxModel = CFactory::getModel('inbox'); $filter['user_id'] = $my->id; $unread = $inboxModel->countUnRead($filter); // get how many pending connection $friendModel = CFactory::getModel('friends'); $pending = $friendModel->countPending($my->id); $profile = JArrayHelper::toObject($data->profile); $profile->largeAvatar = $user->getAvatar(); CFactory::load('libraries', 'activities'); $profile->status = $user->getStatus(); if ($profile->status !== '') { CFactory::load('libraries', 'activities'); $postedOn = new JDate($user->_posted_on); $postedOn = CActivityStream::_createdLapse($postedOn); $profile->posted_on = $user->_posted_on == '0000-00-00 00:00:00' ? '' : $postedOn; } else { $profile->posted_on = ''; } // Assign videoId $profile->profilevideo = $data->videoid; $video = JTable::getInstance('Video', 'CTable'); $video->load($profile->profilevideo); $profile->profilevideoTitle = $video->getTitle(); $addbuddy = "joms.friends.connect('{$profile->id}')"; $sendMsg = CMessaging::getPopup($profile->id); $config = CFactory::getConfig(); $lastLogin = JText::_('COM_COMMUNITY_PROFILE_NEVER_LOGGED_IN'); if ($user->lastvisitDate != '0000-00-00 00:00:00') { //$now =& JFactory::getDate(); $userLastLogin = new JDate($user->lastvisitDate); CFactory::load('libraries', 'activities'); $lastLogin = CActivityStream::_createdLapse($userLastLogin); } // @todo : beside checking the owner, maybe we want to check for a cookie, // say every few hours only the hit get increment by 1. if (!$isMine) { $user->viewHit(); } // @rule: myblog integrations $showBlogLink = false; CFactory::load('libraries', 'myblog'); $myblog =& CMyBlog::getInstance(); if ($config->get('enablemyblogicon') && $myblog) { if ($myblog->userCanPost($user->id)) { $showBlogLink = true; } $tmpl->set('blogItemId', $myblog->getItemId()); } $multiprofile =& JTable::getInstance('MultiProfile', 'CTable'); $multiprofile->load($user->getProfileType()); // Get like $likesHTML = ''; if ($user->getParams()->get('profileLikes', true)) { CFactory::load('libraries', 'like'); $likes = new CLike(); $likesHTML = $my->id == 0 ? $likes->getHtmlPublic('profile', $user->id) : $likes->getHTML('profile', $user->id, $my->id); } /* User status */ CFactory::load('libraries', 'userstatus'); $status = new CUserStatus($user->id, 'profile'); //respect wall setting CFactory::load('helpers', 'friends'); CFactory::load('helper', 'owner'); if ($my->id && (!$config->get('lockprofilewalls') || $config->get('lockprofilewalls') && CFriendsHelper::isConnected($my->id, $profile->id)) || COwnerHelper::isCommunityAdmin()) { // Add default status box CFactory::load('helpers', 'user'); CUserHelper::addDefaultStatusCreator($status); } $isblocked = $user->isBlocked(); return $tmpl->set('karmaImgUrl', CUserPoints::getPointsImage($user))->set('isMine', $isMine)->set('lastLogin', $lastLogin)->setRef('user', $user)->set('addBuddy', $addbuddy)->set('sendMsg', $sendMsg)->set('config', $config)->set('multiprofile', $multiprofile)->set('showBlogLink', $showBlogLink)->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id)->set('isBlocked', $isblocked)->set('profile', $profile)->set('unread', $unread)->set('pending', $pending)->set('registerDate', $user->registerDate)->set('adminControlHTML', $adminControlHTML)->set('likesHTML', $likesHTML)->set('userstatus', $status)->fetch('profile.header'); }