The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Auto-creation of threads?
Hey guys, I'm working on a site where I will have certain admins enter in data into a form, which slaps the data into a couple of tables. What I'd like it to do is to create a new thread in a specific forum based upon certain pre-existing criteria. It will only create a new thread when new data is entered. It would be great if I could have it also create the sub-forums, but I can handle that myself for the time being.
In one of the tables will be a column for the forum ID that the new thread will be created in. I've been looking through the functions_newpost.php and newthread.php, but I'm not quite sure how to set it up so that it will create the thread for me. Yes, I do intend for it to create a first post with relevant info. Uniquely formatting the first post of these auto-created threads will be my next venture. The problem I'm having is the actual vB stuff, how to get it to make a new thread, the integration stuff. If I'm right, I should just be able to pass values to the title and message variables into the newthread.php file, along with the value of f, which is the forumID, and it will do the rest, but I'm not quite sure. So, has anyone else done something like this before? Can anyone point me in the right direction? Thanks! BTW, I've taken a quick look at the talker bot code, and some of it points towards how new posts can be created, but not new threads. Hope that helps anyone else that's interested in a snippet like this. |
#2
|
||||
|
||||
in functions_newpost.php there is the build_newpost function, you just have to submit an array to this functions containing all info like forumid, authorid, message.... and type = 'thread' and it will insert the new thread for ya
|
#3
|
||||
|
||||
Well, that certainly seems easier than submitting info directly to multiple tables like it was seeming I was going to have to do.
I've been thinking of the message portion. For example, in my first post in this thread, I spaced out the paragrahs, but when I check out the table entry for a similar post, it appears as if the paragrahs just run together. In otherwords, is there any secret to get the formatting right? Also, if I wanted to place an image within the message in a certain place if the pic flag is marked in a table, would it be easier to just have an if statement within the postbit template for this, or is there a way to easily set up the formatting in the afforementioned functions? I already have an if stmt in the postbit to make any post by the bot formatted in a non-default way. |
#4
|
||||
|
||||
it's safer to use if statements, especially if you already did something like that already.
i don't get what you mean by getting the formatting right. When you enter a post directly to the db, it's not different than posting it manually, it will be parsed when you go to showthread, and there it will convert all new lines(\n) into <br /> tags |
#5
|
||||
|
||||
Hrm... I'm using the Webmin sw that's on my server (RedHat IIRC) and looking into the post table, I don't see the HTML formatting (i.e. \n, etc.) and the test just runs together... Wait... if I go in to edit an entry, the formatting isn't there (\n) but it looks normal, yippee!
Ok, this is making much more sense now, eheh. Thanks Xenon. I'll report back if everything goes well or not, and if it does, it'll be quite an interesting site! |
#6
|
||||
|
||||
Code:
function build_new_post($type = 'thread', $foruminfo, $threadinfo, $parentid, &$post, &$errors) Code:
$post['posthash'] = trim($post['posthash']); Code:
$foruminfo = verify_id('forum', $_REQUEST['forumid'], 1, 1); |
#7
|
||||
|
||||
just look into the forum / thread /post table.
every field you have in these tables can be within the $...info array. but you don't have to use every entry |
#8
|
||||
|
||||
Gotcha. They really need better commenting in their code Is there a code comment manual I missed or something?
|
#9
|
||||
|
||||
not right now, but iirc something like that is planned
you have to remember vb3 is not yet released final |
#10
|
||||
|
||||
Hehe, I know, but when I was checking out vb2 code, I don't recall seeing any decent amount of comments either. Starting a bit of coding right now, I'll update this with the results.
Update: Grrrr........ Here's my code so far: PHP Code:
Warning: build_new_post(./includes/functions_login.php): failed to open stream: No such file or directory in .../includes/functions_newpost.php on line 212 Fatal error: build_new_post(): Failed opening required './includes/functions_login.php' (include_path='.:/usr/share/pear') in .../includes/functions_newpost.php on line 212 Line 211-213: PHP Code:
BTW, after this darn thing gets functional, I think I'll slap the good stuff from this thread and post a basic tutorial about this so it can help others. That ok with you? If so, what sub-forum would you recommend it be placed in? |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|