Log in

View Full Version : modifying INSERT INTO thread query


HakkieDEV
08-30-2005, 08:56 PM
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:

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

$this->validfields['field1'] = array(TYPE_STR, REQ_NO);
$this->validfields['field2'] = array(TYPE_STR, REQ_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

$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

$this->validfields['field1'] = array(TYPE_STR, REQ_NO);
$this->validfields['field2'] = array(TYPE_STR, REQ_NO);


newpost_process

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
There are Hooks ;)

Try

newthread_post_start

$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

$this->validfields['field1'] = array(TYPE_STR, REQ_NO);
$this->validfields['field2'] = array(TYPE_STR, REQ_NO);


newpost_process

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?