View Full Version : where do I change the order of rank images?
Keyser520
03-02-2006, 01:44 PM
It currently displays them as Last added, First shown, but I want it to happen in the reverse order. Does anyone know what function/script calls the display rank function and/or how to make this happen?
Thanks,
Sculli
03-02-2006, 05:47 PM
I would like to know as well. It doesn't seem like too complicated of an issue, clearly the current order must be stored somewhere. Does anyone know in which template that would be?
Keyser520
03-02-2006, 05:49 PM
I had this posted for a week on vbulletin.com before someone told me that no one there would answer it. I'm trying my luck here.
Kihon Kata
04-18-2006, 12:56 PM
BUMP, I need to know this also. It cannot be too difficult
Keyser520
04-18-2006, 05:39 PM
It appears that the only place this shows up in the templates is..
<if condition="$post['usertitle']"><div class="smallfont">$post[usertitle]</div></if>
<if condition="$post['rank']"><div class="smallfont">$post[rank]</div></if>
I'm guessing that this means that "rank" is a variable in the db, which makes sense as you have to update ranks sometimes.
What I need to know is where the function that writes the ranks is. All I want to do is REVERSE the order that it writes them...
Kihon Kata
04-18-2006, 06:15 PM
It appears that the only place this shows up in the templates is..
<if condition="$post['usertitle']"><div class="smallfont">$post[usertitle]</div></if>
<if condition="$post['rank']"><div class="smallfont">$post[rank]</div></if>
I'm guessing that this means that "rank" is a variable in the db, which makes sense as you have to update ranks sometimes.
What I need to know is where the function that writes the ranks is. All I want to do is REVERSE the order that it writes them...
I think the issue is that $post[rank] represents 1 rank or 2 ranks(if using stacked ranks)
I'm sure someon can fix this
majorxp
05-31-2006, 08:49 PM
I'm looking for same...
lheliosl
05-09-2007, 10:09 PM
wow anyone?
tarionyx
05-31-2007, 03:10 PM
Looking for this also! :)
majorxp
05-31-2007, 03:40 PM
Did anyone put in a request for this on VB.org?
Lord Omega
06-29-2007, 07:48 AM
I could use this information as well. :O
pancan17
03-25-2008, 05:04 AM
Bump for an old-skool question I'm wondering about as well...
lostgirl815
03-25-2008, 06:50 AM
I assume it can't be done, because someone was complaining in vBulletin.com's 'talk about 3.7.0 beta 6' thread that they still haven't provided a way to order ranks.
DriverDan
03-27-2008, 09:58 AM
It CAN be done, it just requires modifying code.
Sanctorum
03-27-2008, 05:48 PM
Yeah, ordering ranks would be great, I'm surprised it isn't like that.
StregSpiller
04-04-2008, 12:09 PM
Bump....
Still no solution to this one???
Does anyone know how to do this?
marrr
08-13-2008, 03:07 PM
im looking for this also
Same here guys :D
Is there any way to make an official request?
DragonBlade
12-12-2008, 06:40 PM
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:
$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 'rankorder' => TYPE_UINT,
Then find this code in the same section
/*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
/*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:
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: print_input_row('Rank Order', 'rankorder', $ranks['rankorder']);
Next, in the doupdate block of the same page, again find this 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 'rankorder' => TYPE_UINT,Then find $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:
$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
// #################### 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
// #################### 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
orion808
01-11-2009, 02:20 PM
Next, in the doupdate block of the same page, again find this 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 'rankorder' => TYPE_UINT,Then find $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:
$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'] . ",
rankorder = " . $vbulletin->GPC['rankorder'] . "
WHERE rankid = " . $vbulletin->GPC['rankid'] . "
");
The 3rd from the last line you had "display" instead of the intended "rankorder". Otherwise, this worked perfectly.
DragonBlade
01-15-2009, 02:25 AM
The 3rd from the last line you had "display" instead of the intended "rankorder". Otherwise, this worked perfectly.
Kickasskewl, you've tried it? I still haven't got around to it. XD
Go me, yay, I did something useful! ^_^
orion808
01-20-2009, 01:28 AM
Yeah, works fine. Would be helpful if the "rank" was also visible (not editable) via the User Rank Manager so you would have an overview and know which ranks you needed to edit.
I have 20 ranks that go into 4 different slots. This works perfectly. So:
<<Orion>>
Forum Status (Rank 1)
Guild Status (Rank 2)
Platoon Status (Rank 3)
Squad Status (Rank 4)
In the /admincp/rank.php
Find:
print_form_header('ranks', 'insert', 0, 1, 'name', '');
print_table_header($vbphrase['images']);
construct_hidden_code('usergroupid', $vbulletin->GPC['usergroupid']);
construct_hidden_code('ranklevel', $vbulletin->GPC['ranklevel']);
construct_hidden_code('minposts', $vbulletin->GPC['minposts']);
construct_hidden_code('doinsert', $vbulletin->GPC['rankimg']);
Change it to:
print_form_header('ranks', 'insert', 0, 1, 'name', '');
print_table_header($vbphrase['images']);
construct_hidden_code('usergroupid', $vbulletin->GPC['usergroupid']);
construct_hidden_code('ranklevel', $vbulletin->GPC['ranklevel']);
construct_hidden_code('minposts', $vbulletin->GPC['minposts']);
construct_hidden_code('rankorder', $vbulletin->GPC['rankorder']);
construct_hidden_code('doinsert', $vbulletin->GPC['rankimg']);
This allows the variable for rankorder to be called.
Find:
print_table_header(iif($rank['usergroupid'] == 0, $vbphrase['all_usergroups'], $rank['title']), 5, 1);
print_cells_row(array($vbphrase['user_rank'], $vbphrase['minimum_posts'], $vbphrase['display_type'], $vbphrase['stack_rank'], $vbphrase['controls']), 1, '',
Change it to:
print_table_header(iif($rank['usergroupid'] == 0, $vbphrase['all_usergroups'], $rank['title']), 6, 1);
print_cells_row(array($vbphrase['user_rank'], $vbphrase['minimum_posts'], $vbphrase['display_type'], $vbphrase['stack_rank'], 'Rank Order', $vbphrase[
Going from 5 to 6 increases the number of headers. Adding 'Rank Order' gives the column a name.
Find:
$cell = array(
$rankhtml,
vb_number_format($rank['minposts']),
($rank['display'] ? $vbphrase['displaygroup'] : $vbphrase['always']),
($rank['stack'] ? $vbphrase['yes'] : $vbphrase['no']),
construct_link_code($vbphrase['edit'], "ranks.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&rankid=$rank[rankid]") . construct_link_code($vbphrase['delete'], "ranks.php?" . $vbulletin->session->vars['sessionurl'] . "do=remove&rankid=$rank[rankid]")
);
Change it to:
$cell = array(
$rankhtml,
vb_number_format($rank['minposts']),
($rank['display'] ? $vbphrase['displaygroup'] : $vbphrase['always']),
($rank['stack'] ? $vbphrase['yes'] : $vbphrase['no']),
vb_number_format($rank['rankorder']),
construct_link_code($vbphrase['edit'], "ranks.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&rankid=$rank[rankid]") . construct_link_code($vbphrase['delete'], "ranks.php?" . $vbulletin->session->vars['sessionurl'] . "do=remove&rankid=$rank[rankid]")
);
This adds the rankorder number to show up on the User Rank Manager page.
Find:
// ###################### Start modify #######################
if ($_REQUEST['do'] == 'modify')
{
$ranks = $db->query_write("
SELECT rankid, ranklevel, minposts, rankimg, ranks. usergroupid,title, type, display, stack
FROM " . TABLE_PREFIX . "ranks AS ranks
LEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup USING(usergroupid)
ORDER BY ranks.usergroupid, minposts
Change it to:
// ###################### Start modify #######################
if ($_REQUEST['do'] == 'modify')
{
$ranks = $db->query_write("
SELECT rankid, ranklevel, minposts, rankimg, ranks. usergroupid,title, type, display, stack, rankorder
FROM " . TABLE_PREFIX . "ranks AS ranks
LEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup USING(usergroupid)
ORDER BY rankorder, ranks.usergroupid, minposts
");
This changes the display order on the User Rank Manager page.
All these steps should display the rankorder on the User Rank Manager page.
orion808
02-05-2009, 11:12 PM
Nice, I'll install that tomorrow. Thank you.
orion808
02-15-2009, 11:20 PM
Well, almost forgot to do this. Thanks for the reminder PM, n8td. One small error, but got it working.
On your last section of code to replace:
SELECT rankid, ranklevel, minposts, rankimg, ranks. usergroupid,title, type, display, stack, rank
Should be:
SELECT rankid, ranklevel, minposts, rankimg, ranks. usergroupid,title, type, display, stack, rankorder
Notice that it's rankorder, not rank. Works like a charm though. Thank you for this. Cleans up my ranks for sure. Actually found one that had the wrong order on it that I forgot to edit after a recent change.
Okay thanks. I edited the original post.
SnaKe |WiH|
05-13-2009, 01:00 AM
Okay thanks. I edited the original post.
Just to clarify for me, which # post was modified plz? I'd like to try this out.
RLShare
05-13-2009, 01:07 AM
That person has only made a single post in this thread that has code in it, I can pretty much guarantee that is the post that is being referred to.
SnaKe |WiH|
05-13-2009, 08:17 PM
Ah, duh, thanks!
badheeu
05-14-2009, 01:41 PM
how about requesting this one for simple addon. that will be very easy.
its very much to edit
--------------- Added 1242313632 at 1242313632 ---------------
when I insert last part, it gets db error
SnaKe |WiH|
05-18-2009, 02:09 AM
I tried this but get a database error when I open User Rank Manager.
Am I suppose to create this new field in the db table manually or is making the code change all I need to do?
SnaKe |WiH|
05-20-2009, 03:35 PM
^Bump
Lynne
05-20-2009, 05:02 PM
I tried this but get a database error when I open User Rank Manager.
Am I suppose to create this new field in the db table manually or is making the code change all I need to do?
Reread his post, this is the second line:
In theory, all we need to do is add a field to the "rank" table called "rankorder".
So yes, you need to add a field to your database.
SnaKe |WiH|
05-20-2009, 07:19 PM
Reread his post, this is the second line:
So yes, you need to add a field to your database.Ah, sorry, missed that. Thanks!!!
rrudeboy
06-18-2009, 03:51 PM
error is gone (had to add rankorder to the database, not sure if i added it 100% correctly in choose the fields)
--------------- Added 1245346286 at 1245346286 ---------------
did all this, and deleted all ranks and started over again, made the founder first (it got automatically id:0) then i made admin which also automatically got id:0... rebuild the user titles and they are displayed in reversed order of creation (admin first, then founder)
could use some assistance.
--------------- Added 1245346556 at 1245346556 ---------------
after running another rebuild, founder is id:5 and admin is id:6, so they are still shown reversed :(
orion808
06-19-2009, 11:36 AM
Not sure I understand the above post...but:
You should be able to just edit the rank order after this is installed. It doesn't matter what order you created the ranks in, just the order of the rankid. Something that is 5 appears before 6. Something that is 3 appears on the same line or immediately after another 3 depending on if both are ranks of the player.
I have my admin/moderator/supermoderator/banned as rankid=1 and have my "guild" status (I play World of Warcraft) as rankid=2. So there are 4 ranks that have rankid=1....etc.
http://www.azurebloodfire.com/members/orion/forum_att/rank_id.jpg
rrudeboy
06-19-2009, 11:48 AM
thanks orion808.... i clearly have something wrong, this is how my ranks look:
http://bb.roeiboot.com/ss/Rank_Capture.JPG
question is what did i screw up :(
plus i can NOT edit the rank order..
Lynne
06-19-2009, 02:58 PM
question is what did i screw up :(
plus i can NOT edit the rank order..
Reread and go over the instructions in post 20, the correction in post 21, and also post 24.
rrudeboy
06-19-2009, 07:29 PM
Reread and go over the instructions in post 20, the correction in post 21, and also post 24.
thanks Lynne.... after the day i had, maybe tomorrow i will be brave enough to triple check the code (which i all copy 'n pasted so not sure what went wrong)
Lynne
06-19-2009, 07:31 PM
thanks Lynne.... after the day i had, maybe tomorrow i will be brave enough to triple check the code (which i all copy 'n pasted so not sure what went wrong)
My guess it that you didn't read post 21 in which someone corrects the code posted in post 20. And, you may have missed a few steps since your table doesn't look correct.
rrudeboy
06-20-2009, 01:57 AM
My guess it that you didn't read post 21 in which someone corrects the code posted in post 20. And, you may have missed a few steps since your table doesn't look correct.
yea, i did get that correct.... since it's all in the ranks.php maybe somebody can share a working copy ? :)
orion808
06-20-2009, 12:37 PM
Just do like he said...
Post 20 is the code
Post 21 is a slight fix of the code (had somehting named wrong)
Post 24 is responsible for making the above screenshot have the rankid visible for an overview
Obviously you didn't do 24 right...but if you did 20/21, then you should be able to hit the edit button to the right of the rank and see a rank order section. See screenshot below.
http://www.azurebloodfire.com/members/orion/forum_att/rank_id2.jpg
rrudeboy
06-20-2009, 03:07 PM
Just do like he said...
Post 20 is the code
Post 21 is a slight fix of the code (had somehting named wrong)
Post 24 is responsible for making the above screenshot have the rankid visible for an overview
Obviously you didn't do 24 right...but if you did 20/21, then you should be able to hit the edit button to the right of the rank and see a rank order section. See screenshot below.
*SNIP*
thanks orion808, i did post 20, and i think i did what post 21 advised.. after doing post 21 nothing changed, so i also need to do post 24 ? did you see my screen shot of how it looks in my ACP ? how am i sure i did the add entry to my database correctly ?
there's no way you can share your working ranks.php ? with possible edits to protect sensitive information ?
again thanks...
orion808
06-21-2009, 02:23 PM
ranks.php for vBulletin 3.8.0 Release Candidate 2
(I still need to update to the latest vBulletin)
<?php
/*================================================= =====================*\
|| ################################################## ################## ||
|| # vBulletin 3.8.0 Release Candidate 2
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2000-2009 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| ################################################## ################## ||
\*================================================ ======================*/
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('CVS_REVISION', '$RCSfile$ - $Revision: 12761 $');
// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('user', 'cpuser', 'cprank');
$specialtemplates = array();
// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/functions_ranks.php');
// ######################## CHECK ADMIN PERMISSIONS #######################
if (!can_administer('canadminusers'))
{
print_cp_no_permission();
}
$vbulletin->input->clean_array_gpc('r', array('rankid' => TYPE_UINT));
// ############################# LOG ACTION ###############################
log_admin_action(!empty($vbulletin->GPC['rankid']) ? "rank id = " . $vbulletin->GPC['rankid'] : '');
// ################################################## ######################
// ######################### START MAIN SCRIPT ############################
// ################################################## ######################
print_cp_header($vbphrase['user_rank_manager']);
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'modify';
}
// ###################### Start insert #######################
if ($_POST['do'] == 'insert')
{
$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,
'rankorder' => TYPE_UNIT,
));
if (!$vbulletin->GPC['ranklevel'] OR (!$vbulletin->GPC['rankimg'] AND !$vbulletin->GPC['rankhtml']))
{
if ($vbulletin->GPC['doinsert'])
{
echo '<p><b>' . $vbphrase['invalid_file_path_specified'] . '</b></p>';
$vbulletin->GPC['rankimg'] = $vbulletin->GPC['doinsert'];
}
else
{
print_stop_message('please_complete_required_field s');
}
}
if ($vbulletin->GPC['usergroupid'] == -1)
{
$vbulletin->GPC['usergroupid'] = 0;
}
if (!$vbulletin->GPC['rankhtml'])
{
$vbulletin->GPC['rankimg'] = preg_replace('/\/$/s', '', $vbulletin->GPC['rankimg']);
if($dirhandle = @opendir(DIR . '/' . $vbulletin->GPC['rankimg']))
{ // Valid directory!
readdir($dirhandle);
readdir($dirhandle);
while ($filename = readdir($dirhandle))
{
if (is_file(DIR . "/{$vbulletin->GPC['rankimg']}/" . $filename) AND (($filelen = strlen($filename)) >= 5))
{
$fileext = strtolower(substr($filename, $filelen - 4, $filelen - 1));
if ($fileext == '.gif' OR $fileext == '.bmp' OR $fileext == '.jpg' OR $fileext == 'jpeg' OR $fileext == 'png')
{
$FileArray[] = htmlspecialchars_uni($filename);
}
}
}
if (!is_array($FileArray))
{
print_stop_message('no_matches_found');
}
print_form_header('ranks', 'insert', 0, 1, 'name', '');
print_table_header($vbphrase['images']);
construct_hidden_code('usergroupid', $vbulletin->GPC['usergroupid']);
construct_hidden_code('ranklevel', $vbulletin->GPC['ranklevel']);
construct_hidden_code('minposts', $vbulletin->GPC['minposts']);
construct_hidden_code('rankorder', $vbulletin->GPC['rankorder']);
construct_hidden_code('doinsert', $vbulletin->GPC['rankimg']);
foreach ($FileArray AS $key => $val)
{
print_yes_row("<img src='../" . $vbulletin->GPC['rankimg'] . "/$val' border='0' alt='' align='center' />", 'rankimg', '', '', $vbulletin->GPC['rankimg'] . "/$val");
}
print_submit_row($vbphrase['save']);
closedir($dirhandle);
exit;
}
else
{ // Not a valid dir so assume it is a filename
if (!(@is_file(DIR . '/' . $vbulletin->GPC['rankimg'])))
{
print_stop_message('invalid_file_path_specified');
}
}
$type = 0;
}
else
{
$vbulletin->GPC['rankimg'] = $vbulletin->GPC['rankhtml'];
$type = 1;
}
build_ranks();
/*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'] . "
)
");
build_ranks();
define('CP_REDIRECT', 'ranks.php?do=modify');
print_stop_message('saved_user_rank_successfully') ;
}
// ###################### Start edit #######################
if ($_REQUEST['do'] == 'edit' OR $_REQUEST['do'] == 'add')
{
if ($_REQUEST['do'] == 'edit')
{
$ranks = $db->query_first("
SELECT *
FROM " . TABLE_PREFIX . "ranks
WHERE rankid = " . $vbulletin->GPC['rankid'] . "
");
print_form_header('ranks', 'doupdate');
}
else
{
$ranks = array(
'ranklevel' => 1,
'usergroupid' => -1,
'minposts' => 10,
'rankimg' => 'images/',
);
print_form_header('ranks', 'insert');
}
if ($ranks['type'])
{
$ranktext = $ranks['rankimg'];
}
else
{
$rankimg = $ranks['rankimg'];
}
$displaytype = array(
$vbphrase['always'],
$vbphrase['if_displaygroup_equals_this_group'],
);
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_input_row('Rank Order', 'rankorder', $ranks['rankorder']);
print_submit_row();
}
// ###################### Start do update #######################
if ($_POST['do'] == 'doupdate')
{
$vbulletin->input->clean_array_gpc('p', array(
'ranklevel' => TYPE_UINT,
'minposts' => TYPE_UINT,
'rankimg' => TYPE_STR,
'usergroupid' => TYPE_INT,
'rankhtml' => TYPE_NOTRIM,
'stack' => TYPE_UINT,
'display' => TYPE_UINT,
'rankorder' => TYPE_UNIT,
));
if (!$vbulletin->GPC['ranklevel'] OR (!$vbulletin->GPC['rankimg'] AND !$vbulletin->GPC['rankhtml']))
{
print_stop_message('please_complete_required_field s');
}
if ($vbulletin->GPC['rankhtml'])
{
$type = 1;
$vbulletin->GPC['rankimg'] = $vbulletin->GPC['rankhtml'];
}
else
{
$type = 0;
if (!(@is_file(DIR . '/' . $vbulletin->GPC['rankimg'])))
{
print_stop_message('invalid_file_path_specified');
}
}
$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'] . ",
rankorder = " . $vbulletin->GPC['rankorder'] . "
WHERE rankid = " . $vbulletin->GPC['rankid'] . "
");
build_ranks();
define('CP_REDIRECT', 'ranks.php?do=modify');
print_stop_message('saved_user_rank_successfully') ;
}
// ###################### Start Remove #######################
if ($_REQUEST['do'] == 'remove')
{
print_form_header('ranks', 'kill');
construct_hidden_code('rankid', $vbulletin->GPC['rankid']);
print_table_header($vbphrase['confirm_deletion']);
print_description_row($vbphrase['are_you_sure_you_want_to_delete_this_user_rank']);
print_submit_row($vbphrase['yes'], '', 2, $vbphrase['no']);
}
// ###################### Start Kill #######################
if ($_POST['do'] == 'kill')
{
$db->query_write("DELETE FROM " . TABLE_PREFIX . "ranks WHERE rankid = " . $vbulletin->GPC['rankid']);
build_ranks();
define('CP_REDIRECT', 'ranks.php?do=modify');
print_stop_message('deleted_user_rank_successfully ');
}
// ###################### Start modify #######################
if ($_REQUEST['do'] == 'modify')
{
$ranks = $db->query_write("
SELECT rankid, ranklevel, minposts, rankimg, ranks. usergroupid,title, type, display, stack, rankorder
FROM " . TABLE_PREFIX . "ranks AS ranks
LEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup USING(usergroupid)
ORDER BY rankorder, ranks.usergroupid, minposts
");
print_form_header('', '');
print_table_header($vbphrase['user_rank_manager']);
print_description_row($vbphrase['user_ranks_desc'] . '<br /><br />' .
construct_phrase($vbphrase['it_is_recommended_that_you_update_user_titles'], $vbulletin->session->vars['sessionurl'])
,'',0);
print_table_footer();
if ($db->num_rows($ranks) == 0)
{
print_stop_message('no_user_ranks_defined');
}
print_form_header('', '');
while ($rank = $db->fetch_array($ranks))
{
if ($tempgroup != $rank['usergroupid'])
{
if (isset($tempgroup))
{
print_table_break();
}
$tempgroup = $rank['usergroupid'];
print_table_header(iif($rank['usergroupid'] == 0, $vbphrase['all_usergroups'], $rank['title']), 6, 1);
print_cells_row(array($vbphrase['user_rank'], $vbphrase['minimum_posts'], $vbphrase['display_type'], $vbphrase['stack_rank'], 'Rank Order', $vbphrase['controls']), 1, '', -1);
}
$count = 0;
$rankhtml = '';
while ($count++ < $rank['ranklevel'])
{
if (!$rank['type'])
{
$rankhtml .= "<img src=\"../$rank[rankimg]\" border=\"0\" alt=\"\" />";
}
else
{
$rankhtml .= $rank['rankimg'];
}
}
$cell = array(
$rankhtml,
vb_number_format($rank['minposts']),
($rank['display'] ? $vbphrase['displaygroup'] : $vbphrase['always']),
($rank['stack'] ? $vbphrase['yes'] : $vbphrase['no']),
vb_number_format($rank['rankorder']),
construct_link_code($vbphrase['edit'], "ranks.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&rankid=$rank[rankid]") . construct_link_code($vbphrase['delete'], "ranks.php?" . $vbulletin->session->vars['sessionurl'] . "do=remove&rankid=$rank[rankid]")
);
print_cells_row($cell, 0, '', -1);
}
print_table_footer();
}
print_cp_footer();
/*================================================= =====================*\
|| ################################################## ##################
|| # Downloaded: 09:08, Thu Jan 1st 2009
|| # CVS: $RCSfile$ - $Revision: 12761 $
|| ################################################## ##################
\*================================================ ======================*/
?>
Hope this helps.
Also noticed something. My version is a working version. I haven't had any issues with it. However, there appears to be a typo. Any know if it is truly one or if it's intended?
This occurs in a couple places:
'display' => TYPE_UINT,
'rankorder' => TYPE_UNIT,
Note that it's "TYPE_UINT" vs "TYPE_UNIT". Thoughts?
--------------- Added 1245598267 at 1245598267 ---------------
thanks orion808, i did post 20, and i think i did what post 21 advised.. after doing post 21 nothing changed, so i also need to do post 24 ? did you see my screen shot of how it looks in my ACP ? how am i sure i did the add entry to my database correctly ?
there's no way you can share your working ranks.php ? with possible edits to protect sensitive information ?
again thanks...
Post 24 is responsible for showing the rankorder in your screenshot above. If it's not listed there like mine, 24 is definitely not completed.
As for the database, this is how mine looks on the ranks table. I just added another field with these values:
http://www.azurebloodfire.com/members/orion/forum_att/rank_id3.jpg
Hope that helps.
rrudeboy
06-22-2009, 11:28 AM
sweet.... THANKS, it works now.
SnaKe |WiH|
07-16-2009, 02:53 AM
I've been working on this for several hours now trying to figure out why I get the following error. I've looked up the error code 1064 and there was some reference to 'order' as a reserved word in some versions of MySQL but I dont think 'rankorder' would cause that problem. Plus more ppl would be having the problem.
I've gone over my php code changes several times in ranks and functions_ranks to make sure it's right.
Can anyone see what the problem might be? I saw some reference to the CHARSET setting but I tried different settings with no help. It's not real intuitive considering my db tables appear to default to MyISAM DEFAULT latin1_swedish_ci. Not sure why it would be swedish. I'm in the US. I digress, I'm not trying to get a MySQL lesson, just sayin.
Thanks for any help.
The rankorder column shows up just fine in admincp. I get this error when I try to change the rankorder on a badge.
Here's the error:
Database error in vBulletin 3.7.6:
Invalid SQL:
UPDATE ranks
SET ranklevel = 1,
minposts = 10,
rankimg = 'images/ranks/moderator.png',
usergroupid = 7,
type = 0,
stack = 1,
display = 0
rankorder = 1
WHERE rankid = 7;
MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rankorder = 1
WHERE rankid = 7' at line 9
Error Number : 1064
Request Date : Wednesday, July 15th 2009 @ 08:26:54 PM
Error Date : Wednesday, July 15th 2009 @ 08:26:54 PM
Script : http://www.warishellgaming.com/forums/admincp/ranks.php?do=doupdate
Referrer : http://www.warishellgaming.com/forums/admincp/ranks.php?do=edit&rankid=7
IP Address : 76.X.X.X
Username : SnaKe
Classname : vB_Database
MySQL Version : 5.1.30
Lynne
07-16-2009, 04:23 PM
If you take a look at the error query, you'll see you are missing commas between a couple of the values. So, go back to the instructions and copy the query exactly - with the commas - and it should work.
orion808
07-16-2009, 09:54 PM
I've learned that whenever I get a syntax error for line X (9 in your example), the error is usually at the end of the previous line...8.
Line 8: display = 0
compare that to line 7 since it's basically the same, and you can see it's missing a comma. I don't think you need a comma after "rankorder = 1" though. Commas are separating all the values...not the WHERE statement.
SnaKe |WiH|
07-16-2009, 11:23 PM
You guys rock! That fixed it.
I def did post 21 but obviously messed it up. Thanks again!
Badhabitz
03-15-2011, 10:04 PM
I am using 4.1.2
I have completed all the steps and everything is working fine in the AdminCP the field shows up and even orders them by rank in the AdminCP and the values are going into the sql database from the new fields.
However in the Forums the ranks are not ordering correctly based upon these values. I'm guessing this is the code build_ranks() function in includes/functions_ranks.php which I have re-modified several times. Yes I am rebuilding the ranks each time ,but it still seems to be ordering them the default way. After trying to solve this for awhile now I decided to post. Could something have changed in the 4.x code? Any help on this would be greatly appreciated.
BirdOPrey5
03-16-2011, 12:58 PM
It would be best to ask in the 4.x forum. This forum is strictly for VB 3.x discussion and mixing in 4.x code will only confuse people looking for help in the future.
Lynne
03-16-2011, 04:41 PM
Yeah, I would start a new thread in the vB4, post exactly what you did (you can reference this thread with a link) and then ask for help.
Badhabitz
03-16-2011, 06:11 PM
Thank you, I wasn't sure if I should make a new thread in the 4.x section. For reference it was working just takes 2hrs for each change to register it's working on the forums.
midnz
11-04-2011, 06:12 AM
Excellent tutorial :). Thanks for helping to solve the user-ranks sorting headache.
whitewolf68
08-25-2012, 05:21 AM
I have this mod completed and working on my localhost installation but every time I upload to the online server I get "The service is unavailable."
Please help, I have been looking for this mod for a really long time now.
demolicionchica
09-23-2012, 11:14 PM
Sorry, I know this thread is old but thank you so much for the code! I'm not technical AT ALL but your instructions were super easy to follow and everything works just as it should.
Sangheili
11-06-2012, 05:02 PM
I seriously can't believe this is still not part of the default vBulletin installation, it's been over 4 years!
SnaKe |WiH|
12-12-2013, 04:02 PM
So does this work with v4 of vB? I've searched the v4 forums for anything to do with ranks and did not find anything.
BirdOPrey5
12-12-2013, 04:19 PM
I suspect it would work in VB4. Main thing to check is if the "Find" code is the same in VB4, it probably is.
Don't forget to add the rankorder field to the database.
reviziongaming
12-15-2013, 09:01 PM
assume that this would all need to be redone in the case of an upgrade?? say you do all this extra code and then upgrade from 4.1 to 4.2 ... all this will be replaced and have to be reworked??
BirdOPrey5
12-15-2013, 09:12 PM
Yes you will need to redo it in case of an upgrade. Although it is unlikely the ranks.php file changes much, if at all, between versions - so you can check first but likely get away with using the same file in various 4.x versions.
reviziongaming
12-15-2013, 10:09 PM
Thanks...
Any chance of someone offering us "less than newbies" instructions on exactly how to create the new field in the ranks table manually?
--------------- Added 1387153203 at 1387153203 ---------------
Scratch that... I just dove in on it and it seems to be working just fine. I love this community.
Amazing Thread. Thanks for the information
dany_danay
08-05-2014, 12:00 PM
This should work in 4.2.2 but no changes make.. still the prorder order.. someone has any ideas?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.