vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   which PHP file contains posting sql function? (https://vborg.vbsupport.ru/showthread.php?t=267575)

radiofranky 07-28-2011 03:31 PM

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

HMBeaty 07-28-2011 03:39 PM

I believe it would be: includes/functions_newpost.php

radiofranky 07-28-2011 03:47 PM

Quote:

Originally Posted by HMBeaty (Post 2226068)
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?

kh99 07-28-2011 04:07 PM

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

radiofranky 07-28-2011 04:19 PM

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.



kh99 07-28-2011 04:24 PM

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

radiofranky 07-28-2011 09:38 PM

actually I want to display in vbadvanced template. Thanks

Quote:

Originally Posted by kh99 (Post 2226098)
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}.



All times are GMT. The time now is 02:39 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.01115 seconds
  • Memory Usage 1,741KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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