Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Sort View Forum Leaders VB 4.1.11 Details »»
Sort View Forum Leaders VB 4.1.11
Version: 1.00, by GrabMyWrist GrabMyWrist is offline
Developer Last Online: Mar 2016 Show Printable Version Email this Page

Category: Forum Display Enhancements - Version: 4.1.11 Rating:
Released: 03-14-2012 Last Update: Never Installs: 13
Re-useable Code Code Changes  
No support by the author.

This mod is fairly simple and straightforward.

First, you need to edit the title of the groups you want to display on showgroups.php. To do so you need to edit the group via Usergroups in the Control Panel.

Example:

Site Admin

Site Staff

Moderator

You need to place the following in front of the title of each usergroup you want displayed and sorted.

<! -- x -- >

x is replaced with a number of the order you wish for them to be displayed.


Example:

<! -- 1 -->Site Admin

<! -- 2 -->Site Staff

<! -- 3 -->Moderator


Also, ensure that each group is set to be "Viewable on Show Groups" under Usergroup Options of each group.

Finally, we have to remove the default Moderators list that appears on showgroups.php when you click View Forum Leaders.

To do this you need to edit showgroups.php directly.

Open showgroups.php in your forum root, find the following code and remove it.



Code:
{
	// get moderators **********************************************************
	$moderators = $db->query_read_slave("
		SELECT user.*,
			moderator.forumid,
			usertextfield.buddylist,
			" . ($show['locationfield'] ? 'userfield.field2,' : '') . "
			IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid
			" . ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight, customavatar.width_thumb AS avwidth_thumb, customavatar.height_thumb AS avheight_thumb, filedata_thumb, NOT ISNULL(customavatar.userid) AS hascustom" : "") . "
		$hook_query_fields
		FROM " . TABLE_PREFIX . "moderator AS moderator
		INNER JOIN " . TABLE_PREFIX . "user AS user USING(userid)
		INNER JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)
		INNER JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid=user.userid)
		" . ($vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "
		$hook_query_joins
		WHERE moderator.forumid <> -1
		$hook_query_where
	");
	$modcache = array();
	while ($moderator = $db->fetch_array($moderators))
	{
		if (!isset($modcache["$moderator[username]"]))
		{
			$modcache["$moderator[username]"] = $moderator;
		}
		$modcache["$moderator[username]"]['forums'][] = $moderator['forumid'];
	}
	unset($moderator);
	$db->free_result($moderators);

	if (is_array($modcache))
	{
		$showforums = true;
		uksort($modcache, 'strnatcasecmp'); // alphabetically sort moderator usernames
		foreach ($modcache AS $moderator)
		{
			$premodforums = array();
			foreach ($moderator['forums'] AS $forumid)
			{
				if ($vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['active'] AND (($vbulletin->forumcache["$forumid"]['showprivate'] > 1 OR (!$vbulletin->forumcache["$forumid"]['showprivate'] AND $vbulletin->options['showprivateforums'])) OR ($vbulletin->userinfo['forumpermissions']["$forumid"] & $vbulletin->bf_ugp_forumpermissions['canview'])))
				{
					$forumtitle = $vbulletin->forumcache["$forumid"]['title'];
					$premodforums["$forumid"] = $forumtitle;
				}
			}
			if (empty($premodforums))
			{
				continue;
			}

			$clc = 0;
			$modforums = array();
			uasort($premodforums, 'strnatcasecmp'); // alphabetically sort moderator usernames
			foreach($premodforums AS $forumid => $forumtitle)
			{
				$foruminfo = array(
					'forumid' => $forumid,
					'title'   => $forumtitle,
				);

				($hook = vBulletinHook::fetch_hook('showgroups_forum')) ? eval($hook) : false;

				$clc++;
				$foruminfo['comma'] = $vbphrase['comma_space'];
				$modforums[$clc] = $foruminfo;
			}

			// Last element
			if ($clc) 
			{
				$modforums[$clc]['comma'] = '';
			}

			$moderator = process_showgroups_userinfo($moderator);

			if ($vbulletin->options['enablepms'] AND $vbulletin->userinfo['permissions']['pmquota'] AND ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']
	 				OR ($moderator['receivepm'] AND $moderator['permissions']['pmquota']
	 				AND (!$moderator['receivepmbuddies'] OR can_moderate() OR strpos(" $moderator[buddylist] ", ' ' . $vbulletin->userinfo['userid'] . ' ') !== false))
	 		))
			{
				$show['pmlink'] = true;
			}
			else
			{
				$show['pmlink'] = false;
			}

			if ($moderator['showemail'] AND $vbulletin->options['displayemails'] AND (!$vbulletin->options['secureemail'] OR ($vbulletin->options['secureemail'] AND $vbulletin->options['enableemail'])) AND $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canemailmember'] AND $vbulletin->userinfo['userid'])
			{
				$show['emaillink'] = true;
			}
			else
			{
				$show['emaillink'] = false;
			}

			($hook = vBulletinHook::fetch_hook('showgroups_usergroup')) ? eval($hook) : false;

			$templater = vB_Template::create('showgroups_usergroupbit');
				$templater->register('modforums', $modforums);
				$templater->register('showforums', $showforums);
				$templater->register('user', $moderator); // Needs to be 'user' because we are using the same template as above.
				$templater->register('xhtml_id', ++$xhtmlid2);
			$moderatorbits .= $templater->render();
		}
	}
}

// *******************************************************

Screenshots

File Type: jpg Usergroup Edit 1.jpg (30.7 KB, 0 views)
File Type: jpg Usergroup Edit 2.jpg (10.5 KB, 0 views)
File Type: jpg View Forum Leaders.jpg (48.0 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
2 благодарности(ей) от:
nacaruncr, Popa Andrei

Comments
  #2  
Old 05-01-2012, 02:46 AM
deadlySniper deadlySniper is offline
 
Join Date: Dec 2008
Location: New York
Posts: 211
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So I did this and my groups dont show up in the order I have them. I started at 10 and went to 29. And it does it in the usergroup editor but not the forum leaders
Reply With Quote
  #3  
Old 06-03-2012, 10:20 AM
owning_y0u owning_y0u is offline
 
Join Date: Dec 2008
Location: Netherlands
Posts: 159
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Works like a charme :-) only its not updating directly. not a real problem tough :-P

Added the showgroups.php file to make it more easy for less advanced users.

the showgroups.php file is for vb 4.2 ONLY!
Attached Files
File Type: php showgroups.php (8.6 KB, 53 views)
Reply With Quote
  #4  
Old 06-13-2012, 10:11 PM
Popa Andrei's Avatar
Popa Andrei Popa Andrei is offline
 
Join Date: May 2008
Location: Romania/Petrosani
Posts: 367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Works like a charm,installed it and marked.
Reply With Quote
  #5  
Old 06-20-2012, 11:07 AM
1F42 1F42 is offline
 
Join Date: Mar 2003
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by deadlySniper View Post
So I did this and my groups dont show up in the order I have them. I started at 10 and went to 29. And it does it in the usergroup editor but not the forum leaders
Only works up to 9 as it seems to only recognise the first digit so 10 and 11 become equal to 1 and 25 or 29 would be seen equal to 2 so awkward to use if you have more than 9 usergroups.
Reply With Quote
  #6  
Old 10-18-2014, 04:52 PM
Voodoo262 Voodoo262 is offline
 
Join Date: Dec 2009
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you to GrabMyWrist for writing this up. I was able to set this mod up to my liking on our site. Here are a few notes for people that are having issues.

First of all, when using the HTML comments (<!-- x -->) to embed/define the sort order, remember that PHP (like most computer software) uses pure ASCII sorting, not numeric sorting, when sorting strings of characters. Therefore, "10" will come before "2" (because it compares "1" against "2"), "3456" will come before "7" (because it compares "3" against "7"), and so forth. If you want the mod to obey your sort order, all of the numbers must have the same number of digits. So if you have at least 10 usergroups you want to display, I would recommend using 2 digits for all the numbers, for example:
HTML Code:
<!-- 00 -->Administrators
<!-- 01 -->Super Moderators
<!-- 02 -->Moderators
etc

Second, when you modify your showgroups.php, make sure you also delete the "if" statement before the block of code that GrabMyWrist posted, otherwise you risk breaking the page completely due to syntax and/or runtime errors, because PHP will be interpreting the code as follows:
PHP Code:
if ($vbulletin->options['forumleaders'] == 1)
{
    
$navpopup = array(
        
'id'    => 'showgroups_navpopup',
        
'title' => $vbphrase['show_groups'],
        
'link'  => 'showgroups.php' $vbulletin->session->vars['sessionurl_q'],
    );

...Meaning it will only initialize and set the value of the $navpopup variable if the preceding condition is true. This is dangerous.

Here is the full block of code you'll want to delete. Actually, what I did was enclose it in comments by placing a "/*" before and a "*/" after, effectively accomplishing the same thing but without getting rid of the original code:
PHP Code:
if ($vbulletin->options['forumleaders'] == 1)
{
    
// get moderators **********************************************************
    
$moderators $db->query_read_slave("
        SELECT user.*,
            moderator.forumid,
            usertextfield.buddylist,
            " 
. ($show['locationfield'] ? 'userfield.field2,' '') . "
            IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid
            " 
. ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight, customavatar.width_thumb AS avwidth_thumb, customavatar.height_thumb AS avheight_thumb, filedata_thumb, NOT ISNULL(customavatar.userid) AS hascustom" "") . "
        
$hook_query_fields
        FROM " 
TABLE_PREFIX "moderator AS moderator
        INNER JOIN " 
TABLE_PREFIX "user AS user USING(userid)
        INNER JOIN " 
TABLE_PREFIX "userfield AS userfield ON(userfield.userid = user.userid)
        INNER JOIN " 
TABLE_PREFIX "usertextfield AS usertextfield ON(usertextfield.userid=user.userid)
        " 
. ($vbulletin->options['avatarenabled'] ? "LEFT JOIN " TABLE_PREFIX "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " TABLE_PREFIX "customavatar AS customavatar ON(customavatar.userid = user.userid)" "") . "
        
$hook_query_joins
        WHERE moderator.forumid <> -1
        
$hook_query_where
    "
);
    
$modcache = array();
    while (
$moderator $db->fetch_array($moderators))
    {
        if (!isset(
$modcache["$moderator[username]"]))
        {
            
$modcache["$moderator[username]"] = $moderator;
        }
        
$modcache["$moderator[username]"]['forums'][] = $moderator['forumid'];
    }
    unset(
$moderator);
    
$db->free_result($moderators);

    if (
is_array($modcache))
    {
        
$showforums true;
        
uksort($modcache'strnatcasecmp'); // alphabetically sort moderator usernames
        
foreach ($modcache AS $moderator)
        {
            
$premodforums = array();
            foreach (
$moderator['forums'] AS $forumid)
            {
                if (
$vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['active'] AND (($vbulletin->forumcache["$forumid"]['showprivate'] > OR (!$vbulletin->forumcache["$forumid"]['showprivate'] AND $vbulletin->options['showprivateforums'])) OR ($vbulletin->userinfo['forumpermissions']["$forumid"] & $vbulletin->bf_ugp_forumpermissions['canview'])))
                {
                    
$forumtitle $vbulletin->forumcache["$forumid"]['title'];
                    
$premodforums["$forumid"] = $forumtitle;
                }
            }
            if (empty(
$premodforums))
            {
                continue;
            }

            
$clc 0;
            
$modforums = array();
            
uasort($premodforums'strnatcasecmp'); // alphabetically sort moderator usernames
            
foreach($premodforums AS $forumid => $forumtitle)
            {
                
$foruminfo = array(
                    
'forumid' => $forumid,
                    
'title'   => $forumtitle,
                );

                (
$hook vBulletinHook::fetch_hook('showgroups_forum')) ? eval($hook) : false;

                
$clc++;
                
$foruminfo['comma'] = $vbphrase['comma_space'];
                
$modforums[$clc] = $foruminfo;
            }

            
// Last element
            
if ($clc
            {
                
$modforums[$clc]['comma'] = '';
            }

            
$moderator process_showgroups_userinfo($moderator);

            if (
$vbulletin->options['enablepms'] AND $vbulletin->userinfo['permissions']['pmquota'] AND ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']
                     OR (
$moderator['receivepm'] AND $moderator['permissions']['pmquota']
                     AND (!
$moderator['receivepmbuddies'] OR can_moderate() OR strpos($moderator[buddylist] "' ' $vbulletin->userinfo['userid'] . ' ') !== false))
             ))
            {
                
$show['pmlink'] = true;
            }
            else
            {
                
$show['pmlink'] = false;
            }

            if (
$moderator['showemail'] AND $vbulletin->options['displayemails'] AND (!$vbulletin->options['secureemail'] OR ($vbulletin->options['secureemail'] AND $vbulletin->options['enableemail'])) AND $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canemailmember'] AND $vbulletin->userinfo['userid'])
            {
                
$show['emaillink'] = true;
            }
            else
            {
                
$show['emaillink'] = false;
            }

            (
$hook vBulletinHook::fetch_hook('showgroups_usergroup')) ? eval($hook) : false;

            
$templater vB_Template::create('showgroups_usergroupbit');
                
$templater->register('modforums'$modforums);
                
$templater->register('showforums'$showforums);
                
$templater->register('user'$moderator); // Needs to be 'user' because we are using the same template as above.
                
$templater->register('xhtml_id', ++$xhtmlid2);
            
$moderatorbits .= $templater->render();
        }
    }
}

// ******************************************************* 


Finally, after you have updated the usergroup titles, you'll have to reset the group cache in order for the sorting to take effect. This can be accomplished by running the following SQL query. The cache will be rebuilt the next time you reload the page:
Code:
delete from cache where cacheid = 'showgroups.groupcache';

I have attached my version of showgroups.php (vB 4.2.2) for your convenience (make sure you update your vBulletin License at the top). It also includes another optimization that moves the sorting from the PHP into the MySQL (because after all, what's the point of caching if you're gonna sort the cache every time anyways? )

This ends today's programming lesson
Attached Files
File Type: php showgroups.php (13.2 KB, 16 views)
Reply With Quote
  #7  
Old 10-18-2014, 05:52 PM
tme_power tme_power is offline
 
Join Date: Sep 2006
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looking for this a while ago, cant do it myself. Work like a charm.
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 09:16 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.04584 seconds
  • Memory Usage 2,376KB
  • Queries Executed 23 (?)
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
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (2)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (6)postbit
  • (5)postbit_attachment
  • (7)postbit_onlinestatus
  • (7)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_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
  • 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
  • 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_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete