Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
  #1  
Old 07-13-2011, 12:17 PM
userform3 userform3 is offline
 
Join Date: Jul 2010
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How I get realusername i hybrid mode

Helo ,

In the thread shall be show real username in hybrid mode.
How can I this make?

My first try was make a plugin

Plugins & Products --> Plugin Manager

Product: vBulletin
Hook Location: showthread_start
Titel: Realname
Execution Order: 5

Plugin PHP Code:
PHP Code:
$hook_query_fields .= ' , userfield.* ';
$hook_query_joins "LEFT JOIN " TABLE_PREFIX "userfield AS userfield ON(userfield.userid = thread.postuserid)";
$hook_query_where ' post.threadid '
It's not work.

In the file showthread.php in line 1176 following i found variables:
PHP Code:
$hook_query_fields $hook_query_joins $hook_query_where ''
And after this query and in line 1448 the same.
It seems as if the hook was not passed to the file showthread.php

What is the error?

Vbulletin 4.1.4 forum.

Greeting
userform3
Reply With Quote
  #2  
Old 07-13-2011, 12:32 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you try using hook location showthread_query_postids_threaded? It's after line 1176, and if you want to set $hook_query_fields and $hook_query_joins it must be after that line.

Also, I believe that

PHP Code:
$hook_query_where ' post.threadid '

will cause an error. I don't think you need to set $hook_query_where at all.
Reply With Quote
  #3  
Old 07-13-2011, 12:51 PM
userform3 userform3 is offline
 
Join Date: Jul 2010
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How I get username form userid


Hi,

Yes, I don't need $hook_query_where.


I try something else, hook location: showthread_query and I get immediately this error:
PHP Code:
Database error in vBulletin 4.1.4:

Invalid SQL:

        
SELECT
            post
.*, post.username AS postusernamepost.ipaddress AS ip, IF(post.visible 210) AS isdeleted,
            
user.*, userfield.*, usertextfield.*,
            
            
            
spamlog.postid AS spamlog_postid,
            
deletionlog.userid AS del_useriddeletionlog.username AS del_usernamedeletionlog.reason AS del_reason,
            
editlog.userid AS edit_userideditlog.username AS edit_usernameeditlog.dateline AS edit_dateline,
            
editlog.reason AS edit_reasoneditlog.hashistory,
            
postparsed.pagetext_htmlpostparsed.hasimages,
            
sigparsed.signatureparsedsigparsed.hasimages AS sighasimages,
            
sigpic.userid AS sigpicsigpic.dateline AS sigpicdatelinesigpic.width AS sigpicwidthsigpic.height AS sigpicheight,
            IF(
displaygroupid=0user.usergroupiddisplaygroupid) AS displaygroupidinfractiongroupid
            
             
userfield.* 
        
FROM post AS post
        LEFT JOIN user 
AS user ON(user.userid post.userid)
        
LEFT JOIN userfield AS userfield ON(userfield.userid user.userid)
        
LEFT JOIN usertextfield AS usertextfield ON(usertextfield.userid user.userid)
        
        
        
LEFT JOIN spamlog AS spamlog ON(spamlog.postid post.postid)
            
LEFT JOIN deletionlog AS deletionlog ON(post.postid deletionlog.primaryid AND deletionlog.type 'post')
        
LEFT JOIN editlog AS editlog ON(editlog.postid post.postid)
        
LEFT JOIN postparsed AS postparsed ON(postparsed.postid post.postid AND postparsed.styleid AND postparsed.languageid 1)
        
LEFT JOIN sigparsed AS sigparsed ON(sigparsed.userid user.userid AND sigparsed.styleid AND sigparsed.languageid 1)
        
LEFT JOIN sigpic AS sigpic ON(sigpic.userid post.userid)
            
LEFT JOIN userfield AS userfield ON(userfield.userid thread.postuserid)
        
WHERE post.postid IN (205497,205518,205576)  post.threadid;

MySQL-Error  Not unique table/alias'userfield'
Error-Nr.    : 1066
Error
-time   Wednesday13.07.2011 15:31:21
Date         
Wednesday13.07.2011 15:31:21
... 
The reason is
Not unique table/alias: 'userfield'
Hm, the table 'userfield' is exists in the databas?
I think the query is not ok, what do you think?
Reply With Quote
  #4  
Old 07-13-2011, 01:02 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It looks like the userfield table and fields are already being included, so maybe you don't need to do it at all.

Code:
Database error in vBulletin 4.1.4: 

Invalid SQL: 

        SELECT 
            post.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted, 
            user.*, userfield.*, usertextfield.*, 
             
             
            spamlog.postid AS spamlog_postid, 
            deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason, 
            editlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline, 
            editlog.reason AS edit_reason, editlog.hashistory, 
            postparsed.pagetext_html, postparsed.hasimages, 
            sigparsed.signatureparsed, sigparsed.hasimages AS sighasimages, 
            sigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight, 
            IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid 
             
             , userfield.*  
        FROM post AS post 
        LEFT JOIN user AS user ON(user.userid = post.userid) 
        LEFT JOIN userfield AS userfield ON(userfield.userid = user.userid) 
        LEFT JOIN usertextfield AS usertextfield ON(usertextfield.userid = user.userid) 
         
         
        LEFT JOIN spamlog AS spamlog ON(spamlog.postid = post.postid) 
            LEFT JOIN deletionlog AS deletionlog ON(post.postid = deletionlog.primaryid AND deletionlog.type = 'post') 
        LEFT JOIN editlog AS editlog ON(editlog.postid = post.postid) 
        LEFT JOIN postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = 1 AND postparsed.languageid = 1) 
        LEFT JOIN sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = 1 AND sigparsed.languageid = 1) 
        LEFT JOIN sigpic AS sigpic ON(sigpic.userid = post.userid) 
            LEFT JOIN userfield AS userfield ON(userfield.userid = thread.postuserid) 
        WHERE post.postid IN (205497,205518,205576)  post.threadid; 

MySQL-Error  : Not unique table/alias: 'userfield' 
Error-Nr.    : 1066 
Error-time   : Wednesday, 13.07.2011 @ 15:31:21 
Date         : Wednesday, 13.07.2011 @ 15:31:21
Reply With Quote
  #5  
Old 07-13-2011, 01:28 PM
userform3 userform3 is offline
 
Join Date: Jul 2010
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes, it's unnecessary
In the table userfield are only two fields what I need:
PHP Code:
userfield.field5userfield.field6 
Have you a idea how I can gat this value form the table userfield?
Reply With Quote
  #6  
Old 07-13-2011, 01:44 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's a good question and I don't know the answer. I think it should be {vb:raw post.userfield.field5} but that probably doesn't work because the template curly tags use '.' for array access.

Edit: no, I'm wrong - I see from your post below that you figured out it's just 'field5' and 'field6'.
Reply With Quote
  #7  
Old 07-14-2011, 06:17 AM
userform3 userform3 is offline
 
Join Date: Jul 2010
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

Your idea was deciding, thanks, I change the Hook Location to showthread_postbit_create
I found in tempalte showthread_list the location where are "bulid" the usernick name, this nickname I want to change to
realname, I try this with following code in this hook:
PHP Code:
$realname ='';
if (
$post['field6'] && $post['field5']) {
     
$realname =  $post['field6'] . ' ' .  $post['field5'];
}
vB_Template::preRegister('showthread_list',array('userjs' => $realname)); 
It dosen't work.
If I change this code to
PHP Code:
vB_Template::preRegister('showthread_list',array('realname' => $realname)); 
And change the part of template showthread_list to
PHP Code:
...
// cached usernames
pu[0] = guestphrase;
//{vb:raw userjs} // org
{vb:raw realname// new
// -->
... 
It dosen't wort to.

What make I wrong?
Reply With Quote
  #8  
Old 07-14-2011, 08:25 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I see now - I was wrong and the field names were just 'field5' and 'field6' - that makes it easier .

I think you would want to use template postbit, or (postbit_legacy is you are using that one instead).
Reply With Quote
  #9  
Old 07-14-2011, 10:07 AM
userform3 userform3 is offline
 
Join Date: Jul 2010
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have implemented your suggestion and expand the php code:
PHP Code:
$realname ='';
if (
$post['field6'] && $post['field5']) {
     
$realname =  $post['field6'] . ' ' .  $post['field5'];
}
vB_Template::preRegister('showthread_list',array('userjs' => $realname));
#vB_Template::preRegister('showthread_list',array('realname' => $realname)); # not work
#vB_Template::preRegister('postbit',array('realname' => $realname));        # tempalte postbit    // not work
#vB_Template::preRegister('postbit_legacy',array('realname' => $realname));    # tempalte postbit_legacy // not work 
I try two templates, it dosen't work or I make samthing wrong?
The Hook Location is the same.
Reply With Quote
Reply

Thread Tools
Display Modes

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 12:06 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.04787 seconds
  • Memory Usage 2,289KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (9)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (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_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • 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
  • 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
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete