View Single Post
  #20  
Old 12-12-2008, 06:40 PM
DragonBlade's Avatar
DragonBlade DragonBlade is offline
 
Join Date: May 2006
Posts: 189
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01944 seconds
  • Memory Usage 1,898KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (12)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete