Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-29-2014, 05:49 AM
webjocky webjocky is offline
 
Join Date: Jun 2013
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using {vb:raw conversation.groupid}

As a vBulletin n00b, I've scoured these (and the vb.com's) forums for the past couple of weeks looking for a solution to this. Since I couldn't find one, I'm having to hack the core files - which I'd rather not do.

I'm hoping someone can tell me a more graceful way to handle this php file modification so that I don't have to hack the core files every time I update to a new release.

Here's what I needed and how I did it:
For those that don't already know, $conversation['groupid'] is not made available for template modifications in the codebase as of 5.1.2 Patch Level 2. The database's node table has a field for this information, but if you take a look - that field only contains NULL values by default. (vb_node -> groupid).

I need to assign avatars to my forum users based on the primary group id. This was easier to do in vB4, but the feature was used very little and so, as the devs have explained, the feature was not included in vB5. With that, I set out to create a group avatar manager myself.

By modifying /core/vb/library/content/text.php, you are now able to pull this information (although another hack is required to fill the database with the groupid of the post author - which I'll update here as soon as I figure that out).

Original @ Line 519
PHP Code:
if (empty($data['userid']))
        {
            
$user vB::getCurrentSession()->fetch_userinfo();
            
$data['authorname'] = $user['username'];
            
$userid $data['userid'] = $user['userid'];
        }
        else
        {
            
$userid $data['userid'];
            if (empty(
$data['authorname']))
            {
                
$data['authorname'] = vB_Api::instanceInternal('user')->fetchUserName($userid);
            }
            
$user vB_Api::instance('user')->fetchUserinfo($userid);
        } 
Modified:
PHP Code:
if (empty($data['userid']))
        {
            
$user vB::getCurrentSession()->fetch_userinfo();
            
$data['authorname'] = $user['username'];
            
$userid $data['userid'] = $user['userid'];
            
$groupid $data['groupid'] = $user['usergroupid'];  //Added groupid
        
}
        else
        {
            
$userid $data['userid'];
            
$groupid $data['groupid']; //Added groupid
            
if (empty($data['authorname']))
            {
                
$data['authorname'] = vB_Api::instanceInternal('user')->fetchUserName($userid);
            }
            
$user vB_Api::instance('user')->fetchUserinfo($userid);
        } 
With that in place, you can now call {vb:raw conversation.groupid}

Edit:
Here's the hack that enables the groupid to be set when someone creates a new forum node (channel/topic/post):
Original File: /core/vb/library/content.php @ Line 199
PHP Code:
    if (empty($data['userid']))
        {
            
$user vB::getCurrentSession()->fetch_userinfo();
            
$data['authorname'] = $user['username'];
            
$userid $data['userid'] = $user['userid'];
        }
        else
        {
            
$userid $data['userid'];
            if (empty(
$data['authorname']))
            {
                
$data['authorname'] = vB_Api::instanceInternal('user')->fetchUserName($userid);
            }
        } 
Change to:
PHP Code:
    if (empty($data['userid']))
        {
            
$user vB::getCurrentSession()->fetch_userinfo();
            
$data['authorname'] = $user['username'];
            
$userid $data['userid'] = $user['userid'];
            
$groupid $data['groupid'] = $user['usergroupid']; //Added groupid
        
}
        else
        {
            
$userid $data['userid'];
            
$groupid $data['groupid']; //Added groupid
            
if (empty($data['authorname']))
            {
                
$data['authorname'] = vB_Api::instanceInternal('user')->fetchUserName($userid);
            }
        } 
As I wait for a response to my question, I hope this helps someone. (just realized: this post contains a lot of hope )

Edit: There is still one more file to edit that controls Private Message node creation. Will update this post when I find it.
Reply With Quote
 


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 03:40 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.04356 seconds
  • Memory Usage 2,572KB
  • Queries Executed 12 (?)
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
  • (4)bbcode_php
  • (21)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (1)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
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete