View Single Post
  #2  
Old 08-15-2010, 10:26 PM
Kozical Kozical is offline
 
Join Date: Jun 2010
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well it seems noone cared to help or just didn't know how so I sought out the information I wanted and I will be nice and show you the class I wrote specifically for my forums. So you may want to modify it to suite your needs. However, I am trying to be nice by adding this here so please do not flame my coding style..

Code:
<?php
require_once('global.php');
require_once('includes/class_dm.php');
require_once('includes/class_dm_poll.php');
require_once('includes/class_dm_threadpost.php');
require_once('includes/functions_databuild.php');

define(FORUM_ID,		29); //-> Forum Id of poster's forum
define(USER_ID,			1);  //-> User Id of poster

$instance = $vbulletin; //-> Fix for FATAL ERROR: Registry not found

class ThreadPoll
{
	var $threadId,
		$pollId,
		$forumId;
	
	function ThreadPoll()
	{
		$forumId = FORUM_ID;
	}
	function InitPoll($question)
	{
		global $instance;
		$poll =& datamanager_init('Poll', $instance, ERRTYPE_STANDARD);
		
		$poll->setr('question', $question);
		$poll->set_option("YES");
		$poll->set_option("NO");
		$poll->set_vote(0);
		$poll->pre_save();
		if (!empty($poll->errors))
		{
			echo ($poll->errors);
			exit;
		}
		$this->pollId = $poll->save();
		unset($poll);
	}
	function InitThread($title, $pagetext)
	{
		global $instance;
		$thread =& datamanager_init('Thread_FirstPost', $instance, ERRTYPE_ARRAY, 'threadpost');
		$forumInfo = fetch_foruminfo($forumId);
		
		$thread->set('forumid',		FORUM_ID);
		$thread->setr('title',		$title);
		$thread->setr('pagetext',	$pagetext);
		$thread->setr('pollid',		$this->pollId);
		$thread->set('userid',		USER_ID);
		$thread->set('open',		1);
		$thread->set('visible',		1);
		$thread->set('allowsmilie',	1);
		
		$thread->set_info('forum', $forumInfo);
		$thread->set_info('thread', array());
		$thread->pre_save();
		
		if (!empty($thread->errors))
		{
			print_r($thread->errors);
			exit;
		}
		$threadId = $thread->save();
		unset($thread);
	}	
	function BuildThread()
	{
		build_thread_counters($threadId);
		build_forum_counters(FORUM_ID);
	}
}

$obj = new ThreadPoll;

$obj->InitPoll("Poll Question");
$obj->InitThread("Title of the thread", "Text to be display in first post.. use \n for new line");
$obj->BuildThread();

?>
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01275 seconds
  • Memory Usage 1,770KB
  • 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_code
  • (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