vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Code to post new thread (https://vborg.vbsupport.ru/showthread.php?t=213841)

squishi 05-16-2009 02:38 PM

Code to post new thread
 
I've copied the part of newthread php in a plugin, but it is not working.
What am I missing? :confused:
The code is run in the hook "private_start".

PHP Code:

if ($_POST['sent'] == '1') {

//##################
//post a new thread!

//require_once('./global.php');
require_once(DIR '/includes/functions_newpost.php');
//require_once(DIR . '/includes/functions_editor.php');
//require_once(DIR . '/includes/functions_bigthree.php');

    
$checked = array();
    
$newpost = array();
    
$postattach = array();

    
// Variables reused in templates

    
$foruminfo = array();
    
$foruminfo['forumid'] = 78// The new thread should be posted in forum no. 78.

    
$posthash $vbulletin->input->clean_gpc('p''posthash'TYPE_NOHTML);
    
$poststarttime $vbulletin->input->clean_gpc('p''poststarttime'TYPE_UINT);

    
$vbulletin->input->clean_array_gpc('p', array(
        
'wysiwyg'         => TYPE_BOOL,
        
'preview'         => TYPE_STR,
        
'message'         => TYPE_STR,
        
'subject'         => TYPE_STR,
        
'iconid'          => TYPE_UINT,

        
'signature'       => TYPE_BOOL,
        
'disablesmilies'  => TYPE_BOOL,
        
'parseurl'        => TYPE_BOOL,

        
'username'        => TYPE_STR,
        
'loggedinuser'    => TYPE_INT,
    ));

    if (
$vbulletin->GPC['loggedinuser'] != AND $vbulletin->userinfo['userid'] == 0)
    {
        
// User was logged in when writing post but isn't now. If we got this
        // Force them to log back in.
        
standard_error(fetch_error('session_timed_out_login'), ''false'STANDARD_ERROR_LOGIN');
    }

    if (
$vbulletin->GPC['wysiwyg'])
    {
        require_once(
DIR '/includes/functions_wysiwyg.php');
        
$newpost['message'] = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], $foruminfo['allowhtml']);
    }
    else
    {
        
$newpost['message'] =& $vbulletin->GPC['message'];
    }

    
$vbulletin->GPC['postpoll'] = false;

    
$newpost['title'] =& $vbulletin->GPC['subject'];
    
$newpost['iconid'] =& $vbulletin->GPC['iconid'];

    
$newpost['parseurl']        = (($vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_URL) AND $foruminfo['allowbbcode'] AND $vbulletin->GPC['parseurl']);
    
$newpost['signature']       =& $vbulletin->GPC['signature'];
    
$newpost['preview']         =& $vbulletin->GPC['preview'];
    
$newpost['disablesmilies']  =& $vbulletin->GPC['disablesmilies'];
    
$newpost['username']        =& $vbulletin->GPC['username'];
    
$newpost['folderid']        =& $vbulletin->GPC['folderid'];
    
$newpost['humanverify']     =& $vbulletin->GPC['humanverify'];
    
$newpost['poststarttime']   = $poststarttime;
    
$newpost['posthash']        = $posthash;

    
$newpost['emailupdate'] = 0;

    
build_new_post('thread'$foruminfo, array(), array(), $newpost$errors);

    if (
sizeof($errors) > 0)
    {
        
// ### POST HAS ERRORS ###
        
$postpreview construct_errors($errors); // this will take the preview's place
        
construct_checkboxes($newpost);
        
$newpost['message'] = htmlspecialchars_uni($newpost['message']);
    }
    else
    {
        
// ### NOT PREVIEW - ACTUAL POST ###
        
$threadinfo fetch_threadinfo($newpost['threadid']); // need the forumread variable from this
        
mark_thread_read($threadinfo$foruminfo$vbulletin->userinfo['userid'], TIMENOW);

    } 
// end if

$vbulletin->url 'forumdisplay.php?' $vbulletin->session->vars['sessionurl'] . "f=$foruminfo[forumid]";
            eval(
print_standard_redirect('redirect_accountdeletion_message'truetrue));

//####################


$_POST['sent'] is '1'. I set this in a custom form. The new private message is sent, but no thread is created.

I know there's probably a lot of useless code in there. But I would like to first get it to work before I weed out the unnecessary stuff.

I also have a problem with the redirect message. See here: https://vborg.vbsupport.ru/showthread.php?t=213457


All times are GMT. The time now is 07:14 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.01289 seconds
  • Memory Usage 1,754KB
  • 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
  • (1)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