vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Auto-creation of threads? (https://vborg.vbsupport.ru/showthread.php?t=61030)

Wired1 02-01-2004 06:43 AM

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.

Xenon 02-01-2004 04:21 PM

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

Wired1 02-02-2004 02:38 AM

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.

Xenon 02-02-2004 02:05 PM

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

Wired1 02-02-2004 10:05 PM

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!

Wired1 02-04-2004 11:25 PM

Code:

function build_new_post($type = 'thread', $foruminfo, $threadinfo, $parentid, &$post, &$errors)
Ok, I found it and I've been looking into the arguments, i.e. $foruminfo. It looks like it's an array. However, I can't find an easy list on all of the values that I need to pass to it. Same goes for $threadinfo. &$post I think I've got down as the description of the function details it. Somewhat worried about
Code:

        $post['posthash'] = trim($post['posthash']);
but I'll leave them for later.

Code:

$foruminfo = verify_id('forum', $_REQUEST['forumid'], 1, 1);
I did find this snippet pertaining to $foruminfo, but I've seen other array cells referenced throughout the code.

Xenon 02-04-2004 11:26 PM

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

Wired1 02-05-2004 03:09 AM

Gotcha. They really need better commenting in their code :) Is there a code comment manual I missed or something?

Xenon 02-05-2004 05:03 PM

not right now, but iirc something like that is planned :)

you have to remember vb3 is not yet released final ;)

Wired1 02-06-2004 02:11 AM

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:

require_once('./forums/includes/functions_newpost.php');
require_once(
'./forums/includes/functions.php');
require_once(
'./forums/includes/functions_login.php'); 

$foruminfo['forumid'] = 8;
$threadinfo['open'] = 1;
$threadinfo['visible'] = 1;

//$threadinfo['title'] = 'This is the test title';
//$threadinfo['forumid'] = 8;
//$threadinfo['postusername'] = 'Poster';
//$threadinfo['postuserid'] = 5;


$post['title'] = 'This is the test title';
$post['username'] = 'Poster';
$post['userid'] = 5;
$post['pagetext'] = 'This is the message stuff\n    Hope this words\n\n\n\n TESTTTTTTT\n';
$post['preview'] = 0;

build_new_post('thread'$foruminfo$threadinfo0$post$errors); 

I'm getting this error:
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:

// remove sessionhash from urls:
require_once('./includes/functions_login.php');
$post['message'] = fetch_removed_sessionhash($post['message']); 

After I got that error, I added the require into the page, but with no effect. Any suggestions?

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?


All times are GMT. The time now is 12:24 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.01141 seconds
  • Memory Usage 1,746KB
  • 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
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete