View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01155 seconds
  • Memory Usage 1,860KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete