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)

Dismounted 09-22-2007 03:57 AM

You don't need to escape anything going into datamanagers as they do the escaping for you.

toucan42 09-22-2007 11:38 AM

OK removing the escaping does not fix the error though:

Quote:

That username is already in use or does not meet the administrator's standards.
To clarify the purpose here - I have a form where a user can add information which is then used to populate a new thread. I cannot get the datamanager ThreadPost to cooperate. The thread should be attributed to the user who fills out the form on my custom page and the data is all coming acorss just fine but for some reason I get that response.

Opserty 09-22-2007 12:38 PM

What are the values of $uname and $userid just before you set them for the thread datamanager?

(I know you set them as $_GET bla bla but post an example you get when you run the script, it may be that it is not being assigned correctly somewhere else)

toucan42 09-22-2007 12:41 PM

$uid = 1
$uname = 'admintw42'

Both of these values are correct for my user account.

If I set this to another user id & name it still fails with the same error.

If I set this to a username and id that does not exist I get a different error (no users match query) which is just what I would expect.

Quote:

Originally Posted by Delphiprogrammi (Post 1331592)
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


Is that call being handled directly within the line:

PHP Code:

$threaddm->set_info('forum',$newforuminfo); 

or is this something that needs to be done beforehand and if so is the call simply:

PHP Code:

$newforuminfo =  fetchforuminfo(); 

Is there a parameter to pass into fetchforuminfo ?

Sorry for all the questions - vBulletin is complex!

Opserty 09-22-2007 12:56 PM

Hmm I don't know exactly what the problem is. How about hard coding the username and userid in the script and seeing if it works that way. I don't see why the vB code isn't working so its best to start from the beginning and work through to identify the problem.

Also try running this on your script and checking if the username returned matches $uname.
PHP Code:

//$uid = $_GET['uid'] ...
$userinfo fetch_userinfo($uid);
var_dump($userinfo['username'], $uname);
exit(); 


toucan42 09-22-2007 01:08 PM

Using that piece of code I get:

string(9) "admintw42"

I don't have access to $user_userid or $user_username .... The values are being passed from the page before in an AJAX call. Does vB somehow not recognize the script as having permissions to create a thread? Is there something I could do to make vB recognize that I am the logged in user on the page that is running this code?

Actually a closer look at the remainder of the error says:

Quote:

If you are admintw42 and you have forgotten your password, click here.
So it appears maybe this really is the issue? That it doesn't see me as logged in to perform the thread insert?

Opserty 09-22-2007 02:50 PM

Quote:

Originally Posted by toucan42 (Post 1344585)
Is that call being handled directly within the line:

PHP Code:

$threaddm->set_info('forum',$newforuminfo); 

or is this something that needs to be done beforehand and if so is the call simply:

PHP Code:

$newforuminfo =  fetchforuminfo(); 

Is there a parameter to pass into fetchforuminfo ?

You need to fetch_foruminfo($forumid); before $threaddm->set_info('forum', $newforuminfo);

Place
PHP Code:

var_dump($uname);
exit(); 

above
PHP Code:

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

What do you get returned?

I'm sure there is something easy were missing lol :erm:

toucan42 09-23-2007 11:38 AM

Quote:

Originally Posted by Opserty (Post 1344641)
You need to fetch_foruminfo($forumid); before $threaddm->set_info('forum', $newforuminfo);

I added the code:

PHP Code:

$foruminfo fetch_foruminfo($forumtouse); 

Where $forumtouse has the (correct) forum id to post the new thread to.

Adding :
PHP Code:

var_dump($uname);
exit(); 

yielded the expected return value:

string(9) "admintw42"


[QUOTEI'm sure there is something easy were missing lol :erm:[/QUOTE]

I hope so - this is one of those 2% tasks taking 98% of the time.

Is there an equivalent line of code needed before:

PHP Code:

   $threaddm->set_info('thread'$threadinfo); 

If so what call should be made for $threadinfo?

bump. anyone? this error is dogging me.

I think it has something to do with the server script somehow not being "allowed" to post.

Opserty 09-24-2007 02:28 PM

Hmm I'm not to sure, I'll run some test of my own see if I can make it work. I'll let you know of the results, won't be soon though so keep trying to figure it out.

toucan42 09-24-2007 03:50 PM

I am trying to use the vb_DataManager_Thread_FirstPost to insert a new thread on behalf of a user who has filled out a form on a page which calls this script vis AJAX.

The script SHOULD create a new thread in a specified forum and attribute the thread/post to the user who filled in the form. Unfortunately what I am getting in return is the following error:

Quote:

That username is already in use or does not meet the administrator's standards. If you are admintw42 and you have forgotten your password, click here.
In this case I am logged in as admintw42 and filled out the form which then made an AJAX call to my form processor script which should be creating the thread.

Does anyone know what needs to be done to enable the script permissions as the user to create a new thread?

Source below - one thing I am not sure of is the line:

Quote:

$threaddm->set_info('thread', $threadinfo);
This is my first attempt at this sort of thing so be easy on me please :o

PHP Code:

<?php
    
// Returning Update Status via AJAX to user
    //////////////////////////////////////////////
    
    // 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'); /* included to build new thread and update counters */ 
        
        // Retrieve data from form page (passed via querystring)
    
$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'];

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

        
$threadinfo = array();

    
$forumtouse 57;

    
// fetch forum info
    
$foruminfo fetch_foruminfo($forumtouse);
        
$threaddm->set_info('forum'$foruminfo);
        
        
// fetch thread info - not sure about this
        
$threaddm->set_info('thread'$threadinfo);
        
        
// set to correct forum
        
$threaddm->setr('forumid'$forumtouse);
        
        
$userinfo fetch_userinfo($uid);
    
$uname $userinfo['username'];

        
// user information
        
$threaddm->setr('userid'$uid);
       
        
$threaddm->setr('username'$uname);
       
        
$threadtitle "some title";

        
$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']);  
        
?>



All times are GMT. The time now is 12:46 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.02141 seconds
  • Memory Usage 1,803KB
  • 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
  • (12)bbcode_php_printable
  • (7)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