Requirement: XThreads
Based On: Dynamic Board Stats
Just a plugin that I want to share that will hide all users in Awaiting Activation usergroup from member list.
Note:
- inline_action in AdminCP isn't covered by this plugin.
- Run the Recount Statistics tools to synchronized the additional cache with the actual data if needed.
- Admin not affected by this plugin.
Please tell me if there is something wrong with the code.
I'm still learning

Wow, nice work RateU
I probably wouldn't have made it as complex as you did (I'd just overwrite the MyBB cache directly), so good work on the effort you put in!
I changed up the xtmn_hnau_stats function to also replace the number of registered users to the ones that are currently activated. There's probably a more efficient way to count up all the activated users.
PHP Code:
function xtmn_hnau_stats(){
if($GLOBALS['mybb']->usergroup['cancp'] != 1){
$lastreguser = $GLOBALS['cache']->read('xtmn_hnau_last_reg_users');
if(!is_array($GLOBALS['stats'])) $GLOBALS['stats'] = $GLOBALS['cache']->read('stats');
$GLOBALS['stats']['lastuid'] = $lastreguser['lastuid'];
$GLOBALS['stats']['lastusername'] = $lastreguser['lastusername'];
$GLOBALS['cache']->cache['stats'] = $GLOBALS['stats'];
$query = $GLOBALS['db']->simple_select('users','COUNT(*) AS num_users','usergroup!=5');
$activeusercount = $GLOBALS['db']->fetch_field($query, 'num_users');
$GLOBALS['stats']['numusers'] = $activeusercount;
$GLOBALS['cache']->cache['stats'] = $GLOBALS['stats'];
}
}
|
Do a select COUNT(*) (also, ordering doesn't make any sense here)
PHP Code:
$query = $GLOBALS['db']->simple_select('users','COUNT(*) AS num_users','usergroup!=5');
$activeusercount = $GLOBALS['db']->fetch_field($query, 'num_users');
|
Note that you may wish to put an index on the usergroup column if you do this, as the query can be slow if there are a lot of users.
(04-05-2012 04:54 PM)ZiNgA BuRgA Wrote: [ -> ]Do a select COUNT(*) (also, ordering doesn't make any sense here)
PHP Code:
$query = $GLOBALS['db']->simple_select('users','COUNT(*) AS num_users','usergroup!=5');
$activeusercount = $GLOBALS['db']->fetch_field($query, 'num_users');
|
Note that you may wish to put an index on the usergroup column if you do this, as the query can be slow if there are a lot of users.
Updated the modification I made earlier to use that method for counting the number of active users. As for the indexing, I would set it up like this, correct?:
PHP Code:
function xtmn_hnau_activate(){
xtmn_hnau_deactivate();
if(!$db->is_fulltext("users") && $db->supports_fulltext_boolean("users"))
{
$db->create_fulltext_index("users", "usergroup","activeuser");
}
xtmn_hnau_last_reg_users();
}
function xtmn_hnau_deactivate(){
if(is_object($GLOBALS['cache']->handler)){
$GLOBALS['cache']->handler->delete('xtmn_hnau_last_reg_users');
}
$GLOBALS['db']->delete_query('datacache','title="xtmn_hnau_last_reg_users"');
if($db->is_fulltext("users"))
{
$db->drop_index("users","activeuser");
}
}
|
No.
Please read up on MySQL indexing. Full text indexing is something completely different.
It would be something like
PHP Code:
$db->write_query('ALTER TABLE '.TABLE_PREFIX.'users ADD KEY `usergroup`(`usergroup`)');
|
EDIT: actually scrap that, MyBB already has an index on the usergroup column, never knew that.
In other words, you don't need to add the index.
Update:
Count the number of registered users in the Board Stats.
To upgrade, replace the old version with the new one.
Run the
Recount Statistics tools.
Thanks, Yumi, ShadowKyogre
