The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
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! |
#2
|
|||
|
|||
![]()
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(); ?> |
#3
|
|||
|
|||
![]()
I'm about to give this a go
![]() |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|