Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 12-30-2015, 08:00 PM
CAG CheechDogg's Avatar
CAG CheechDogg CAG CheechDogg is offline
 
Join Date: Feb 2012
Location: Riverside, California USA
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Mark sorry to highjack this thread ...but how about to show only 1 usergroup even if they belong to a secondary usergroup?
Reply With Quote
  #12  
Old 12-30-2015, 09:11 PM
Dragonsys's Avatar
Dragonsys Dragonsys is offline
 
Join Date: Jan 2008
Location: DFW, Texas
Posts: 743
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CAG CheechDogg View Post
Mark sorry to highjack this thread ...but how about to show only 1 usergroup even if they belong to a secondary usergroup?
it doesn't display usergroups. Are you wanting to show all member of only 1 specific group? If so, change the query to this:
Code:
$users_visited = $vbulletin->db->query_read(" 
    SELECT user.* 
    FROM " . TABLE_PREFIX . "user AS user 
    WHERE lastvisit >= " . TIMENOW . " - " . 7 * 86400 . " 
    AND usergroupid = _YOURUSERGROUP_
    ORDER BY lastvisit DESC 
");
change _YOURUSERGROUP_ to the group ID you want to show
Reply With Quote
Благодарность от:
CAG CheechDogg
  #13  
Old 12-30-2015, 09:43 PM
CAG CheechDogg's Avatar
CAG CheechDogg CAG CheechDogg is offline
 
Join Date: Feb 2012
Location: Riverside, California USA
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dragonsys View Post
it doesn't display usergroups. Are you wanting to show all member of only 1 specific group? If so, change the query to this:
Code:
$users_visited = $vbulletin->db->query_read(" 
    SELECT user.* 
    FROM " . TABLE_PREFIX . "user AS user 
    WHERE lastvisit >= " . TIMENOW . " - " . 7 * 86400 . " 
    AND usergroupid = _YOURUSERGROUP_
    ORDER BY lastvisit DESC 
");
change _YOURUSERGROUP_ to the group ID you want to show
What I was really looking for is to show members of a specific usergroup who are online now. I have members who belong to usergroup "Officers" and would like to show them online now if they are online now kind of like they are staff who are online so that members can contact them if they have questions... know what I mean?
Reply With Quote
  #14  
Old 12-30-2015, 10:10 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CAG CheechDogg View Post
What I was really looking for is to show members of a specific usergroup who are online now. I have members who belong to usergroup "Officers" and would like to show them online now if they are online now kind of like they are staff who are online so that members can contact them if they have questions... know what I mean?
When I am in for the night, I will post the code to display members of a certain usergroup who are online at the moment.
Reply With Quote
  #15  
Old 12-30-2015, 11:45 PM
CAG CheechDogg's Avatar
CAG CheechDogg CAG CheechDogg is offline
 
Join Date: Feb 2012
Location: Riverside, California USA
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
When I am in for the night, I will post the code to display members of a certain usergroup who are online at the moment.
Good stuff Mark thank you so much !!!!!!

:up::up::up:
Reply With Quote
Благодарность от:
setishock
  #16  
Old 12-31-2015, 12:06 AM
setishock setishock is offline
 
Join Date: Feb 2008
Location: Houma, La.
Posts: 1,177
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I wasn't paying attention and just put in the change you made to weed out banned members. It gave me a server error. Had one of those DOH moments. When I replaced the old with the new in its entirety, it worked as advertised. Now all that shows is me and the supermod and the folks that just signed up for S&G.

Thanks again. If I could program like you my Arduino wouldn't be sitting on my desk gathering dust.
Reply With Quote
  #17  
Old 12-31-2015, 05:33 AM
CAG CheechDogg's Avatar
CAG CheechDogg CAG CheechDogg is offline
 
Join Date: Feb 2012
Location: Riverside, California USA
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
When I am in for the night, I will post the code to display members of a certain usergroup who are online at the moment.
Any progress on this Senor Mark?
Reply With Quote
  #18  
Old 12-31-2015, 05:42 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CAG CheechDogg View Post
Any progress on this Senor Mark?
I had some buddies show up unexpectedly tonight, and many beers were quaffed, and I decided to put off anything serious until tomorrow.

--------------- Added [DATE]1451590749[/DATE] at [TIME]1451590749[/TIME] ---------------

Quote:
Originally Posted by CAG CheechDogg View Post
Any progress on this Senor Mark?
You will likely want to set "Cache Time (in minutes)" to 0 so that this information is always current. This is the PHP content I used on my dev site to show all Math Helpers currently online:

PHP Code:
global $vbulletin$db;
$groupid 13;
$groupname 'Math Helpers';
$output '<div class="restore"><ul>';

$users_online $vbulletin->db->query_read("
    SELECT user.*, session.loggedin
    FROM " 
TABLE_PREFIX "user AS user
    INNER JOIN " 
TABLE_PREFIX "session AS session
    ON session.userid = user.userid
    WHERE (user.usergroupid = " 
$groupid "
    OR " 
$groupid " IN (user.membergroupids))
    AND session.loggedin > 0
    ORDER BY user.lastactivity DESC
"
);

$count 0;
while (
$member $db->fetch_array($users_online))
{
    
$output .= '<li>' helper_link($member$member['lastactivity']) . '</li>';
    
$count++;
}

$output .= '</ul></div>';

$output '<div style="text-align: center; font-weight: bold; margin-bottom: 1em">' $count ' ' $groupname ' Online</div>' $output;

return 
$output;

function 
helper_link($user_name$dateline)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user_name['username'];

    if (
$user_name['displaygroupid'])
    {
        
$groupid $user_name['displaygroupid'];
    }
    else
    {
        
$groupid $user_name['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Last Activity: ' vbdate($vbulletin->options['dateformat'], $dateline1) . ' at ' vbdate($vbulletin->options['timeformat'], $dateline);
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user_name['username'] . $close_tag '</a>';

You will want to edit these two lines near the top:

PHP Code:
$groupid 13;
$groupname 'Math Helpers'
to use the groupid and groupname of your choice.

This will list all users currently online who are a member of the selected usergroupid, and list them in descending order by the time of their last activity.

I should also add, that if you wish to use multiple groupids (and have user avatars displayed), I recommend checking out Joe's (BirdOPrey5) product here:

Current Staff Online Forum Sideblock and CMS Widget by BOP5
Reply With Quote
Благодарность от:
Dragonsys
  #19  
Old 01-01-2016, 04:35 PM
CAG CheechDogg's Avatar
CAG CheechDogg CAG CheechDogg is offline
 
Join Date: Feb 2012
Location: Riverside, California USA
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
I had some buddies show up unexpectedly tonight, and many beers were quaffed, and I decided to put off anything serious until tomorrow.

--------------- Added [DATE]1451590749[/DATE] at [TIME]1451590749[/TIME] ---------------



You will likely want to set "Cache Time (in minutes)" to 0 so that this information is always current. This is the PHP content I used on my dev site to show all Math Helpers currently online:

PHP Code:
global $vbulletin$db;
$groupid 13;
$groupname 'Math Helpers';
$output '<div class="restore"><ul>';

$users_online $vbulletin->db->query_read("
    SELECT user.*, session.loggedin
    FROM " 
TABLE_PREFIX "user AS user
    INNER JOIN " 
TABLE_PREFIX "session AS session
    ON session.userid = user.userid
    WHERE (user.usergroupid = " 
$groupid "
    OR " 
$groupid " IN (user.membergroupids))
    AND session.loggedin > 0
    ORDER BY user.lastactivity DESC
"
);

$count 0;
while (
$member $db->fetch_array($users_online))
{
    
$output .= '<li>' helper_link($member$member['lastactivity']) . '</li>';
    
$count++;
}

$output .= '</ul></div>';

$output '<div style="text-align: center; font-weight: bold; margin-bottom: 1em">' $count ' ' $groupname ' Online</div>' $output;

return 
$output;

function 
helper_link($user_name$dateline)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user_name['username'];

    if (
$user_name['displaygroupid'])
    {
        
$groupid $user_name['displaygroupid'];
    }
    else
    {
        
$groupid $user_name['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Last Activity: ' vbdate($vbulletin->options['dateformat'], $dateline1) . ' at ' vbdate($vbulletin->options['timeformat'], $dateline);
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user_name['username'] . $close_tag '</a>';

You will want to edit these two lines near the top:

PHP Code:
$groupid 13;
$groupname 'Math Helpers'
to use the groupid and groupname of your choice.

This will list all users currently online who are a member of the selected usergroupid, and list them in descending order by the time of their last activity.

I should also add, that if you wish to use multiple groupids (and have user avatars displayed), I recommend checking out Joe's (BirdOPrey5) product here:

Current Staff Online Forum Sideblock and CMS Widget by BOP5
TY Mark ... I tried using BOP5's CSOFS mod on my site but for some reason it doesn't work ....

--------------- Added [DATE]1451683913[/DATE] at [TIME]1451683913[/TIME] ---------------

Mark ..is it possible to edit this so that when there is only one member of said group it says "1 Officer Online" when there is only one member (Officer) instead of "1 Officers Online"

--------------- Added [DATE]1451685439[/DATE] at [TIME]1451685439[/TIME] ---------------

Ooops ...nevermind Mark ...this doesn't work with for additional usergroups .... it will only display members of the primary usergroup .... can this be modified to show members if they also have the groupid as the additional usergroup?

--------------- Added [DATE]1451685565[/DATE] at [TIME]1451685565[/TIME] ---------------

Or allow to do an array of group ids?

--------------- Added [DATE]1451692168[/DATE] at [TIME]1451692168[/TIME] ---------------

Bummer !!! This works but for some reason it works for some of the members and not others ... at one point it listed one member 10 times ...

--------------- Added [DATE]1451692371[/DATE] at [TIME]1451692371[/TIME] ---------------

This is what is happening:

Reply With Quote
Благодарность от:
MarkFL
  #20  
Old 01-02-2016, 01:20 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did not realize there were new posts in this thread because of doublepost merges. Sorry about that. To allow multiple usergroups and to prevent repetition, try this (of course edit the $groupid/$groupname definitions):

PHP Code:
global $vbulletin$db;
$groupid '6,13';
$groupname 'Math Helpers/Administrators';
$output '<div class="restore"><ul>';

$groupid_arr explode(','$groupid);
$qwhere '';

foreach (
$groupid_arr AS $id)
{
    
$qwhere .= 'OR ' $id ' IN (user.membergroupids) ';
}

$users_online $vbulletin->db->query_read("
    SELECT user.*, session.loggedin
    FROM " 
TABLE_PREFIX "user AS user
    INNER JOIN " 
TABLE_PREFIX "session AS session
    ON session.userid = user.userid
    WHERE user.usergroupid IN (" 
$groupid ")
    " 
$qwhere "
    AND session.loggedin > 0
    GROUP BY user.userid
    ORDER BY user.lastactivity DESC
"
);

$count 0;
while (
$member $db->fetch_array($users_online))
{
    
$output .= '<li>' helper_link($member$member['lastactivity']) . '</li>';
    
$count++;
}

$output .= '</ul></div>';

$output '<div style="text-align: center; font-weight: bold; margin-bottom: 1em">' $count ' ' $groupname ' Online</div>' $output;

return 
$output;

function 
helper_link($user_name$dateline)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user_name['username'];

    if (
$user_name['displaygroupid'])
    {
        
$groupid $user_name['displaygroupid'];
    }
    else
    {
        
$groupid $user_name['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Last Activity: ' vbdate($vbulletin->options['dateformat'], $dateline1) . ' at ' vbdate($vbulletin->options['timeformat'], $dateline);
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user_name['username'] . $close_tag '</a>';

Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:36 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09509 seconds
  • Memory Usage 2,372KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (5)bbcode_php
  • (8)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (4)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete