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

Reply
 
Thread Tools Display Modes
  #1  
Old 09-19-2011, 07:22 AM
TeknoSounds TeknoSounds is offline
 
Join Date: Nov 2006
Location: TX
Posts: 435
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default External Thread Creation: Registry Object is not an Object error

Greetings, I'm (still) attempting to create a new thread outside VB, but now I'm getting the following errors (echoes 0 & 1 happen previously in the code):
Code:
012
Fatal error: MGCCbEvo_core::Registry object is not an object in [path]/mgc_cb_evo/classes/class_core.php on line 21
As you can see, this is from MGC chatbox. When the chatbox is disabled from the ACP, I then get the following error:
Code:
0123
Fatal error: Registry object is not an object in [path]/includes/class_dm.php on line 205
I can't seem to figure out why its not able to create the registry object for either MGC or the datamanager. Code below.

PHP Code:
    //Create New VB Thread from Event Info
    
public function CreateNewVBThread($date$name$venue$city$state) {
        
//Variables
        
echo 2;
        
$postip "127.0.0.1";
        
$userid 243;
        
$username 'Events Announcer';
        
$title = ($date ' - ' $name ' @ ' $venue ' - ' $city ', ' $state);
        
$threadinfo = array();
        
$forumdir "/myforumdirectory";
        
$specialtemplates = array();
        
$actiontemplates = array();
        
$globaltemplates = array();

        
chdir($forumdir);

        require(
$forumdir '/global.php');
        require(
$forumdir '/includes/functions_databuild.php');

        
//Determine City/Forum
        
if ($state "TX") {
            switch (
$city) {
                case 
"Austin":
                    
$forumid 70;
                    break;
                case 
"Dallas":
                    
$forumid 77;
                    break;
                case 
"Houston":
                    
$forumid 78;
                    break;
                case 
"San Antonio":
                    
$forumid 79;
                    break;
                default:
                    
$forumid 80;
                    break;
            }
        }
        else {
            
$forumid 81;
        }
        echo 
3;
        
//Create new thread given info below
        
$threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');

        
$foruminfo fetch_foruminfo($forumid);
        
$threaddm->set_info('forum'$foruminfo);
        
$threaddm->set_info('thread'$threadinfo);
        
$threaddm->setr('forumid'$forumid);
        
$threaddm->setr('userid'$userid);
        
$threaddm->setr('title'$title);
        
$threaddm->set('username'$username);
        
$threaddm->set('pagetext''This is a test');
        
$threaddm->set('allowsmilie'1);
        
$threaddm->set('visible'1);
        
$threaddm->set('ipaddress'$postip);
        
$threaddm->set('dateline'TIMENOW);
                
        
$threaddm->pre_save();
        if(
count($threaddm->errors) < 1)
        {
            
$threadid $threaddm->save();
            unset(
$threaddm);
            
build_thread_counters($threadid);
        }
        else 
        {
            print 
"Error making new thread! " $threaddm->errors[0] . $threaddm->errors[1] . $threaddm->errors[2] ;
        }
        
        
build_forum_counters($forumid);

    }  
//end CreateNewVBThread() */ 
The file does live in a folder outside of vb currently, though plans are to remove this section and place it in its own file in the vb folder later.
Reply With Quote
  #2  
Old 09-19-2011, 06:43 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

On this line:

PHP Code:
        $threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost'); 

you're passing $vbulletin to the datamanager_init() function but $vbulletin is not defined. If you want to pass the global $vbulletin object you need a "global $vbulletin;" statement before that call.
Reply With Quote
  #3  
Old 09-20-2011, 03:30 AM
TeknoSounds TeknoSounds is offline
 
Join Date: Nov 2006
Location: TX
Posts: 435
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay did that and the errors are gone, but now its not doing anything again it seems *sigh* back to testing
Reply With Quote
  #4  
Old 09-20-2011, 06:21 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You mean no errors but it's not creating a thread? I tried it and it's working for me. To test it I took out the word "public" and changed a few other things for my forum, but I think the important parts are the same.
Reply With Quote
  #5  
Old 09-20-2011, 07:21 AM
TeknoSounds TeknoSounds is offline
 
Join Date: Nov 2006
Location: TX
Posts: 435
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

argh!!! really?? Well dangit... Tho that is really good to know the code works as a standalone. Now just to get it to work when its supposed to be called.

Thanks so much for the help kh99
But I might be back hehe.
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 08:00 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.04997 seconds
  • Memory Usage 2,229KB
  • 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
  • (2)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete