Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2010, 02:51 AM
Kozical Kozical is offline
 
Join Date: Jun 2010
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Create a New Thread as Poll

Hey, I have recently found code for creating a new post but I need to create a thread and hopefully without me having to personally write the sql inserts and queues to manually create a new thread that works as a poll.
I wanted to stop by here and ask the community if there was a way.

I am trying to make an application form to join my community and then once it is submitted have it automatically create a new poll thread that people will vote on. Rather than having to manually go in and create one every time someone applies..

Question again just for clarity:

I need the php code to create a new poll thread. Does anyone know where I can locate this?

Thanks!
Reply With Quote
  #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
  #3  
Old 03-09-2011, 04:24 PM
FortressGamers FortressGamers is offline
 
Join Date: Oct 2010
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm about to give this a go
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:09 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.04353 seconds
  • Memory Usage 2,178KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete