PDA

View Full Version : How I get realusername i hybrid mode


userform3
07-13-2011, 12:17 PM
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:

$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:

$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

$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:

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


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.

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:

, userfield.field5, userfield.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:

$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

vB_Template::preRegister('showthread_list',array(' realname' => $realname));

And change the part of template showthread_list to

...
// 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:

$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('realnam e' => $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.