squishi
05-16-2009, 02:38 PM
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".
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'] != 0 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_logi n'), '', 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_accountdele tion_message', true, true));
//####################
}
$_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
What am I missing? :confused:
The code is run in the hook "private_start".
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'] != 0 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_logi n'), '', 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_accountdele tion_message', true, true));
//####################
}
$_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