I'm actually working on this. XD
In theory, all we need to do is add a field to the "rank" table called "rankorder".
In the
insert block on the
/admincp/ranks.php, we need to add a field to this:
PHP Code:
$vbulletin->input->clean_array_gpc('p', array(
'ranklevel' => TYPE_UINT,
'minposts' => TYPE_UINT,
'rankimg' => TYPE_STR,
'usergroupid' => TYPE_INT,
'doinsert' => TYPE_STR,
'rankhtml' => TYPE_NOTRIM,
'stack' => TYPE_UINT,
'display' => TYPE_UINT,
));
This would be the field added
PHP Code:
'rankorder' => TYPE_UINT,
Then find this code in the same section
PHP Code:
/*insert query*/
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "ranks
(ranklevel, minposts, rankimg, usergroupid, type, stack, display)
VALUES
(
" . $vbulletin->GPC['ranklevel'] . ",
" . $vbulletin->GPC['minposts'] . ",
'" . $db->escape_string($vbulletin->GPC['rankimg']) . "',
" . $vbulletin->GPC['usergroupid'] . ",
$type,
" . $vbulletin->GPC['stack'] . ",
" . $vbulletin->GPC['display'] . "
)
");
and change it to
PHP Code:
/*insert query*/
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "ranks
(ranklevel, minposts, rankimg, usergroupid, type, stack, display, rankorder)
VALUES
(
" . $vbulletin->GPC['ranklevel'] . ",
" . $vbulletin->GPC['minposts'] . ",
'" . $db->escape_string($vbulletin->GPC['rankimg']) . "',
" . $vbulletin->GPC['usergroupid'] . ",
$type,
" . $vbulletin->GPC['stack'] . ",
" . $vbulletin->GPC['display'] . ",
" . $vbulletin->GPC['rankorder'] . "
)
");
That will take care of inserting the rank into the DB.
Now to edit existing ranks, find this in the
edit block on the same page:
PHP Code:
construct_hidden_code('rankid', $vbulletin->GPC['rankid']);
print_table_header(construct_phrase($vbphrase['x_y_id_z'], $vbphrase['user_rank'], '', $vbulletin->GPC['rankid']));
print_input_row($vbphrase['times_to_repeat_rank'], 'ranklevel', $ranks['ranklevel']);
print_chooser_row($vbphrase['usergroup'], 'usergroupid', 'usergroup', $ranks['usergroupid'], $vbphrase['all_usergroups']);
print_input_row($vbphrase['minimum_posts'], 'minposts', $ranks['minposts']);
print_yes_no_row($vbphrase['stack_rank'], 'stack', $ranks['stack']);
print_select_row($vbphrase['display_type'], 'display', $displaytype, $ranks['display']);
print_table_header($vbphrase['rank_type']);
print_input_row($vbphrase['user_rank_file_path'], 'rankimg', $rankimg);
print_input_row($vbphrase['or_you_may_enter_text'], 'rankhtml', $ranktext);
print_submit_row();
Before
print_submit_row(); (wherever you want it), add the line:
PHP Code:
print_input_row('Rank Order', 'rankorder', $ranks['rankorder']);
Next, in the
doupdate block of the same page, again find this code:
PHP Code:
$vbulletin->input->clean_array_gpc('p', array(
'ranklevel' => TYPE_UINT,
'minposts' => TYPE_UINT,
'rankimg' => TYPE_STR,
'usergroupid' => TYPE_INT,
'doinsert' => TYPE_STR,
'rankhtml' => TYPE_NOTRIM,
'stack' => TYPE_UINT,
'display' => TYPE_UINT,
));
and add in there
PHP Code:
'rankorder' => TYPE_UINT,
Then find
PHP Code:
$db->query_write("
UPDATE " . TABLE_PREFIX . "ranks
SET ranklevel = " . $vbulletin->GPC['ranklevel'] . ",
minposts = " . $vbulletin->GPC['minposts'] . ",
rankimg = '" . $db->escape_string($vbulletin->GPC['rankimg']) . "',
usergroupid = " . $vbulletin->GPC['usergroupid'] . ",
type = $type,
stack = " . $vbulletin->GPC['stack'] . ",
display = " . $vbulletin->GPC['display'] . "
WHERE rankid = " . $vbulletin->GPC['rankid'] . "
");
and edit is so:
PHP Code:
$db->query_write("
UPDATE " . TABLE_PREFIX . "ranks
SET ranklevel = " . $vbulletin->GPC['ranklevel'] . ",
minposts = " . $vbulletin->GPC['minposts'] . ",
rankimg = '" . $db->escape_string($vbulletin->GPC['rankimg']) . "',
usergroupid = " . $vbulletin->GPC['usergroupid'] . ",
type = $type,
stack = " . $vbulletin->GPC['stack'] . ",
display = " . $vbulletin->GPC['display'] . ",
display = " . $vbulletin->GPC['rankorder'] . "
WHERE rankid = " . $vbulletin->GPC['rankid'] . "
");
Now, you have to change the
build_ranks() function in
includes/functions_ranks.php. Look for
PHP Code:
// #################### Begin Build Ranks PHP Code function ################
function &build_ranks()
{
global $vbulletin;
$ranks = $vbulletin->db->query_read_slave("
SELECT ranklevel AS l, minposts AS m, rankimg AS i, type AS t, stack AS s, display AS d, ranks.usergroupid AS u
FROM " . TABLE_PREFIX . "ranks AS ranks
LEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup USING (usergroupid)
ORDER BY ranks.usergroupid DESC, minposts DESC
");
$rankarray = array();
while ($rank = $vbulletin->db->fetch_array($ranks))
{
$rankarray[] = $rank;
}
build_datastore('ranks', serialize($rankarray), 1);
return $rankarray;
}
We are going to change the
ORDER BY bit of the query to be
PHP Code:
// #################### Begin Build Ranks PHP Code function ################
function &build_ranks()
{
global $vbulletin;
$ranks = $vbulletin->db->query_read_slave("
SELECT ranklevel AS l, minposts AS m, rankimg AS i, type AS t, stack AS s, display AS d, ranks.usergroupid AS u
FROM " . TABLE_PREFIX . "ranks AS ranks
LEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup USING (usergroupid)
ORDER BY ranks.rankorder, ranks.usergroupid DESC, minposts DESC
");
$rankarray = array();
while ($rank = $vbulletin->db->fetch_array($ranks))
{
$rankarray[] = $rank;
}
build_datastore('ranks', serialize($rankarray), 1);
return $rankarray;
}
P.S.: I have NOT done this to my own forum yet, so I can only ASSUME this would work. I am also a vB Programming newbie, so there might be a much better, easier, faster way.
Figures, I actually came here because I was looking for help on how to update the rank display for a single user after changing said user's membergroupids. XD