vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Create Posts (https://vborg.vbsupport.ru/showthread.php?t=102418)

ks_work 11-22-2006 02:24 PM

i'm with 3.6.3 now.
How do I update existing post ?

thanks

amcd 11-23-2006 03:52 AM

Quote:

Originally Posted by ks_work (Post 1122972)
i'm with 3.6.3 now.
How do I update existing post ?

thanks

this is how we do it on 3.6.1 . i think the same is valid for 3.6.3 as well
Code:

$vbulletin->db->query_write("UPDATE post SET pagetext = '$message' WHERE postid=$postid");
$vbulletin->db->query_write("DELETE FROM postparsed WHERE postid=$postid");


ks_work 11-23-2006 12:37 PM

thanks a lot !
I'll try it.
Meanwhile this code did the job for me (i apologize for it's messiness):
PHP Code:

<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
//define('GET_EDIT_TEMPLATES', true);

    
define('SKIP_SESSIONCREATE'1);
    
define('DIE_QUIETLY'1);    
define('THIS_SCRIPT''editpost');

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(
DIR '/includes/functions_newpost.php');
require_once(
DIR '/includes/functions_bigthree.php');
require_once(
DIR '/includes/functions_editor.php');
require_once(
DIR '/includes/functions_log_error.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

// ### STANDARD INITIALIZATIONS ###
$checked = array();
$edit = array();
$postattach = array();



############################ start  input from tt_news

$k_postid=$_REQUEST["k_postid"];
$k_threadid=$_REQUEST['k_threadid'];
$k_title=$_REQUEST['k_title'];
$k_pagetext=$_REQUEST['k_pagetext'];
$k_hidden_visible=$_REQUEST['k_hidden_visible'];

############################  end input from tt_news



$threadinfo['forumid']=55;
$threadinfo['threadid']=$k_threadid;
$threadinfo['firstpostid']= $k_postid;

$foruminfo fetch_foruminfo($threadinfo['forumid'], false);
//print"<P>forum: <pre>".print_r($foruminfo,1);print"<P>thread :<pre>".print_r($threadinfo,1);
    
$postinfo['postid'] = $k_postid;
    
$postinfo['threadid'] =$threadinfo['threadid'];
    
$postinfo['parentid'] = $k_postid;
    
$postinfo['username'] = 'administrator';
    
$postinfo['userid'] = 1;
    
$postinfo['title'] = $k_title;
    
$postinfo['dateline'] = '';
    
$postinfo['pagetext'] =$k_pagetext;
    
$postinfo['allowsmilie'] = 1;
    
$postinfo['showsignature'] = 0;
    
$postinfo['ipaddress'] = '206.223.168.166';
    
$postinfo['iconid'] = 0;

        if( isset(
$_REQUEST["k_hidden_visible"]))//
        
{
                if(
$_REQUEST["k_hidden_visible"]==0)// hidden
                
{
                
$visible_val=0;
                }
                else 
//
                
{
                
$visible_val=1;
                }        
        }
        else 
//
        
{
            
$visible_val=0;
        
        }

    
$postinfo['visible'] = $visible_val;
    
$postinfo['attach'] = 0;
    
$postinfo['infraction'] = 0;
    
$postinfo['reportthreadid'] = 0;
    
$postinfo['isdeleted'] = 0;
    
$postinfo['edit_userid'] = '';
    
$postinfo['edit_dateline'] = '';
    
$postinfo['edit_reason'] ='' ;


    
$threadinfo['visible']=$visible_val;
///print"<P>post <pre>".print_r($postinfo,1);
$aaa=1;

// need to get last post-type information
cache_ordered_forums(1);

// ############################### start update post ###############################
if ($aaa ==1)
{
    
// Variables reused in templates
    
$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(
        
'stickunstick'   => TYPE_BOOL,
        
'openclose'      => TYPE_BOOL,
        
'wysiwyg'        => TYPE_BOOL,
        
'message'        => TYPE_STR,
        
'title'          => TYPE_STR,
        
'iconid'         => TYPE_UINT,
        
'parseurl'       => TYPE_BOOL,
        
'signature'         => TYPE_BOOL,
        
'disablesmilies' => TYPE_BOOL,
        
'reason'         => TYPE_NOHTML,
        
'preview'        => TYPE_STR,
        
'folderid'       => TYPE_UINT,
        
'emailupdate'    => TYPE_UINT,
        
'ajax'           => TYPE_BOOL,
        
'advanced'       => TYPE_BOOL,
        
'postcount'      => TYPE_UINT,
        
'podcasturl'     => TYPE_STR,
        
'podcastsize'    => TYPE_UINT,
        
'podcastexplicit' => TYPE_BOOL,
        
'podcastkeywords' => TYPE_STR,
        
'podcastsubtitle' => TYPE_STR,
        
'podcastauthor'   => TYPE_STR,
    ));
    
    
// ### PREP INPUT ###
    
        
$edit['message'] =$k_pagetext;
        
$edit['iconid'] =& $vbulletin->GPC['iconid'];
        
$edit['title'] =$k_title;
        
$edit['podcasturl'] =& $vbulletin->GPC['podcasturl'];
        
$edit['podcastsize'] =& $vbulletin->GPC['podcastsize'];
        
$edit['podcastexplicit'] =& $vbulletin->GPC['podcastexplicit'];
        
$edit['podcastkeywords'] =& $vbulletin->GPC['podcastkeywords'];
        
$edit['podcastsubtitle'] =& $vbulletin->GPC['podcastsubtitle'];
        
$edit['podcastauthor'] =& $vbulletin->GPC['podcastauthor'];        
        
$edit['signature'] =& $vbulletin->GPC['signature'];
        
$edit['disablesmilies'] =& $vbulletin->GPC['disablesmilies'];
        
$edit['enablesmilies'] = $edit['allowsmilie'] = ($edit['disablesmilies']) ? 1;
        
$edit['stickunstick'] =& $vbulletin->GPC['stickunstick'];
        
$edit['openclose'] =& $vbulletin->GPC['openclose'];
        
$edit['visible'] = $visible_val;

        
$edit['reason'] = fetch_censored_text($vbulletin->GPC['reason']);
        
$edit['preview'] =& $vbulletin->GPC['preview'];
        
$edit['folderid'] =& $vbulletin->GPC['folderid'];    

    
$dataman =& datamanager_init('Post'$vbulletinERRTYPE_ARRAY'threadpost');
    
$dataman->set_existing($postinfo);
//print"<P>edit:<pre>".print_r($edit,1);
    // set info
    
$dataman->set_info('parseurl', ($foruminfo['allowbbcode'] AND $edit['parseurl']));
    
$dataman->set_info('posthash'$posthash);
    
$dataman->set_info('forum'$foruminfo);
    
$dataman->set_info('visible'$visible_val);
    
$dataman->set_info('thread'$threadinfo);
    
$dataman->set_info('show_title_error'true);
    
$dataman->set_info('podcasturl'$edit['podcasturl']);
    
$dataman->set_info('podcastsize'$edit['podcastsize']);
    
$dataman->set_info('podcastexplicit'$edit['podcastexplicit']);
    
$dataman->set_info('podcastkeywords'$edit['podcastkeywords']);
    
$dataman->set_info('podcastsubtitle'$edit['podcastsubtitle']);
    
$dataman->set_info('podcastauthor'$edit['podcastauthor']);
    if (
$postinfo['userid'] == $vbulletin->userinfo['userid'])
    {
        
$dataman->set_info('user'$vbulletin->userinfo);
    }
//print"<P>userinfo:<pre>".print_r($vbulletin->userinfo,1);


    // set options
    
$dataman->setr('showsignature'$edit['signature']);
    
$dataman->setr('allowsmilie'$edit['enablesmilies']);

    
// set data
    /*$dataman->setr('userid', $vbulletin->userinfo['userid']);
    if ($vbulletin->userinfo['userid'] == 0)
    {
        $dataman->setr('username', $post['username']);
    }*/
    
$dataman->setr('title'$edit['title']);
    
$dataman->setr('visible'$edit['visible']);
    
$dataman->setr('pagetext'$edit['message']);
    if (
$postinfo['userid'] != $vbulletin->userinfo['userid'])
    {
        
$dataman->setr('iconid'$edit['iconid'], truefalse);
    }
    else
    {
        
$dataman->setr('iconid'$edit['iconid']);
    }
    
    
$dataman->pre_save();
    if (
$dataman->errors)
    {
        
$errors $dataman->errors;
    }
    
    if (
sizeof($errors) > 0)
    {
        
// ### POST HAS ERRORS ###
        
print"<P>ERRORS:<pre>".print_r($errors,1);
            
    }    
    else
    {
        
// ### POST HAS NO ERRORS ###

        
print"<P>No errors so far !";
        print
"<P>edit:<pre>".print_r($edit,1);

        print 
"<P>result is :".$dataman->save();    

        
$date vbdate($vbulletin->options['dateformat'], TIMENOW);
        
$time vbdate($vbulletin->options['timeformat'], TIMENOW);

        
// initialize thread / forum update clauses
        
$forumupdate false;

        
$threadman =& datamanager_init('Thread'$vbulletinERRTYPE_SILENT'threadpost');
        
$threadman->set_existing($threadinfo);

    if (
$edit['title'] != '' )
        {
            
// need to update thread title and iconid            
            
$threadman->set_info('skip_first_post_update'false);
            
$threadman->set('title'unhtmlspecialchars($edit['title']));
            
$threadman->set('visible'$edit['visible']);
            
$threadman->set('iconid'$edit['iconid']);

            
// do we need to update the forum counters?
            
$forumupdate = ($foruminfo['lastthreadid'] == $threadinfo['threadid']) ? true false;
        }
        else{
        print 
"<P> line 237 not update thread";
        }
                
        
$threadman->save();
        
        require_once(
DIR '/includes/functions_databuild.php');

        
// do forum update if necessary
        
if ($forumupdate)
        {
            
build_forum_counters($threadinfo['forumid']);
        }

        
$cansubscribe true;
        
        
//    $vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "p=$postinfo[postid]#post$postinfo[postid]";                
    
}
}
?>


Derschizo 12-03-2006 11:23 PM

That looks interesting can you show me how to implement and make it fully work completely. I'm not sure exactly where you put the code and what each section completely means. I'm assuming it goes to the function_newpost .

amcd 12-04-2006 03:18 AM

That depends on what you want to achieve. In vbulletin 3.5 or higher, editing the original php files is discouraged and its better to add plugins.

jj 12-09-2006 03:10 PM

Hi guys, I'm creating/posting/modifying posts/thread out of some custom software I wrote. Now is there a way of bypassing the post-time limit with the datamanager-method when doing it?

BOLT 12-21-2006 03:38 PM

I dont understand. Where do you enter this code? And how do you make the post, time, thread, etc. be what exactly you want?

liquidx 05-27-2007 03:36 AM

Can someone help here?

I'm trying to create new posts, I've tried both the dataman and build_new_post methods, here's my problems:

Dataman method:
How do I handle errors? When I get an error (like posting anonymously with a user name that is already in use) it directly echos out a full error page! I don't want this, I want just the error message..

build_new_post method:
When posting anonymous, the new posts are moderated, even though the forum allows anonymous posting and is not moderated.. I can't figure out how to stop this from happening.

I've searched all over the forums for both these issues but came up empty, anyone?

quitsmoking 07-04-2007 10:26 PM

And what if I want to add a new thread (not a post in an existing thread)?

fly 07-05-2007 11:49 AM

Then you'd find the thread about HowTo Create Threads. ;)


All times are GMT. The time now is 07:19 PM.

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.01541 seconds
  • Memory Usage 1,884KB
  • 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_code_printable
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete