Log in

View Full Version : datamanager question


Brother Malachi
11-08-2009, 05:59 AM
So, I'm trying to add a new thread via a plugin I wrote:

$threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_STANDARD, 'threadpost');
$threadman->set_existing($threadinfo);
$threadman->set('pollid', $pollid);
$threadman->save();

It works just fine, creating the thread where it is supposed to be created.

I've added a new column called "ent_attach" in the thread table and need to set its value to 1 via the above plugin.
I tried doing$threadman->setr('ent_attach', 1);
as well as $threadman->set('ent_attach', 1);
but it's not working. Anything I'm missing?

--------------- Added 1257674386 at 1257674386 ---------------

Ok I added this:
$this->validfields['ent_attach'] = array(TYPE_INT, REQ_NO);
via threaddata_start plugin.
It is still not working tho.
Am I missing something?

Lynne
11-08-2009, 04:08 PM
Adding it to the validfields should work. You have to set the field prior to doing the save - you didn't say exactly where you added that line, nor did you say which hook location you are using.

Brother Malachi
11-08-2009, 06:45 PM
Adding the validfields php to the threadfpdata_start hook.
I also tried threaddata_start but it seems like threadfp one is the right one.
When I set it to REQ_YES instead of REQ_NO, it won't let me post a thread neither from my plugin nor from a new thread page telling me I'm missing that field.

The $threadman->set(); i put right before the save().

That goes in a plugin in misc.php page where I'm setting up a custom form for my members.
Basically, the goal is to have them fill it out and it posts a new thread in a specific forum and sets that mysql column value to 1.

Lynne
11-08-2009, 08:14 PM
threadfpdata_start is for the first post only. If you are only going to use this when creating a new thread (thus a first post), then that is fine to use.

What hook location are you using in the misc.php file? It would help to see exactly what you have right now since you've changed things.

Brother Malachi
11-08-2009, 09:24 PM
Never mind. I decided to use a simple query to take care of the problem.