Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 09-22-2007, 04:57 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't need to escape anything going into datamanagers as they do the escaping for you.
Reply With Quote
  #12  
Old 09-22-2007, 12:38 PM
toucan42 toucan42 is offline
 
Join Date: Sep 2006
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #13  
Old 09-22-2007, 01:38 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)
Reply With Quote
  #14  
Old 09-22-2007, 01:41 PM
toucan42 toucan42 is offline
 
Join Date: Sep 2006
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$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 View Post
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!
Reply With Quote
  #15  
Old 09-22-2007, 01:56 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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(); 
Reply With Quote
  #16  
Old 09-22-2007, 02:08 PM
toucan42 toucan42 is offline
 
Join Date: Sep 2006
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #17  
Old 09-22-2007, 03:50 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by toucan42 View Post
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:
Reply With Quote
  #18  
Old 09-23-2007, 12:38 PM
toucan42 toucan42 is offline
 
Join Date: Sep 2006
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
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.
Reply With Quote
  #19  
Old 09-24-2007, 03:28 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #20  
Old 09-24-2007, 04:50 PM
toucan42 toucan42 is offline
 
Join Date: Sep 2006
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

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']);  
        
?>
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 10:57 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.12656 seconds
  • Memory Usage 2,320KB
  • Queries Executed 11 (?)
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
  • (12)bbcode_php
  • (7)bbcode_quote
  • (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
  • (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_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