Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-01-2004, 06:43 AM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 02-01-2004, 04:21 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #3  
Old 02-02-2004, 02:38 AM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 02-02-2004, 02:05 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 02-02-2004, 10:05 PM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #6  
Old 02-04-2004, 11:25 PM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 02-04-2004, 11:26 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 02-05-2004, 03:09 AM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Gotcha. They really need better commenting in their code Is there a code comment manual I missed or something?
Reply With Quote
  #9  
Old 02-05-2004, 05:03 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

not right now, but iirc something like that is planned

you have to remember vb3 is not yet released final
Reply With Quote
  #10  
Old 02-06-2004, 02:11 AM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:22 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05030 seconds
  • Memory Usage 2,272KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete