Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
Prev Previous Post   Next Post Next
  #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
 

Thread Tools
Display Modes

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 06:45 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06552 seconds
  • Memory Usage 3,314KB
  • Queries Executed 13 (?)
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
  • (2)bbcode_code
  • (12)bbcode_php
  • (13)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (26)post_thanks_box
  • (7)post_thanks_box_bit
  • (26)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit
  • (26)post_thanks_postbit_info
  • (26)postbit
  • (2)postbit_attachment
  • (26)postbit_onlinestatus
  • (26)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • 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_threaded
  • showthread_threaded_construct_link
  • 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
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete