vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   [RELEASE] Show number of users in each group (https://vborg.vbsupport.ru/showthread.php?t=9749)

leadZERO 02-25-2001 01:38 PM

Someone asked for this hack, it was a simple thing so I took 10 minutes and coded it.

This will show the number of users in each group in the User Groups and Permissions -> Modify

#### Changes to "admin/usergroup.php" ####

~ Search for:
while ($usergroup=$DB_site->fetch_array($usergroups)) {

~ Add after:
//LEADZERO -- number of users per group hack
//ADD BLOCK
$q_id = $DB_site->query("SELECT username FROM user WHERE usergroupid=$usergroup[usergroupid]");
$mems = $DB_site->num_rows( $q_id );
//END ADD BLOCK

~ Replace:
echo "<li>$usergroup[title]".

~ With:
//CHANGE LINE
//WAS - echo "<li>$usergroup[title]".
echo "<li>$usergroup[title] - <i>$mems Members</i>".

02-25-2001 01:42 PM

Nice one and valuable. Thanks for sharing it with us. I'll try it on my test board this evening. :)

02-25-2001 02:06 PM

May I suggest changing

Code:

//LEADZERO -- number of users per group hack
//ADD BLOCK
$q_id = $DB_site->query("SELECT username FROM user WHERE usergroupid=$usergroup[usergroupid]");
$mems = $DB_site->num_rows( $q_id );
//END ADD BLOCK

to

Code:

//LEADZERO -- number of users per group hack
//ADD BLOCK
$q_id = $DB_site->query_first("SELECT COUNT(*) as count FROM user WHERE usergroupid=$usergroup[usergroupid]");
$mems = $q_id[count];
//END ADD BLOCK

Will be a wee bit faster for ya..

02-25-2001 02:15 PM

Hmmm...

Are you sure thats right? I tried it and now it doesn't show the number...

02-25-2001 02:35 PM

Looks right to my naked eye but if ya want you can replace your whole block of code in the modify section of usergroup.php with the following code. It is what will be in beta3/release (whichever it is)

Code:

  $usergroups=$DB_site->query("SELECT usergroup.usergroupid, usergroup.title, COUNT(user.userid) as count
                              FROM usergroup
                              LEFT JOIN user ON (user.usergroupid = usergroup.usergroupid)
                              GROUP BY usergroup.usergroupid
                              ORDER BY usergroup.title");

  echo "<table align=\"center\" bgcolor=\"black\" border=0 cellpadding=0 cellspacing=0><tr><td>";
  echo "<table border=0 cellspacing=1 cellpadding=4><tr bgcolor=\"#3F3849\"><td align=\"center\" colspan=4><FONT color=\"#BCB6CD\"><b>Usergroups</b></FONT></td></tr>\n";
  echo "<tr bgcolor=\"#51485F\"><td nowrap align=\"center\" width=\"100%\"><FONT color=\"#BCB6CD\">Usergroup</font></td><td align=\"center\" nowrap><FONT color=\"#BCB6CD\"># of Users</font></td><td align=\"center\" nowrap><FONT color=\"#BCB6CD\">Edit</font></td><td nowrap align=\"center\"><FONT color=\"#BCB6CD\">List Users</font></td></tr>\n";

  while ($usergroup=$DB_site->fetch_array($usergroups)) {

    echo "<tr bgcolor=\"#CCCCCC\"><td width=\"100%\">$usergroup[title]</td><td nowrap>$usergroup[count]</td><td nowrap>".
        makelinkcode("edit","usergroup.php?s=$session[sessionhash]&action=edit&usergroupid=$usergroup[usergroupid]").
                  iif($usergroup[usergroupid]>6,makelinkcode("remove","usergroup.php?s=$session[sessionhash]&action=remove&usergroupid=$usergroup[usergroupid]"),"")."</td><td nowrap>".
                makelinkcode("list all users","user.php?s=$session[sessionhash]&action=find&usergroupid=$usergroup[usergroupid]").
        "</td></tr>\n";
  }
  echo "</table></td></tr></table>\n";


03-01-2001 10:18 AM

I'm getting this error when I change it into that freddie:

: Using scalar variable $usergroup as an array or object in .. usergroup.php

03-01-2001 10:37 AM

fixed it... I forgot something :D


All times are GMT. The time now is 07:08 AM.

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.00935 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete