vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   modifying INSERT INTO thread query (https://vborg.vbsupport.ru/showthread.php?t=95343)

HakkieDEV 08-30-2005 08:56 PM

modifying INSERT INTO thread query
 
Hiya,

I'd like to know IF its possible to modify the INSERT INTO thread query.

I've a couple of extra fields when posting a new thread, I'd like to have them being inserted into the database together with the threadtitle, dateline etc.

Andreas 08-30-2005 09:03 PM

Take a look at build_new_post().

HakkieDEV 08-31-2005 02:28 PM

I had a look in functions_newpost.php, but I can't find a hook overthere?

I've currently done:

in newthread_post_start:
PHP Code:

$vbulletin->input->clean_gpc('p''field1'TYPE_STR);
$newpost['field1'] =& $vbulletin->GPC['field1'];
$vbulletin->input->clean_gpc('p''field2'TYPE_STR);
$newpost['field2'] =& $vbulletin->GPC['field2']; 

and in threadfpdata_start:
PHP Code:

$this->validfields['field1'] = array(TYPE_STRREQ_NO);
$this->validfields['field2'] = array(TYPE_STRREQ_NO); 

But, this doesn't work. Any idea what I am doing wrong here?

HakkieDEV 09-04-2005 02:01 PM

Sorry for bumping this thread, but I really want to have this fixed. :)

Andreas 09-04-2005 02:17 PM

There are Hooks ;)

Try

newthread_post_start
PHP Code:

$vbulletin->input->clean_array_gpc('p', array('field1' => TYPE_STR'field2'TYPE_STR));
$newpost['field1'] =& $vbulletin->GPC['field1'];
$newpost['field2'] =& $vbulletin->GPC['field2']; 

threadfpdata_start
PHP Code:

$this->validfields['field1'] = array(TYPE_STRREQ_NO);
$this->validfields['field2'] = array(TYPE_STRREQ_NO); 

newpost_process
PHP Code:

if ($type == 'thread)
{
    $dataman->setr('
field1', $post['field1']);
    $dataman->setr('
field2', $post['field2']);



HakkieDEV 09-04-2005 08:24 PM

Thanks KirbyDE, I owe you one!

waherne 10-26-2005 10:56 AM

Andreas (or KirbyDE!), thanks for the solution to HakkieDEV's query - it works perfectly. Next question focuses on editing!

Could you or anyone else tell me how one would edit data contained in those fields which were added to the thread table? I can load the original field data into the editing form but on submission, I cannot update the thread table. The issue is that the extra field names (e.g. field1, field2) are considered invalid. I think that something like the hook for threadfpdata_start is needed but I'm not sure how to go about this.

Any help very much appreciated.

W

jaybolt 04-25-2006 08:14 PM

Quote:

Originally Posted by Andreas
There are Hooks ;)

Try

newthread_post_start
PHP Code:

$vbulletin->input->clean_array_gpc('p', array('field1' => TYPE_STR'field2'TYPE_STR));
$newpost['field1'] =& $vbulletin->GPC['field1'];
$newpost['field2'] =& $vbulletin->GPC['field2']; 

threadfpdata_start
PHP Code:

$this->validfields['field1'] = array(TYPE_STRREQ_NO);
$this->validfields['field2'] = array(TYPE_STRREQ_NO); 

newpost_process
PHP Code:

if ($type == 'thread)
{
    $dataman->setr('
field1', $post['field1']);
    $dataman->setr('
field2', $post['field2']);



There is a typo in this. It should be:

if ($type == 'thread')
{
$dataman->setr('field1', $post['field1']);
$dataman->setr('field2', $post['field2']);
}

Andreas - when I use this, it writes the first field fine but won't write the second field. Any ideas?


All times are GMT. The time now is 05:31 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.01135 seconds
  • Memory Usage 1,747KB
  • 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
  • (8)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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