vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   How I get realusername i hybrid mode (https://vborg.vbsupport.ru/showthread.php?t=266734)

userform3 07-13-2011 12:17 PM

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

kh99 07-13-2011 12:32 PM

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.

userform3 07-13-2011 12:51 PM

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?

kh99 07-13-2011 01:02 PM

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


userform3 07-13-2011 01:28 PM

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?

kh99 07-13-2011 01:44 PM

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'.

userform3 07-14-2011 06:17 AM

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?

kh99 07-14-2011 08:25 AM

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).

userform3 07-14-2011 10:07 AM

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.


All times are GMT. The time now is 06:57 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01199 seconds
  • Memory Usage 1,791KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (9)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete