vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   vB_DataManager_Thread, How do I do? (https://vborg.vbsupport.ru/showthread.php?t=158660)

ralle89 09-03-2007 04:35 PM

vB_DataManager_Thread, How do I do?
 
Hey!
I am trying to generate threads with the class: vB_DataManager_Thread.
I tried searching Google and the forums.
I couldn't really find what I need.

I need a simple piece of code on how to make a thread in forum, by userid, with contents and dateline.

I have seached a lot,

Thanks in advance,
Ralle

Delphiprogrammi 09-03-2007 06:08 PM

hi,

You must create a datamanager instance set the things you want to set check for errors and finally when things are ok save them

PHP Code:

$threaddm =& datamanager_init('Thread_FirstPost',$vbulletin,ERRTYPE_ARRAY,'threadpost');
  
$threaddm->setr('forumid',$destforum);
  
$threaddm->setr('title','');
  
$threaddm->setr('pagetext','');
  
$threaddm->set('userid','');
  
$threaddm->set('open',1);
  
$threaddm->set('visible',1);
  
$threaddm->set('allowsmilie',1);
  
$threaddm->set_info('forum',$newforuminfo);
  
$threaddm->set_info('thread',array());
  
$threaddm->pre_save();
  if(!empty(
$threaddm->errors))
  {
   
print_r($threaddm->errors);
   exit;
  }
  else
  {
   
$newthreadid $threaddm->save();
  } 

now you have at least an idea howto do it $newforuminfo is coming from a fetch_foruminfo(); call

ralle89 09-03-2007 06:43 PM

Never mind, I fixed it.
I replaced all setr with set
Once again, thank you!
Quote:

Thank you for your response and the big help. But I cannot get this to work.
This is my code:
PHP Code:

<?php
// don't look at the $scriptpath variable. It's assigned from an upper file.
require_once("$scriptpath/vbulletin.php");
require_once(
'./includes/class_dm.php');
require_once(
'./includes/class_dm_threadpost.php');

$threaddm =& datamanager_init('Thread_FirstPost',$vbulletin,ERRTYPE_ARRAY,'threadpost');
$threaddm->setr('forumid',$destforum);
$threaddm->setr('title','Peter Jackson');
$threaddm->setr('pagetext','This thread [b]rocks!');
$threaddm->set('userid','1');
$threaddm->set('open',1);
$threaddm->set('visible',1);
$threaddm->set('allowsmilie',1);
$threaddm->set_info('forum',$newforuminfo);
$threaddm->set_info('thread',array());
$threaddm->pre_save();
if(!empty(
$threaddm->errors)) {
    
print_r($threaddm->errors);
    exit;
} else {
    
$newthreadid $threaddm->save();
}

?>

And I am getting this error:
Code:

Fatal error:  Cannot pass parameter 2 by reference in /[...]/tools_thread.php on line 9
I tried to uncomment this line:
PHP Code:

$threaddm->setr('title','Peter Jackson'); 

But then it just started complaining about the next line

Opserty 09-03-2007 07:38 PM

In setr the value is passed as a reference. (So it must be a variable I assume.)

PHP Code:

$title 'Peter Jackson';
$threaddm->setr('title'$title); 

Would work, I think.

Paul M 09-03-2007 07:47 PM

Correct - setr() means set by reference, so cannot be a constant.

toucan42 09-21-2007 06:34 PM

I am getting the following error:

That username is already in use or does not meet the administrator's standards.

any ideas?

Opserty 09-21-2007 06:52 PM

Didn't you read the error?
Quote:

That username is already in use or does not meet the administrator's standards.
It seems pretty self explanatory to me.

You probably need to add something like:

PHP Code:

$threaddm->set('username''Username for Userid #1 or something here'); 

To the list.

toucan42 09-21-2007 07:23 PM

Quote:

Originally Posted by Opserty (Post 1344022)
Didn't you read the error?
It seems pretty self explanatory to me.

You probably need to add something like:

PHP Code:

$threaddm->set('username''Username for Userid #1 or something here'); 

To the list.

Of course I read the error - how else would I know to post the durn thing!?

It just doesn't make sense to me.

I already have:

PHP Code:

$threaddm->setr('username'$uname); 

you are using set i am using setr but both flavors give the same result. :confused:

Opserty 09-21-2007 08:53 PM

What is the value of $uname? Also make sure it is set to the username of the member with the same userid which is defined earlier.

toucan42 09-21-2007 10:58 PM

Here is my entire script - the variables in $_GET are all form variables being sent via AJAX to a page processing the form and creating a new thread:

PHP Code:

<?php
    
    
// Get Required Includes
    
require_once('global.php');
    require_once(
'includes/class_dm.php');
    require_once(
'includes/class_dm_threadpost.php'); 
    require_once(
'includes/functions_databuild.php'); 
        
        
// Retrieve data from Query String
    
$name $_GET['name'];
    
$lat $_GET['lat'];
    
$lon $_GET['lon'];
    
$uid $_GET['uid'];
    
$uname $_GET['uname'];
    
$gid $_GET['gid'];
    
$desc $_GET['desc'];
    
$phone $_GET['phone'];
    
$addr $_GET['addr'];
    
$addr2 $_GET['addr2'];
    
$city $_GET['city'];
    
$state $_GET['state'];
    
$zip $_GET['zip'];
    
$cat $_GET['cat'];

    
// Escape User Input to help prevent SQL Injection
    
$name mysql_real_escape_string($name);
    
$lat mysql_real_escape_string($lat);
    
$lon mysql_real_escape_string($lon);
    
$uid mysql_real_escape_string($uid);
    
$uname mysql_real_escape_string($uname);
    
$gid mysql_real_escape_string($gid);
    
$desc mysql_real_escape_string($desc);
    
$phone mysql_real_escape_string($phone);
    
$addr mysql_real_escape_string($addr);
    
$addr2 mysql_real_escape_string($addr2);
    
$city mysql_real_escape_string($city);
    
$state mysql_real_escape_string($state);
    
$zip mysql_real_escape_string($zip);
    
$cat mysql_real_escape_string($cat);


    
// Thread_FirstPost DataManager to add thread
        
$threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
        
$threadinfo = array();

    
// unsure about these two
        
$threaddm->set_info('forum'$foruminfo);
        
$threaddm->set_info('thread'$threadinfo);
        
        
// set to correct forum to use
        
$forumtouse 57;
        
$threaddm->setr('forumid'$forumtouse);
        
        
// user information - uid and username come from submitted form
        
$threaddm->setr('userid'$uid);

        
$threaddm->setr('username'$uname);
       
       
$threadtitle "Some title text";
        
$threaddm->setr('title'$threadtitle);
        
       
        
// Set thread contents
        
$pagetext $desc;
        
$threaddm->setr('pagetext'$pagetext);
        
       
        
        
// allow replies
        
$threaddm->set('open'$open);
        
        
// allow smilies
        
$threaddm->set('allowsmilie'$allowsmilie);
        
        
// make visible
        
$threaddm->set('visible'$visible);

    
// pre-save
        
$threaddm->pre_save();


            
$threadid $threaddm->save();
            unset(
$threaddm);
            
build_thread_counters($threaddm);

        
build_forum_counters($foruminfo['forumid']);

There exists more code below this but none of it deals with inserting a new thread.


All times are GMT. The time now is 04:42 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.01154 seconds
  • Memory Usage 1,802KB
  • 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
  • (1)bbcode_code_printable
  • (8)bbcode_php_printable
  • (3)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
  • (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