Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2011, 03:31 PM
radiofranky radiofranky is offline
 
Join Date: Jun 2011
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default which PHP file contains posting sql function?

Hi,
I have created additional fields in my editor and I would like to able to store those variables into database. However, I'm not quit familiar with VB yet and don't know which file contains the code for submitting the post bits to db.

I have manually create three "columns" named "price", "orig_price" and "pct".
Could someone show me where sql command is called during posting and when it pulls out to render in the template.

thanks
Reply With Quote
  #2  
Old 07-28-2011, 03:39 PM
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Posts: 4,141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I believe it would be: includes/functions_newpost.php
Reply With Quote
  #3  
Old 07-28-2011, 03:47 PM
radiofranky radiofranky is offline
 
Join Date: Jun 2011
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by HMBeaty View Post
I believe it would be: includes/functions_newpost.php
thanks. I have the following code as a plugin which adds two extra input fields during new post. Stored in "price" and "saleprice", it also calculate the third value "pct".
I would like to store them into db with the thread of the postbits. Could you help me figure it out? Thanks


Code:
$vbulletin->input->clean_array_gpc('p', array( 
              'saleprice'         => TYPE_uinit, 
              'price'          => TYPE_uinit)); 
              $price = $vbulletin->GPC['price'];
              $saleprice = $vbulletin->GPC['saleprice'];
              vB_Template::preRegister('newthread', array('price' => $price, 'saleprice' => $saleprice)); 
$pct = intval((1-($vbulletin->GPC['saleprice']  / $vbulletin->GPC['price']))*100 );
          $vbulletin->GPC['subject'] .= " for $".$vbulletin->GPC['saleprice'] .", {$pct}% off (orig.$" . $vbulletin->GPC['price'] . ")";


i see this
Code:
function build_new_post($type = 'thread', $foruminfo, $threadinfo, $postinfo, &$post, &$errors)
and should i add my variable to it?
Reply With Quote
  #4  
Old 07-28-2011, 04:07 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In includes/class_dm_threadpost.php, around line 1515 is class vB_DataManager_ThreadFirstPost, if you scroll down you see a $validfields array which I believe are the columns from the thread table. If you scroll down further you see this:

PHP Code:
    function vB_DataManager_Thread_FirstPost(&$registry$errtype ERRTYPE_STANDARD)
    {
        
parent::vB_DataManager($registry$errtype);

        (
$hook vBulletinHook::fetch_hook('threadfpdata_start')) ? eval($hook) : false;
    } 

which is executed when one of those objects is created, so if you create a plugin using hook threadfpdata_start, you should be able to add your fields to the $validfields array. Then in build_new_post() in includes/functions_newpost.php, you can see the fields being set. So you should be able to create a plugin using hook newpost_process and something like:

PHP Code:
if ($type == 'thread')
{
    
$dataman->setr('price'$post['price']);
    
// etc.


(BTW, I haven't actually tried this).
Reply With Quote
  #5  
Old 07-28-2011, 04:19 PM
radiofranky radiofranky is offline
 
Join Date: Jun 2011
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks very much..

How do I set the third variable "pct" which is the result of calculation from "price" and "saleprice"?

since the three additional fields were done by another plugin, will this work?

PHP Code:
if ($type == 'thread')
{
    
$dataman->setr('price'$post['price']);
    
$dataman->setr('saleprice'$post['saleprice']);
    
$dataman->setr('pct'$post['pct']);
    
// etc.

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

As long as the other plugin runs first. I guess it'll be easy enough to tell. If they were done in newthread.php before build_new_post() is called, you'll be OK.

--------------- Added [DATE]1311888277[/DATE] at [TIME]1311888277[/TIME] ---------------

Where do you want to read them? Your other thread said postbit, but this is a thread thing and not a post thing. Anyway, it might be available already. In a template you could try {vb:raw thread.price}.
Reply With Quote
  #7  
Old 07-28-2011, 09:38 PM
radiofranky radiofranky is offline
 
Join Date: Jun 2011
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

actually I want to display in vbadvanced template. Thanks

Quote:
Originally Posted by kh99 View Post
As long as the other plugin runs first. I guess it'll be easy enough to tell. If they were done in newthread.php before build_new_post() is called, you'll be OK.

--------------- Added [DATE]1311888277[/DATE] at [TIME]1311888277[/TIME] ---------------

Where do you want to read them? Your other thread said postbit, but this is a thread thing and not a post thing. Anyway, it might be available already. In a template you could try {vb:raw thread.price}.
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 04:40 PM.


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.08086 seconds
  • Memory Usage 2,233KB
  • 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
  • (2)bbcode_code
  • (3)bbcode_php
  • (2)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
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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