The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Nov 01, 2011 3:21 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Nov 01, 2011 12:14 pm
Posts: 2
Hi,

Module "Who is online" can display usernames but not real names. I have found several hacks to change that, but none corresponds to my config. Not sure if this is because I use Joomla! 1.7 or Kunena (may be it modifies this module?). :'(

I have been able to display real names thansk to the following hack. I am not an expert, so if you identify a bug in the code please tell me! Anyhow it works for me and does not seem to generate issues with other modules or extensions. :)

1) In (site)\modules\mod_whosonline\helper.php, change :

static function getOnlineUserNames() {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.username, a.time, a.userid, a.usertype, a.client_id');
$query->from('#__session AS a');
$query->where('a.userid != 0');
$query->where('a.client_id = 0');
$query->group('a.userid');
$db->setQuery($query);
return (array) $db->loadObjectList();
}

Replace by :

static function getOnlineUserNames() {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('u.name, u.id, a.username, a.userid');
$query->from('#__users AS u');
$query->innerjoin('#__session AS a ON u.id = a.userid');
$query->where('a.userid != 0');
$query->where('a.client_id = 0');
$db->setQuery($query);
return (array) $db->loadObjectList();
}


2) In (site)\modules\mod_whosonline\tmpl\default.php :

Replace “username” by “name” in following line (twice, lines 27 and 30) :
<?php echo $name->username; ?>
becomes
<?php echo $name->name; ?>


I have already received a lot from Joomla forums, I am glad I can give a bit now ! :p


Top
 Profile  
 
PostPosted: Mon Jan 09, 2012 1:38 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Jan 27, 2008 11:09 am
Posts: 3
This is just what I was looking for ...and it works!

Thank you! :)


Top
 Profile  
 
PostPosted: Sat Feb 04, 2012 6:06 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 12, 2010 8:46 pm
Posts: 7
how would i do this with the new 2.5 version?

there I have:

static function getOnlineUserNames($params) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.username, a.time, a.userid, a.usertype, a.client_id');
$query->from('#__session AS a');
$query->where('a.userid != 0');
$query->where('a.client_id = 0');
$query->group('a.userid');
$user = JFactory::getUser();
if (!$user->authorise('core.admin') && $params->get('filter_groups', 0) == 1)
{
$groups = $user->getAuthorisedGroups();
if (empty($groups))
{
return array();
}
$query->leftJoin('#__user_usergroup_map AS m ON m.user_id = a.userid');
$query->leftJoin('#__usergroups AS ug ON ug.id = m.group_id');
$query->where('ug.id in (' . implode(',', $groups) . ')');
$query->where('ug.id <> 1');
}
$db->setQuery($query);
return (array) $db->loadObjectList();


? Thanks in advance, I cant find the innerjoin query...


Top
 Profile  
 
PostPosted: Wed Feb 08, 2012 6:50 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 12, 2010 8:46 pm
Posts: 7
bump

Does anyone have a solution for this. I would greatly appreciate it.


Top
 Profile  
 
PostPosted: Wed Feb 08, 2012 7:03 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Nov 01, 2011 12:14 pm
Posts: 2
I have not yet tested on J2.5, but as soon as I can I will, as I am interested too. Don't expect a solution in the very short term though, I am too busy with other issues right now.
Any help from the community?


Top
 Profile  
 
PostPosted: Sun Feb 12, 2012 11:01 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Feb 12, 2012 10:41 am
Posts: 1
1) In (site)\modules\mod_whosonline\helper.php, change :

// show online member names
static function getOnlineUserNames($params) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.username, a.time, a.userid, a.usertype, a.client_id');
$query->from('#__session AS a');
$query->where('a.userid != 0');
$query->where('a.client_id = 0');
$query->group('a.userid');
$user = JFactory::getUser();
if (!$user->authorise('core.admin') && $params->get('filter_groups', 0) == 1)
{
$groups = $user->getAuthorisedGroups();
if (empty($groups))
{
return array();
}
$query->leftJoin('#__user_usergroup_map AS m ON m.user_id = a.userid');
$query->leftJoin('#__usergroups AS ug ON ug.id = m.group_id');
$query->where('ug.id in (' . implode(',', $groups) . ')');
$query->where('ug.id <> 1');
}
$db->setQuery($query);
return (array) $db->loadObjectList();
}
}

Replace by :

// show online member names
static function getOnlineUserNames() {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('u.name, u.id, a.username, a.userid');
$query->from('#__users AS u');
$query->innerjoin('#__session AS a ON u.id = a.userid');
$query->where('a.userid != 0');
$query->where('a.client_id = 0');
$user = JFactory::getUser();
if (!$user->authorise('core.admin') && $params->get('filter_groups', 0) == 1)
{
$groups = $user->getAuthorisedGroups();
if (empty($groups))
{
return array();
}
$query->leftJoin('#__user_usergroup_map AS m ON m.user_id = a.userid');
$query->leftJoin('#__usergroups AS ug ON ug.id = m.group_id');
$query->where('ug.id in (' . implode(',', $groups) . ')');
$query->where('ug.id <> 1');
}
$db->setQuery($query);
return (array) $db->loadObjectList();
}
}

2) In (site)\modules\mod_whosonline\tmpl\default.php :

Replace “username” by “name” in following line (at line 26):
<?php echo $name->username; ?>
becomes
<?php echo $name->name; ?>

ENJOY!


Top
 Profile  
 
PostPosted: Fri Feb 24, 2012 9:23 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 12, 2010 8:46 pm
Posts: 7
Almost, you forgot to pass $params into the function.
1)
static function getOnlineUserNames($params) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('u.name, u.id, a.username, a.userid');
$query->from('#__users AS u');
$query->innerjoin('#__session AS a ON u.id = a.userid');
$query->where('a.userid != 0');
$query->where('a.client_id = 0');
$user = JFactory::getUser();
if (!$user->authorise('core.admin') && $params->get('filter_groups', 0) == 1)
{
$groups = $user->getAuthorisedGroups();
if (empty($groups))
{
return array();
}
$query->leftJoin('#__user_usergroup_map AS m ON m.user_id = a.userid');
$query->leftJoin('#__usergroups AS ug ON ug.id = m.group_id');
$query->where('ug.id in (' . implode(',', $groups) . ')');
$query->where('ug.id <> 1');
}
$db->setQuery($query);
return (array) $db->loadObjectList();
}
}

2) In (site)\modules\mod_whosonline\tmpl\default.php :

Replace “username” by “name” in following line (at line 26):
<?php echo $name->username; ?>
becomes
<?php echo $name->name; ?>


Top
 Profile  
 
PostPosted: Tue Apr 30, 2013 9:54 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri May 04, 2007 12:29 pm
Posts: 185
Location: Erie, PA
Can anyone help me figure out how to do this with an override? I have added the default.php page to my templates html/mod_whosonline folder and that works fine, but where does the helper file go? I have it in the same folder now, but that doesn't work.

Thanks
Dan

_________________
Dan Riefstahl
Pixel Point Creative
Your Image is our Mission™
http://www.pixelpointcreative.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 



Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group