Hello,
I am trying to get online users for each group, what I have done till now is this
in my plugin:
elgg_extend_view('groups/right_column', 'groupusers/online_users');
in my online_users file this is the code:
<div class="group_widget">
<h2><?php echo rozce_echo('Online Users'); ?></h2>
<?php
$count = count(find_active_group_users(600, 9999));
$members = find_active_group_users(1200,16,0);
if($members) {
echo rozce_view_entity_list($members, $count,0,10,false);
}
?>
</div>
what I was thinking was adding a new function called find_active_group_users this will extend over the core find_active_users , but I am having trouble getting the online users for groups
this is function of find_active_group_users:
function find_active_group_users($seconds = 600, $limit = 10, $offset = 0, $group_guid) {
global $CONFIG;
$seconds = (int)$seconds;
$limit = (int)$limit;
$offset = (int)$offset;
$time = time() - $seconds;
$access = get_access_sql_suffix("e");
$query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid where u.last_action >= {$time} and $access and e.container_guid = {$group_guid} order by u.last_action desc limit {$offset},{$limit}";
return get_data($query, "entity_row_to_rozcestar");
}
what do I change in the SQL to add group context in it ?
Please help out,
Regards,
Aimash
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Brett@brett.profitt
Brett - 0 likes
- aimash@aimthemask
aimash - 0 likes
- aimash@aimthemask
aimash - 0 likes
- aimash@aimthemask
aimash - 0 likes
- Cash@costelloc
Cash - 0 likes
- aimash@aimthemask
aimash - 0 likes
- Brett@brett.profitt
Brett - 0 likes
You must log in to post replies.Users aren't contained by the group. If this were so, each user would only be able to be in a single group! Group membership is determined by the relationships table. To get the users only for a current group, you'll have to join with the relationship table where guid1 is the user guid, relationship is 'member' and guid2 is the group guid.
can you please tell me what will the query will be then ?I am having trouble making this complex query can anyone please tell me , what the query will be ?
any one ? figured it out yet ? how to join the relationships table in this query and then filter users per group ?
does any one know what the query will be :s ? this is not hard , I just dont have the expertise in this area :/ please help me some1
Here is a link to a MYSQL tutorial: http://www.tizag.com/mysqlTutorial/. It has a section on joins.
The information about active users is in the user entities table and the group membership is in the relationships table as Brett pointed out.
If you didn't want to learn MYSQL, you could grab all the users that belong to a group and then sort in PHP by last_action.
Hello Cash and Brett, thanks for you support , I was able to do this ;) , I will share this with the community soon, I have made around 10 new mods which I will upload to the community soon ;)
aimash - Glad it worked!