PDA

View Full Version : Auto-Create Discussion Thread (when posting new thread)


Tekton
01-26-2005, 10:00 PM
___________
If you installed before 01/28/05, you should search through the added code to newthread.php and replace $vboptions[homeurl] with $vboptions[bburl]. There is one occurrence of this.
???????????

Discussion Threads Requested Here (https://vborg.vbsupport.ru/showthread.php?t=73567)

Estimated Time: ~5 minutes [Any questions? This thread only please :)]

What is it: Adds a button in the new thread creation that will auto-create a discussion thread. Useful for posting in a forum that is locked to normal users and gives them a place to discuss it.

Options: Global ON/OFF, Start Forum, End Forum, Allow Discussion Thread creation by usergroup or user, text to addon to the original thread, text to add before or after Discussion Thread title, and starting text in the new Discussion Thread. (SEE IMAGES)

Images:
newthread.php (http://www.tektek.org/vbhack/discussion_maker/img_newthread.png)
Admin Options (http://www.tektek.org/vbhack/discussion_maker/img_options.png)


Possible Changes: using the vboptions instead of a seperate (kinda sloppy) page to set the values. I dislike vboptions, but anyone can feel free to do this! ;) Also, multiple usergroups and users instead of just a single (not too hard) ANYONE IS FREE TO CHANGE THIS OR MAKE IT BETTER!

// ###### INSTALLATION ######
Currently, I'm storing the data in a row on the adminutil table (it's kinda empty).
You can run the attached file (discussion_maker_install.php) from your admin directory, or just run this vB query for initial setup:
$DB_site->query("INSERT INTO ".TABLE_PREFIX."adminutil('title', 'text') VALUES
('discussion_maker', '0~0~0~999999~[Discuss this Announcement]~1~Discussion~unchecked~Please feel free to discuss! :)')");
OR this SQL query (not tested)
INSERT INTO YOUR_DB.adminutil ('title', 'text')
VALUES
('discussion_maker', '0~0~0~999999~[Discuss this Announcement]~1~Discussion~unchecked~Please feel free to discuss! :)');


// ###### SETUP ######
Place the attached file (discussion_maker.php) into your admin directory.
____________________
OPTIONAL: If you want a link to it from your admin panel; in your admin index.php find:
construct_nav_group($vbphrase['vbulletin_options'], '<hr />');
Add AFTER:
// #### START DISCUSSION MAKER
construct_nav_option('Discussion Maker Options', 'discussion_maker.php?do=view');
construct_nav_group('Discussion Maker');
// #### END DISCUSSION MAKER
????????????????????
In your newthread template, add "$discussion_maker" (without quotes) wherever you want it to show up in the template. (as long as it's inside the <form> tags)
????????????????????
In newthread.php, find:require_once('./includes/functions_bigthree.php');
Add AFTER:// ###### DISCUSSION MAKER CREATE ######
$discuss = $DB_site->query_first("SELECT title, text FROM ".TABLE_PREFIX."adminutil WHERE title = 'discussion_maker'");
$this_forum=$_REQUEST['f']; $dcs_mkr = explode("~", $discuss[text]);
if($dcs_mkr[2]==0){$dcs_chk[0]=$bbuserinfo[usergroupid];}if($dcs_mkr[2]==1){$dcs_chk[0]=$bbuserinfo[userid];}
// for debug --> echo $dcs_chk[0]." ?= ".$dcs_mkr[3]." ~~~ ".$this_forum." ?= ".$dcs_mkr[0];
if($_REQUEST['discuss']=='Submit + Discussion Thread' && $dcs_chk[0]==$dcs_mkr[3] && $this_forum==$dcs_mkr[0]){

$dcs_mkr = explode("~", $discuss[text]);
if($dcs_mkr[2]==0){$dcs_chk[0]=$bbuserinfo[usergroupid];}if($dcs_mkr[2]==1){$dcs_chk[0]=$bbuserinfo[userid];}
if($dcs_chk[0]==$dcs_mkr[3]){
if($dcs_mkr[5]==0){$mkr1=$dcs_mkr[6];}if($dcs_mkr[5]==1){$mkr2=$dcs_mkr[6];}
$new_thread_title=$mkr1." ".$_POST['subject']." ".$mkr2;

// Creating Thread
$DB_site->query("INSERT INTO ".TABLE_PREFIX."thread(
title, lastpost, forumid, open, replycount, postusername, postuserid, lastposter, dateline, iconid, visible) VALUES('
" . addslashes(htmlspecialchars($new_thread_title)) . "', " . TIMENOW . ", $dcs_mkr[1], 1, 0,
'". addslashes($bbuserinfo[username]) ."', $bbuserinfo[userid],'". addslashes($bbuserinfo[username]) ."', " . TIMENOW . ", 0, 1)");
$threadinfo['threadid'] = $DB_site->insert_id();

// Creating Post
$DB_site->query("INSERT INTO ".TABLE_PREFIX."post(
threadid, parentid, title, username, userid, dateline, pagetext, allowsmilie, showsignature, ipaddress, iconid, visible) VALUES
($threadinfo[threadid], 0, '" . addslashes(htmlspecialchars($new_thread_title)) . "', '" . addslashes($bbuserinfo[username]) . "',
$bbuserinfo[userid], " . TIMENOW . ", '" . addslashes($dcs_mkr[8]) . "', 1, 1, 0, 0, 1)");

$post['postid'] = $DB_site->insert_id();
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET firstpostid = $post[postid] WHERE threadid = $threadinfo[threadid]");
require_once('./includes/functions_databuild.php');

build_post_index($post['postid'], $foruminfo, iif($type == 'thread', 1, 0));

// update forum stuff
$DB_site->query("UPDATE " . TABLE_PREFIX . "forum
SET replycount = replycount + 1, threadcount = threadcount + 1,
lastpost = " . TIMENOW . ", lastposter = '" . addslashes($bbuserinfo[username]) . "',
lastthread = '" . addslashes(htmlspecialchars($new_thread_title)) . "',
lastthreadid = $threadinfo[threadid] WHERE forumid = $dcs_mkr[1]");

$newtid = $DB_site->query_first("SELECT dateline, threadid FROM ".TABLE_PREFIX."thread WHERE postuserid = '$bbuserinfo[userid]' ORDER BY dateline DESC");
$_POST['message']=$_POST['message']."\n ".$dcs_mkr[4]." (.$vboptions[bburl]."showthread.php?t=".$newtid[threadid].)";}}
// ###### END DISCUSSION MAKER CREATE ######

// ###### DISCUSSION MAKER SHOW ######
if($dcs_chk[0]==$dcs_mkr[3] && $this_forum==$dcs_mkr[0]){
if($dcs_mkr[7]=="checked"){$discussion_maker="<input type='submit' class='button' name='discuss' value='Submit + Discussion Thread' accesskey='d'/>";}}
// ###### END DISCUSSION MAKER SHOW ######

// =======================

DONE! Make sure you configure the setup in discussion_maker.php. Tell me if there's any problems; it's possible I missed something in the instructions. This hack has been tested and does work~ Use at your own risk! (I'm not responsible, etc etc)

Tekton
01-27-2005, 09:27 AM
If you want to change what the button says, there are two things you need to change in the newthread.php (should probably have been one, but oh well ^^)
Find:if($_REQUEST['discuss']=='Submit + Discussion Thread' && $dcs_chk[0]==$dcs_mkr[3] && $this_forum==$dcs_mkr[0]){
Change to:if($_REQUEST['discuss']=='WHATEVER YOU WANT' && $dcs_chk[0]==$dcs_mkr[3] && $this_forum==$dcs_mkr[0]){
//------
Find:<input type='submit' class='button' name='discuss' value='Submit + Discussion Thread' accesskey='d'/>
Change the value tag to the exact same text as your changed above.


????????????????????
If you don't want to add that large amount of code to your newthread.php, you can add this instead instead:
require_once('./includes/functions_discussion_maker.php');

Then, place the attached file into your includes folder~

nexialys
01-27-2005, 10:03 AM
hum.. this hack is amazing for me... THANKS Tekton for the idea !!

jluerken
01-27-2005, 12:00 PM
Hi Tekton,

pretty cool. Thanks for writing a hack out of my suggestion.

This thing is not clear to me:

If you don't want to add that large amount of code to your newthread.php, you can add this instead instead:


Can you tell us where to place this line and what else you then don't have to add somewhere else? :D

I am looking forward to see your pseudo-UserCP and the HostingCP.
I'll write you a PM about the last thing.

Thanks man!

Tekton
01-27-2005, 03:02 PM
Hi. Basically I mean placing the last bit of code (the really long part) into a seperate php file and then just including it into the newthread.php with the 'require_once' function mentioned above. The code in the functions_discussion_maker.php is the same as listed in that last one (only change is that it's wrapped in php tags - <?php ?)

jluerken
01-28-2005, 04:16 PM
Very great hack. Its working fine. Thanks man :D

jluerken
01-28-2005, 07:15 PM
Hi,

there is a small bug in

$_POST['message']=$_POST['message']."\n ".$dcs_mkr[4]." (.$vboptions[homeurl]."showthread.php?t=".$newtid[threadid].)";}}
// ###### END DISCUSSION MAKER CREATE ######


This construct .$vboptions[homeurl]." makes links like:
http://www.url.comshowthread.php

There is a / missing and also the forum directory.

For example:
My board must have this link: http://www.url.com/forum/showthread.php

I changed this:

$_POST['message']=$_POST['message']."\n ".$dcs_mkr[4]." (.$vboptions[homeurl]."showthread.php?t=".$newtid[threadid].)";}}
// ###### END DISCUSSION MAKER CREATE ######


to:

$_POST['message']=$_POST['message']."\n ".$dcs_mkr[4]." (.$vboptions[homeurl]."/forum/showthread.php?t=".$newtid[threadid].)";}}
// ###### END DISCUSSION MAKER CREATE ######


which is working fine for me.
If another user has installed his board in http://www.url.com/board change
the above /forum/ to /board/

:D

Tekton
01-28-2005, 07:21 PM
Ah, yeah sorry we use the base directory for all of our forums~ ^^;;

Replace $vboptions[homeurl] with $vboptions[bburl]

MoogleCC
07-31-2005, 05:20 PM
Text in this field will be added to the bottom of the original thread in the form of a link that will take the user to the Discussion thread. (cannot use '~')

but this doesn`t work
maybe because of 3.0.7 ????

jluerken
10-09-2005, 09:03 AM
Tekton could you create this also for vB 3.5?