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

Reply
 
Thread Tools Display Modes
  #1  
Old 10-05-2009, 09:01 PM
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Posts: 4,141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Automatic thread creation help (again)

Ok, going back to one of my mods I'm still working on , it creates the thread perfectly fine, but what I want to do, is create a setting in the vBulletin Options, to where the admin would enter a userid, and it would create the thread under that user.

The code I'm currently using is:

PHP Code:
// START CREATING THE THREAD
// Check to see if create new thread is enabled
if ($vbulletin->options['usml_staffapp_createthread'] == 1)
{
        
// Make a new thread
                
require_once(DIR '/includes/functions_newpost.php');

        
$forumid intval($vbulletin->options['usml_staffapp_forumid']);
        
$user_id $vbulletin->options['usml_staffapp_userthread'];
        
$username $vbulletin->userinfo['username'];

        
$target_foruminfo fetch_foruminfo($forumid);
        
$newpost = array(
            
'userid' => $user_id,
            
'username' => $username,
            
'message' =>  $message2,
            
'title' => 'Staff Application: ' $vbulletin->GPC['username'],
            
'poststarttime' => time(),
            
'emailupdate' => 0
        
);
        
build_new_post('thread'$target_foruminfo, array(), array(), $newpost$errors);

// Check to see if create a poll is enabled
        //Poll Options
            
$pollpublic = ($vbulletin->options['usml_staffapp_pollpublic']);
            
$polloption[1] = ($vbulletin->options['usml_staffapp_polloption1']);
            
$polloption[2] = ($vbulletin->options['usml_staffapp_polloption2']);
        
// Check to see poll option 3 is turned on
        
if ($vbulletin->options['usml_staffapp_polloption3on'] == 1)
        {
            
$polloption[3] = ($vbulletin->options['usml_staffapp_polloption3']);
        }
        
// Check to see poll option 4 is turned on
        
if ($vbulletin->options['usml_staffapp_polloption4on'] == 1)
        {
            
$polloption[4] = ($vbulletin->options['usml_staffapp_polloption4']);
        }

if (
$vbulletin->options['usml_staffapp_addpoll'] == 1)
{
        
// Make a poll
                
require_once(DIR '/includes/functions_newpost.php');
                
$threadinfo verify_id('thread'$newpost[threadid], 01);
                
$polloptions count($polloption);
                
$question $posttitle;
                
$vbulletin->GPC['options'] = $polloption;

                
$counter 0;
                
$optioncount 0;
                
$badoption '';
                while (
$counter++ < $polloptions)
                { 
// 0..Pollnum-1 we want, as arrays start with 0
                    
if ($vbulletin->options['maxpolllength'] AND vbstrlen($vbulletin->GPC['options']["$counter"]) > $vbulletin->options['maxpolllength'])
                    {
                        
$badoption .= iif($badoption', ') . $counter;
                    }
                    if (!empty(
$vbulletin->GPC['options']["$counter"]))
                    {
                        
$optioncount++;
                    }
                }

                
// Add the poll
                
$poll =& datamanager_init('Poll'$vbulletinERRTYPE_STANDARD);

                
$counter 0;
                while (
$counter++ < $polloptions)
                {
                    if (
$vbulletin->GPC['options']["$counter"] != '')
                    {
                        
$poll->set_option($vbulletin->GPC['options']["$counter"]);
                    }
                }

                
$poll->set('question',    $question);
                
$poll->set('dateline',    TIMENOW);
                
$poll->set('active',    '1');
                
$poll->set('public',    $pollpublic);

                
$pollid $poll->save();
                
//end create new poll

                // update thread
                
$threadman =& datamanager_init('Thread'$vbulletinERRTYPE_STANDARD'threadpost');
                
$threadman->set_existing($threadinfo);
                
$threadman->set('pollid'$pollid);
                
$threadman->save();
            }

        
// Check if any errors during post
        
if (sizeof($errors) > 0)
        {
        
// Post of new thread failed !
        
$error_info construct_errors($errors);
        
//echo $error_info;
        // do anything you want here - likely to redirect !
        // ...
        
}

        
// Fix forums counters
        
build_forum_counters($forumid);
}
// END CREATING THE THREAD 
And I keep looking at it, and keep getting confused as to what to change to what haha. So, some guidance would be appreciated
Reply With Quote
  #2  
Old 12-29-2009, 02:00 PM
norma-aguilera norma-aguilera is offline
 
Join Date: Jul 2006
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you ever figure it out? I need a script that will automaticaly create a post with a certain message/title.
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 11:16 AM.


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.10343 seconds
  • Memory Usage 2,219KB
  • 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
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)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