vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Create Posts (https://vborg.vbsupport.ru/showthread.php?t=102418)

Thibaut 10-23-2007 03:43 PM

How can I get the id of the thread ?
Thanks

zytzagoo 10-24-2007 06:23 AM

Quote:

Originally Posted by Thibaut (Post 1366801)
How can I get the id of the thread ?
Thanks

PHP Code:

$thread_id $threaddm->save(); 


Thibaut 10-24-2007 07:08 AM

Thanks ! :)

Tinh.Nhi 11-21-2007 09:01 AM

how to use the code like thank please ?

paolo.capitani 12-21-2007 02:42 PM

thanks for the thread!
how can I add a break line in the content of the just added post?

TCooper 12-24-2007 04:57 PM

I was able to make a script that posts a new thread to a user defined forum but not able to make it post a reply to a current thread. I tried using the example in the first post and it didnt work, can someone please help with a new post to current thread.

amcd 12-24-2007 05:32 PM

PHP Code:

$postdm = new vB_DataManager_Post($vbulletinERRTYPE_STANDARD); 

$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);
$postdm->save();
unset(
$postdm); 

this works.

sonata 04-12-2008 01:43 PM

Quote:

Originally Posted by ruinernix (Post 1091515)
This works, but all messages created end up in a moderation queue even though the forum is not set to moderate posts/threads. I tried adding 'visible'=>'1' but it doesn't make a difference. Any clues? I suppose it's because I'm running this from an outside script, that isn't really logged into VB. I made a modification to functions_newpost.php
PHP Code:

Replaced:
    
// see if post has to be moderated or if poster in a mod
    
if ( 
        ((
With:
    
// see if post has to be moderated or if poster in a mod
    
if ( ($post['visible'] == 0) AND
        (( 

It does the job, but I'd like to understand why it's not working properly..

Any solution for this? I still encounter this problem when I use build_new_post function. Right now, I have to execute SQL queries to delete it from moderation table and set the visible flag to one. Any better solution?

amcd 04-12-2008 01:58 PM

build_new_post assumes that you are adding a post for the same user who is logged in. use the data manager.

silly rabbit 05-23-2008 02:53 PM

Quote:

Originally Posted by flypaper (Post 1283415)
Then you'd find the thread about HowTo Create Threads. ;)

Cute! flypaper, a somewhat related question to the topic at hand, creating posts . . .

. . . if editing an existing post I'd like to have a simple "check box" in the editor that would flag/include the updated post into the "New Posts" search engine for everyone to review, see. Ever seen such a hack before? Easily possible?

Great Thread, thx Rabbit

amcd 05-24-2008 07:44 AM

Quote:

Originally Posted by silly rabbit (Post 1529040)
Cute! flypaper, a somewhat related question to the topic at hand, creating posts . . .

. . . if editing an existing post I'd like to have a simple "check box" in the editor that would flag/include the updated post into the "New Posts" search engine for everyone to review, see. Ever seen such a hack before? Easily possible?

Great Thread, thx Rabbit

Not a good idea. To accomplish this, the time of the post would have to be edited, and that would move the post to the end of the thread.

The thread's last updated time can be updated, and that would bump the thread, but it will not solve your purpose. A 10 page thread may have a post on page 4 edited, and users will be wondering why the thread is on top of the forum when the last post is 3 months ago.

silly rabbit 05-25-2008 01:19 AM

Quote:

Originally Posted by amcd (Post 1529786)
Not a good idea. To accomplish this, the time of the post would have to be edited, and that would move the post to the end of the thread.

Thanks amcd! Yer right, moving the post by adjusting the time is not what I would have had in mind but at least now I have a better understanding of the problem at hand . . .

If I come up with another amicable solution myself I'll certainly post it here.

Hare says ThankYou & Cheers!

LoRdGd 06-10-2008 12:26 AM

Hello,
Can anybody help me with this one?

Quote:

$postdm = new vB_DataManager_Post($vbulletin, ERRTYPE_STANDARD);

$timenow = TIMENOW ;
$threadinfo = fetch_threadinfo($threadid);
$foruminfo = fetch_foruminfo($forumid);
$threadid = '19987';
$userid = '1500';
$symid='90000';

$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', $wiadomosc);
$postdm->set('allowsmilie', 1);
$postdm->set('visible', 1);
$postdm->set('dateline', $timenow);
$postdm->save();
unset($postdm);
Im trying to posing messages from FORM in my joomla based site... but nothing happens on the board :(
This form is in other dfrent directory, but im totaly newbie in php and i don`t know how to set a directory here.


Im using vB 3.7.1

Essencee 07-13-2008 12:26 PM

Quote:

Originally Posted by ragtek (Post 1365393)
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(); 


Thank you!
How can I get the post id after sending?

ragtek 07-13-2008 12:32 PM

you have to save it with $yourid = $threaddm->save();
thant it's stored in $yourid

hth

Essencee 07-13-2008 01:16 PM

Quote:

Originally Posted by ragtek (Post 1574202)
you have to save it with $yourid = $threaddm->save();
thant it's stored in $yourid

hth

Thank you my dear :)

dlitec 07-16-2008 01:25 PM

hey there
i tryed this too.. but i get back an error.. now first the code:
PHP Code:

$forumid 50;
$userid 1077;
$title '$PRODUCTS_MODEL - $PRODUCTS_NAME';
$pagetext 'Tatatatatestpost....';
        
$threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');

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

$threaddm->set('forumid'$forumid);
$threaddm->set('userid'$userid);
$threaddm->set('user''Onlineshop Kommentar');
$threaddm->set('title'$title);
$threaddm->set('pagetext'$pagetext);
$threaddm->set('allowsmilie'1);
$threaddm->set('visible'1);
$threaddm->set('dateline'TIMENOW);
$threaddm->save(); 

looks good to me.. but i'll recieve this:
"Fatal error: Call to a member function query_first_slave() on a non-object in /var/www/de/shop/www/htdocs/community/includes/functions.php on line 1303"

anyone has an idea what could be wrong? using 3.7.2 currently

LoRdGd 07-16-2008 01:49 PM

I`m not good in php, but i have make it some weeks ago.
Look at my thread in vbulletin.com: http://www.vbulletin.com/forum/showthread.php?t=275195

Maybe you will see something interesting :)

dlitec 07-16-2008 02:32 PM

thx lord.. but my code was correct

it was a problem between xtcommerce and this script.. no i'm handling it on another way ;)

dlitec 07-22-2008 01:02 PM

hmm sorry its me again

i wonder if its possible to vote threads with this too?!

i tried this:
PHP Code:

$postdm->set('votetotal'$voted); 

but recieved the standard error:
Field votetotal is not defined in $validfields in class vB_DataManager_Post in [path]/includes/class_dm.php

anyone has a clue?

edit:
extending in class_dm.php with this variable works.. no error anymore, but the voting is not transfered. do i really have to write into the DB directly? or is there a way?

fly 07-22-2008 06:53 PM

Quote:

Originally Posted by dlitec (Post 1581391)
hmm sorry its me again

i wonder if its possible to vote threads with this too?!

i tried this:
PHP Code:

$postdm->set('votetotal'$voted); 

but recieved the standard error:
Field votetotal is not defined in $validfields in class vB_DataManager_Post in [path]/includes/class_dm.php

anyone has a clue?

edit:
extending in class_dm.php with this variable works.. no error anymore, but the voting is not transfered. do i really have to write into the DB directly? or is there a way?

This is really offtopic for this thread, but if you want to rate threads, I'd check out class_dm_threadrate.php. If you want to vote in polls, class_dm_pollvote.php probably has what you need.

edit:
http://members.vbulletin.com/api/vBu...drate.php.html
http://members.vbulletin.com/api/vBu...lvote.php.html

dlitec 07-23-2008 06:34 AM

thanks for your advice.. i now solved it with direct db-query's ... i dont like the datamanager :(

i think next time i'll stay straight with php and mysql.

Hereward 07-24-2008 06:44 AM

Hi there,

I am trying to work out how to perform an update as opposed to an insert on the text of the first post of a thread.

I currently have the following which works fine for inserts:

PHP Code:

$threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
$forumid 36//$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'1);
$threaddm->set('title'$title);
$threaddm->set('pagetext'$body);
$threaddm->set('allowsmilie'1);
$threaddm->set('visible'1);
$threaddm->set('dateline'TIMENOW);
$threadid $threaddm->save(); 

Is there a way to change this from an insert to an update, by passsing in the threadid for example?

I tried this, which generated a 503 error:
PHP Code:

$threaddm->set('threadid'$threadid); 


Hereward 07-26-2008 12:20 PM

I have spent many hours now trying to solve the humble little problem stated above with no success.

this is heartbreaking.

I tried to set the post id using this:
PHP Code:

    $postid $postdm->fetch_field('firstpostid');
    
$postdm->set('postid'$postid); 

didn't work

fly 07-26-2008 01:48 PM

Quote:

Originally Posted by Hereward (Post 1584590)
I have spent many hours now trying to solve the humble little problem stated above with no success.

this is heartbreaking.

I tried to set the post id using this:
PHP Code:

    $postid $postdm->fetch_field('firstpostid');
    
$postdm->set('postid'$postid); 

didn't work

Do it with a SQL query then...

Hereward 07-27-2008 03:01 AM

yeah that's exactly what I am going to do, but it seems wrong when there is an API which supposedly can do all this - but since I do not understand how it works and cannot find a working example or documentation other than the comments in the code itself it doesn;t seem likely that I am going to work it out without a miracle.

amcd 07-27-2008 05:52 AM

There is no miracle needed. The vbulletin code is very well organized and commented.

I guess there must be a way of telling the thread data manager to pre-load itself with the thread. Then change whatever you want to and tell it to save. That should do an update.

Read the data manager class in the includes directory. Or else read any of the default vb scripts which o an update, such as the edit thread function from thread tools dropdown.

Hereward 07-27-2008 12:38 PM

"well documented" ..? you gotta be joking

but I have figured it out now:
In order to force the save command to do an update instead of an insert you need to use
set_existing:

PHP Code:

$existing = array('userid' => $userid,'threadid'=>$threadid);
$threaddm->set_existing($existing); 

This works (: (:

amcd 07-27-2008 12:54 PM

Quote:

Originally Posted by Hereward (Post 1585236)
"well documented" ..? you gotta be joking

It is. You haven't seen the bad stuff. There are a huge number of scripts out there which are not even indented properly and are being sold for $400 and above.

nuk3 07-30-2008 04:08 AM

Quote:

Originally Posted by Hereward (Post 1585236)
"well documented" ..? you gotta be joking

Quote:

Setting the existing data (if necessary)
If you are using the data managers to insert a new record into the database, you do not need to perform this step. However, if you are updating an existing record (eg, editing a post), this step is mandatory.

To set the existing data, you must call the set_existing method of the data manager object.

set_existing(&$existing)

The $existing is an array of data that is currently stored in the database. It should include all the fields this data manager handles as keys. *snip*
http://www.vbulletin.com/docs/html/d...er_programming

How you could've not checked and/or found that documentation in the first place is seriously beyond me, being the first result on google for vbulletin datamanager and all. It explains everything you could need to know and also has relevant real world examples provided too. So take your ignorant minded "well documented" attack and shove it.

vrinteractive 09-19-2008 10:39 PM

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

fly 09-19-2008 11:28 PM

Quote:

Originally Posted by vrinteractive (Post 1625938)
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...

LoRdGd 09-20-2008 11:53 AM

Read my topic on vbulletin.com:
http://www.vbulletin.com/forum/showt...23#post1578823

Mutt 05-03-2009 04:07 PM

Quote:

Originally Posted by ragtek (Post 1365393)
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

ULFSoft 06-02-2009 08:41 PM

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

todd73nj 09-01-2009 01:07 AM

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;

?>


amcd 09-01-2009 07:28 AM

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?

todd73nj 09-01-2009 01:12 PM

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


ewelin 10-07-2009 07:12 PM

Quote:

Originally Posted by Evercraft (Post 960421)
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.

amcd 10-08-2009 08:50 AM

Did you try build_thread_counters?


All times are GMT. The time now is 04:06 PM.

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.01652 seconds
  • Memory Usage 1,936KB
  • 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
  • (19)bbcode_php_printable
  • (16)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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