Sure would be nice to get this tiny tweak added to the Group Manager.
I made a very minor modification to the Group Manager list which adds the total number of members in each of the groups listed.
Text Formatted Code
Edit Group Name Description Core Group Members
Edit All Users Group that a typical user is added to Yes Lst Edit (168)
Edit Block Admin Has full access to block features Yes Lst Edit (2)
Edit Calendar Admin Has full access to event features No Lst Edit (2)
Edit Club Members Group of people who are Club Members No Lst Edit (97)
etc....
It's a great way to quickly scan for groups that may have excessive number of members.
The code that does the work involved duplicating the grp_selectUsers() function from lib-admin.php and just return the count of members in the specified group, rather than the actual list of members. The function is below, and I added it to lib-custom.php.
Text Formatted Code
// This function counts all the users in the specified group. It's really just a copy of
// the function grp_selectUsers() that returns just the count, not the actual list of
// group members. So, the official solution would avoid duplicating the common
// part of this function.
// ------------------------------------------------------------------------------------------------------------
function CUST_grp_countUsers ($group_id, $allusers = false)
{
global $_TABLES, $_USER;
$retval = '';
// Get a list of users in the Root Group and the selected group
$sql = "SELECT DISTINCT uid FROM {$_TABLES['users']} LEFT JOIN {$_TABLES['group_assignments']} ";
$sql .= "ON {$_TABLES['group_assignments']}.ug_uid = uid WHERE uid > 1 AND ";
$sql .= "({$_TABLES['group_assignments']}.ug_main_grp_id = 1 OR {$_TABLES['group_assignments']}.ug_main_grp_id = $group_id)";
$result = DB_query ($sql);
$filteredusers = array();
while ($A = DB_fetchArray($result)) {
$filteredusers[] = $A['uid'];
}
$groups = getGroupList ($group_id);
$grouplist = '(' . implode (',', $groups) . ')';
$sql = "SELECT DISTINCT uid,username FROM {$_TABLES['users']} LEFT JOIN {$_TABLES['group_assignments']} ";
$sql .= "ON {$_TABLES['group_assignments']}.ug_uid = uid WHERE uid > 1 AND ";
$sql .= "{$_TABLES['group_assignments']}.ug_main_grp_id ";
if ($allusers) {
$sql .= 'NOT ';
}
$sql .= "IN {$grouplist} ";
// Filter out the users that will be in the selected group
if ($allusers) {
$filteredusers = implode(',',$filteredusers);
$sql .= " AND uid NOT IN ($filteredusers) ";
}
$sql .= "ORDER BY username";
$result = DB_query ($sql);
$numUsers = DB_numRows ($result);
return $numUsers;
}
To enable it, add a couple lines of code in ADMIN_getListField_groups() (in lib-admin.php).
Text Formatted Code
$countMembers = CUST_grp_countUsers($A['grp_id'], false);
, just include $countMembers in the retval string after the list and edit icons.
Text Formatted Code
case 'list':
if ($show_all_groups) {
$retval = "<a href=\"{$_CONF['site_admin_url']}/group.php?mode=listusers&grp_id={$A['grp_id']}&chk_showall=1\">"
."{$icon_arr['list']}</a> "
."<a href=\"{$_CONF['site_admin_url']}/group.php?mode=editusers&grp_id={$A['grp_id']}&chk_showall=1\">"
."{$icon_arr['edit']}</a> ({$countMembers})";
} else {
$retval = "<a href=\"{$_CONF['site_admin_url']}/group.php?mode=listusers&grp_id={$A['grp_id']}\">"
."{$icon_arr['list']}</a> "
."<a href=\"{$_CONF['site_admin_url']}/group.php?mode=editusers&grp_id={$A['grp_id']}\">"
."{$icon_arr['edit']}</a> ({$countMembers})";
}
break;