Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Create Posts
fly
Join Date: Oct 2003
Posts: 1,215

 

Show Printable Version Email this Page Subscription
fly fly is offline 12-06-2005, 10:00 PM

PHP Code:
require_once('./global.php');
require_once(
'./includes/class_dm.php');
require_once(
'./includes/class_dm_threadpost.php');

$postdm = new vB_DataManager_Post($vbulletinERRTYPE_STANDARD);

$postthreadid '4473';
$postusername 'admin';
// Use $postusername if posting as a guest, use $postuserid if posting as a user
//$postuserid = '1';
$postpagetext 'Hi mom!';

$threadinfo fetch_threadinfo($postthreadid);
$foruminfo fetch_foruminfo($threadinfo['forumid']);

$postdm->set_info('forum'$foruminfo);
$postdm->set_info('thread'$threadinfo);  
$postdm->set('threadid'$postthreadid);
$postdm->set('username'$postusername);
// Use $postusername if posting as a guest, use $postuserid if posting as a user
//$postdm->set('userid', $postuserid);
$postdm->set('pagetext'$postpagetext);
$postdm->set('allowsmilie'1);
$postdm->set('visible'1);
$postdm->set('dateline'TIMENOW);
$postdm->save();
unset(
$postdm); 
Reply With Quote
  #72  
Old 09-19-2008, 10:39 PM
vrinteractive vrinteractive is offline
 
Join Date: Nov 2005
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is there a setting i need to configure in admincp? I'm trying to add a forum thread useing the datamanger_init, and save is returning a new id, but when i try to visit the thread i get a permissions error. it's on 3.7.2
Reply With Quote
  #73  
Old 09-19-2008, 11:28 PM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by vrinteractive View Post
is there a setting i need to configure in admincp? I'm trying to add a forum thread useing the datamanger_init, and save is returning a new id, but when i try to visit the thread i get a permissions error. it's on 3.7.2
I think there is another thread on how to create threads. It may be more ontopic there. Otherwise, I think we'd need to see your code...
Reply With Quote
  #74  
Old 09-20-2008, 11:53 AM
LoRdGd LoRdGd is offline
 
Join Date: Mar 2008
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Read my topic on vbulletin.com:
http://www.vbulletin.com/forum/showt...23#post1578823
Reply With Quote
  #75  
Old 05-03-2009, 04:07 PM
Mutt's Avatar
Mutt Mutt is offline
 
Join Date: Nov 2001
Posts: 331
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ragtek View Post
with this code:
PHP Code:
$threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');

$forumid $vbulletin->GPC['fid']; // can also be a number ;) $forumdid= 12;

$foruminfo fetch_foruminfo($forumid);
$threaddm->set_info('forum'$foruminfo);

$threaddm->set('forumid'$foruminfo['forumid']);
$threaddm->set('userid'1234);
$threaddm->set('title''Testtitle');
$threaddm->set('pagetext''a little test');
$threaddm->set('allowsmilie'1);
$threaddm->set('visible'1);
$threaddm->set('dateline'TIMENOW);
$threaddm->save(); 
if you need the threadid save it with
PHP Code:
$id $threaddm->save(); 

this works but how can I also set the prefix? added a prefix line returns an error

--------------- Added [DATE]1241372989[/DATE] at [TIME]1241372989[/TIME] ---------------

found it. you have to use "prefixid" & you set it to the prefix var. like this

$threaddm->set('prefixid', 'report');

I'm using this for our mod forum so alerted posts or pms have prefixes
Reply With Quote
  #76  
Old 06-02-2009, 08:41 PM
ULFSoft ULFSoft is offline
 
Join Date: Jul 2008
Location: web
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

how can i attach file when i want to create a thread with data manager?
i think that i must use class_dm_attachment.php but how?
can anyone help me?
(i am new to vb programming!)
Reply With Quote
  #77  
Old 09-01-2009, 01:07 AM
todd73nj todd73nj is offline
 
Join Date: Aug 2008
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I was wondering if someone could tell me what is wrong with my script. All I am trying to do is post a new message in an existing thread. When I put this script in a php page and hit it from my browser, I don't get any error, but I also don't get a message posted. I don't even see the "save returned" message in my browser. If I change some things (like the path to class_dm_threadpost), I get an error, so I know it is running something.

As for the echo not working, it seems like as soon as I put those require_once at the top of my file, I can't echo any messages anymore. But I only have those echos in there because the message isn't being posted to my thread.

PHP Code:
<?php
require_once('global.php'); 
require_once(
'./includes/class_dm_threadpost.php');

$postdm = new vB_DataManager_Post($vbulletinERRTYPE_STANDARD); 

$threadid=1565;
$forumid=5;
$symid='asdf';
$userid=2;
$message="Testing.Testing.Testing.Testing.Testing.";

$timenow TIMENOW;
$threadinfo fetch_threadinfo($threadid);
$foruminfo fetch_foruminfo($forumid);

$postdm->set_info('forum'$foruminfo);
$postdm->set_info('thread'$threadinfo);  
$postdm->set('threadid'$threadid);
$postdm->set('title'$symid);
$postdm->set('userid'$userid);
$postdm->set('pagetext'$message);
$postdm->set('allowsmilie'1);
$postdm->set('visible'1);
$postdm->set('dateline'$timenow);
$xxx $postdm->save();
unset(
$postdm);  
echo 
"save returned:";
echo 
$xxx;

?>
Reply With Quote
  #78  
Old 09-01-2009, 07:28 AM
amcd amcd is offline
 
Join Date: Oct 2004
Posts: 218
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you have access to php.ini and/or PHP error log? Check the error log.

If echo does not work, try the PHP error_log() function. You may also find the var_export() function useful.

I have almost the same code working with vb 3.6.1. What is your version?
Reply With Quote
  #79  
Old 09-01-2009, 01:12 PM
todd73nj todd73nj is offline
 
Join Date: Aug 2008
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am running 3.7.4 PL1.

If I start with an empty php file and just put an echo statement, I see the message when I hit the page. Anything I echo before the line that includes class_dm_threadpost.php I see output, but anything after I don't. For example:

PHP Code:
<?php
require_once('global.php'); 
require_once(
'./includes/class_dm_threadpost.php');

echo 
"Hello world.";
?>
Shows nothing in the page. But
PHP Code:
<?php
require_once('global.php'); 
echo 
"Hello world.";
require_once(
'./includes/class_dm_threadpost.php');

?>
Shows "Hello world." on the page.

I am using godaddy, so I don't know how I can access the php error file. I tried using an set_error_handler as described on this page: http://us3.php.net/set-error-handler , to catch any errors, but still I got no output. It is bizarre. It is like including that class_dm_threadpost is killing everything. I have not modified any of my vbulletin files, so it should be whatever came with 3.7.4.

var_export() behaves the same way as echo. Before that require_once line it works, after it, I see nothing.

--------------- Added [DATE]1251815891[/DATE] at [TIME]1251815891[/TIME] ---------------

Doh. I figured it out. I have to include another file as well (class_dm.php). It seems like without it, something in the class_dm_threadpost was unhappy.

This works:

PHP Code:
<?php
require_once('global.php'); 
require_once(
'./includes/class_dm.php'); 
require_once(
'./includes/class_dm_threadpost.php');

$threadid=1565;
$forumid=5;
$symid='asdf';
$userid=2;
$message="Testing.Testing.Testing.Testing.Testing.";

$timenow TIMENOW;
$threadinfo fetch_threadinfo($threadid);
$foruminfo fetch_foruminfo($forumid);

$postdm = new vB_DataManager_Post($vbulletinERRTYPE_STANDARD); 
$postdm->set_info('forum'$foruminfo);
$postdm->set_info('thread'$threadinfo);  
$postdm->set('threadid'$threadid);
$postdm->set('title'$symid);
$postdm->set('userid'$userid);
$postdm->set('pagetext'$message);
$postdm->set('allowsmilie'1);
$postdm->set('visible'1);
$postdm->set('dateline'$timenow);
$xxx $postdm->save();
unset(
$postdm);  
echo 
'save returned:';
echo 
$xxx;
?>
Reply With Quote
  #80  
Old 10-07-2009, 07:12 PM
ewelin ewelin is offline
 
Join Date: Dec 2007
Location: Cambridge, MA
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Evercraft View Post
You need to add the following code, after the post has been created, to update forum counters and last post index etc.

PHP Code:
require_once(DIR '/includes/functions_databuild.php');
build_forum_counters($threadinfo['forumid']); 
I have a slight problem.... My code is inserting the post perfectly and everything is working in that respect. The problem is that the last post field is not being updated. I know this has something to do with the timestamp, but I'm not sure why the issue is happening. I'm importing a chat transcript and putting each chat post as a forum post. The import script runs every 5 minutes and uses the chat post's timestamp as the forum post time stamp. The forum posts appear just as they were posted within the chat and the time is dead on... Even with the above code included at the end, it only updates the forum counters, it doesn't update the last post index. Now if I swap the timestamp from the actual chat post time to TIMENOW
it's updated. Anyone have any ideas on how I can resolve this.
Reply With Quote
  #81  
Old 10-08-2009, 08:50 AM
amcd amcd is offline
 
Join Date: Oct 2004
Posts: 218
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you try build_thread_counters?
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 12: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.05022 seconds
  • Memory Usage 2,375KB
  • Queries Executed 26 (?)
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
  • (8)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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_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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • 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