The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Sort View Forum Leaders VB 4.1.11 Details »» | |||||||||||||||||||||||||||||||
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
Show Your Support
|
2 благодарности(ей) от: | ||
nacaruncr, Popa Andrei |
Comments |
#2
|
|||
|
|||
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
|
#3
|
|||
|
|||
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! |
#4
|
||||
|
||||
Works like a charm,installed it and marked.
|
#5
|
|||
|
|||
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.
|
#6
|
|||
|
|||
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:
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:
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 |
#7
|
|||
|
|||
Looking for this a while ago, cant do it myself. Work like a charm.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|