Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-13-2007, 05:11 PM
sifo sifo is offline
 
Join Date: Mar 2007
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default EQDKP in the postbit

I am trying to add a field in the postbit to display the users current DKP. I am somewhat of a novice but I have been learning rather quickly. The way my site is set up is that the EQDKP site and the vBulletin forums are separate MYSQL databases.

The way I envision this working is that I create a new User Profile Field through the Admin CP. It is just a string. My users enter their userid from our DKP site into that field. With this string entered into the 'fieldXX' (field6 for my board), I can use that string to index my array and extract the pertinent data to calculate the current DKP.

The code below works properly by itself but I don't have enough knowledge to incorporate it into vBulletin. I'm not sure if this is too much of a bother to even worry about or if it would take just a few lines in the right place - any help would be greatly appreciated.

Code:
<?php

mysql_connect("myserver.net","myusername","mypassword") or die(mysql_error());

mysql_select_db("mydatabase") or die(mysql_error());

// $dkpname is the string that will come from 'fieldXX' which is a user defined profile field to display in the postbit

$yourdkpname = mysql_query("SELECT * FROM eqdkp_members
 WHERE member_name= '$dkpname'") or die(mysql_error());

$data = mysql_fetch_array($yourdkpname);

$yourdkp = $data['member_earned'] - $data['member_spent'] + $data['member_adjustment'];

// $yourdkp is the current dkp that I want to be displayed in the postbit

?>
Reply With Quote
  #2  
Old 10-13-2007, 07:49 PM
Analogpoint's Avatar
Analogpoint Analogpoint is offline
 
Join Date: Feb 2007
Posts: 656
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To test this, just put the code you posted in a plugin that is fired on the global_start hook, then put $yourdkp in your postbit template (or postbit_legacy if that's the one you're using).

But please sanitize your database inputs. Do you know what would happen if someone entered this as their DKP userid?

[sql]joeblow'; drop table eqdkp_members; --[/sql]

At least do this before your query.

PHP Code:
$dkpname mysql_real_escape_string($dkpname); 
Reply With Quote
  #3  
Old 10-15-2007, 12:48 AM
sifo sifo is offline
 
Join Date: Mar 2007
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I believe I have done everything you suggested. However, $yourdkp doesn't seem to be displaying. I have tried entering a manual value for $yourdkp and bypassed the database query in the plugin and I still don't get a value displayed.

This is what I entered in the postbit:
Code:
<if condition="$post['field6']">Current DKP: $yourdkp<else />Current DKP: N/A</if>
Thanks for your help!
Reply With Quote
  #4  
Old 10-15-2007, 02:02 PM
Kiint Kiint is offline
 
Join Date: Nov 2006
Posts: 191
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I haven't really looked at your code, but this is what I use on my site in the profile of each person, I have a page that has this code:

PHP Code:
$result $db->query("SELECT * FROM " TABLE_PREFIX "`eqdkp_items`
                               LEFT JOIN eqdkp_raids ON eqdkp_items.raid_id=eqdkp_raids.raid_id
                               WHERE `item_buyer` = \""
.$chardata[fname]."\"
                               ORDER BY `item_date` DESC"
);
    
$ii $db->num_rows($result);
    while(
$loot $db->fetch_array($result)) {
        
$lootdate date("D, F j, Y, g:i a"$loot[item_date]);
  eval(
'$loothistory .= "' fetch_template('roster_profile_loot') . '";');
 }
    
$db->free_result($result); 
Then a template called 'roster_profile_loot' with the following in it:

HTML Code:
<tr>
 <td class="alt1" align="left">
 <a href="http://www.yoursite.com/eqdkp/viewitem.php?s=&i=$loot[item_id]" target="_blank">$loot[item_name]</a></td>
 <td class="alt2" align="left">
 <a href="http://www.yoursite.com/eqdkp/viewraid.php?s=&r=$loot[raid_id]"  target="_blank">$loot[raid_name]</a></td>
 <td class="alt1" align="left">
 $lootdate
 </td>
</tr>
Hope this helps a little
Reply With Quote
  #5  
Old 10-15-2007, 03:05 PM
sifo sifo is offline
 
Join Date: Mar 2007
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That is definitely something I'd like to try and add in the future. I guess my real sticking point right now is how do I make a variable from a plugin to be passed/available for use in the postbit template?

Thanks again.
Reply With Quote
  #6  
Old 10-15-2007, 06:48 PM
Analogpoint's Avatar
Analogpoint Analogpoint is offline
 
Join Date: Feb 2007
Posts: 656
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by sifo View Post
That is definitely something I'd like to try and add in the future. I guess my real sticking point right now is how do I make a variable from a plugin to be passed/available for use in the postbit template?

Thanks again.
What hook location is your plugin using?

Both the hook evaluation and template evaluation have to be in the same scope. If either one is in a function, it's not going to work.

If you do this, it'll work:

Plugin code:
Code:
$GLOBALS['somevar'] = 'Hey';
In the template:
Code:
Here's my variable: $GLOBALS[somevar]
Reply With Quote
  #7  
Old 10-16-2007, 09:14 AM
sifo sifo is offline
 
Join Date: Mar 2007
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got it to work properly... thanks for all of the help here!
Reply With Quote
  #8  
Old 10-16-2007, 01:44 PM
Eikinskjaldi's Avatar
Eikinskjaldi Eikinskjaldi is offline
 
Join Date: Feb 2006
Location: Hell, never looked better
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In mysql you can prepend the table with the database name.

In other words, you can use the vbulletin mysql object, you dont have to make another, and you can join, call, whatever across databases.

select db1.table1.field1,db2.table2.field2....
Reply With Quote
  #9  
Old 12-22-2007, 12:58 AM
Oll1 Oll1 is offline
 
Join Date: Mar 2006
Location: Germany
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

if you are unable to print out the mysql data from eqdkp - this will work:

in plugin:

PHP Code:
$my_dkp $vbulletin->userinfo[fieldX]; 
(Remember: NO <?php & ?> Tags !!!!!!!)

in template:

PHP Code:
$my_dkp 
works fine for me
Reply With Quote
Reply


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 05:53 PM.


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.04119 seconds
  • Memory Usage 2,259KB
  • 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
  • (4)bbcode_code
  • (1)bbcode_html
  • (4)bbcode_php
  • (1)bbcode_quote
  • (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