vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Automatic thread creation help (again) (https://vborg.vbsupport.ru/showthread.php?t=224642)

HMBeaty 10-05-2009 09:01 PM

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

norma-aguilera 12-29-2009 02:00 PM

Did you ever figure it out? I need a script that will automaticaly create a post with a certain message/title.


All times are GMT. The time now is 07:32 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.01114 seconds
  • Memory Usage 1,772KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete