vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Fork Threads (https://vborg.vbsupport.ru/showthread.php?t=94420)

GilbertZ 08-15-2005 10:00 PM

Fork Threads
 
Boring Preamble
Sometimes a thread gets really long or some posts generate interesting but off topic conversation. I wanted to test the new cool product manager system and thought of this very simple mod to add Fork Thread functionality to the end user.

What it does
Allows the end user to divert off-topic tangents into a new thread, while automatically quoting the original thread.

Specs
Plugin: Included

Phrases added automatically: 2
fork_prefix and fork_this_post

Templates added automatically: 1
newpost_fork

Templates to edit: 1
postbit or postbit_legacy

Images to upload: 1 (optional)
fork.gif

How to Install

This is a full blown plugin. Follow the usual instructions for a plugin. Then you have to edit the postbit or postbit_legacy template.

For the graphical version you have to insert these lines where you want the link to appear:
PHP Code:

<a href="newthread.php?fork=1&do=newthread&p=$post[postid]"><img src="$stylevar[imgdir_button]/fork.gif" alt="$vbphrase[fork_this_post]border="0" /></a

For the text version use this code:
PHP Code:

<a href="newthread.php?fork=1&do=newthread&p=$post[postid]">$vbphrase[fork_this_post]</a

You may want to place it in an "if" conditional so that only users who can post New Threads will see the image. Just use the same code as what's embedded in the "quote" image.

Updated to version 1.0.1 on 08/18/2005

*Modified to use the phrase manager.
*Fixed minor bug when "Automatically Quote Post / Thread Title" was set to "no".
*Fixed minor bug where after processing the title I pointed to the wrong variable :)

Preview and Live Demo

Preview attached. Or you can Register and try to fork the posts in the fork me thread.

Graphics help solicited

The quickie image I put together of a fork sucks :)
If someone comes up with an edited image of the .psd file vb comes with I will edit this post.

Wishlist for this mod

1. I doubt I will have the time to put this together, but it would be nice if there was a dropdown with forums the user has permission to post in so that the user can fork the thread to a different forum.
2. Adding a post to the original thread stating it had been forked and a link to the new thread

Final note

Oblivion Knight donated an image you can use of a fork (Thanks). It is attached to this post.

Ghostsuit 08-16-2005 10:04 AM

bloody nice idea.

Azhrialilu 08-16-2005 10:22 AM

What a great idea!

nexialys 08-16-2005 10:33 AM

:) maybe crop your screenshots, big white spaces are not looking good.. ;)

and like said... GREAT idea!

turksengel 08-16-2005 10:38 AM

i couldnt understand what is it doing ?

Azhrialilu 08-16-2005 10:41 AM

One thing that might be useful is if it added a post to the original thread stating it had been forked and a link to the new thread - otherwise on a busy board you could get loads of forks many of which could be under the same thread.

Ghostsuit 08-16-2005 10:58 AM

Quote:

Originally Posted by turksengel
i couldnt understand what is it doing ?

It creates a new thread with a quote fromt he old thread and puts Forked in the title so people can spawn a thread from a post in another thread rather than take the topic of the thread in a different direction with in that thread. Very simple idea and very very handy.

Neutral Singh 08-16-2005 12:27 PM

Brilliant Idea !!

jugo 08-16-2005 01:36 PM

/me installs and bows.

Nicely done!!!

Vizionz 08-16-2005 01:41 PM

this is a pretty good idea it would be better if it let u choose where to put the fork after. and it should be called offtopic instead of fork :P

Chris M 08-16-2005 02:27 PM

Then rename it :p

Satan

Vizionz 08-16-2005 02:38 PM

i did :P

poolking 08-16-2005 03:55 PM

* poolking installs

nice one. :D

The Geek 08-16-2005 04:03 PM

clapclapclap

Well done. A big thumbs up for a wonderfully simple and very effective concept.

Plus I love the fork image. I will be installing this when I get on over to 3.5

jesus likes pie 08-16-2005 04:19 PM

Just wondering, whats the difference between this and splitting? (apart from the fact that it says "Forked:" before the title.

GilbertZ 08-16-2005 04:23 PM

Quote:

Originally Posted by nexialys
:) maybe crop your screenshots, big white spaces are not looking good.. ;)

and like said... GREAT idea!

I will. I'm working on a bunch of code and have many programs and windows open so photoshop won't load :) I used Paint instead and screwed up. When I have some more RAM I'll fix it.

GilbertZ 08-16-2005 04:28 PM

Quote:

Originally Posted by Azhrialilu
One thing that might be useful is if it added a post to the original thread stating it had been forked and a link to the new thread - otherwise on a busy board you could get loads of forks many of which could be under the same thread.

Thanks. I actually meant to add that to the wishlist.

Would it look better to have a full blown post with a link to the fork or just a note in smallfont in the post that was forked? (I think the latter, but the complexity of the mod would become considerably greater).

GilbertZ 08-16-2005 04:32 PM

Quote:

Originally Posted by Vizionz
this is a pretty good idea it would be better if it let u choose where to put the fork after.

That's in the wishlist.

Quote:

Originally Posted by Vizionz
and it should be called offtopic instead of fork :P

Not sure I like "offtopic" but if people have ideas for better wording than I used, please post them. I tried to find your site to see how it looks as "offtopic". Can you post your url? (You can PM if you want it private.)

I'll switch wording to reflect the best received suggestions.

GilbertZ 08-16-2005 04:34 PM

Quote:

Originally Posted by jesus likes pie
Just wondering, whats the difference between this and splitting? (apart from the fact that it says "Forked:" before the title.

This can help you avoid having to split in the first place. This is for your users where splitting is for the admin.

This is similar to the quote feature. It starts a new thread quoting the old post.

jesus likes pie 08-16-2005 04:45 PM

OH......

I thought this was only for the admin. O.K consider this installed on The UberGamers Forums

jesus likes pie 08-16-2005 04:55 PM

Um if we're supposed to get the fork image from the attachment, I dont like the fact that it has a white background. Can you make it transparent?

GilbertZ 08-16-2005 04:59 PM

Quote:

Originally Posted by jesus likes pie
Um if we're supposed to get the fork image from the attachment, I dont like the fact that it has a white background. Can you make it transparent?

I suck at graphics. I'm hoping someone who is good at it will offer something better.

jesus likes pie 08-16-2005 05:01 PM

dont worry i suck at em too :P

Floris 08-16-2005 05:33 PM

Quote:

Originally Posted by nexialys
:) maybe crop your screenshots, big white spaces are not looking good.. ;)

and like said... GREAT idea!

I agree, great idea and nice of you to write it out in a full blown plugin and tnx for sharing!

GilbertZ 08-16-2005 05:41 PM

Thanks for the nice comments everybody!

Oblivion Knight 08-16-2005 06:09 PM

Quote:

Originally Posted by jesus likes pie
Um if we're supposed to get the fork image from the attachment, I dont like the fact that it has a white background. Can you make it transparent?

How about this as an alternative?

GilbertZ 08-16-2005 06:30 PM

Just a quick question to any vb dev.

There are two new variables called in the plugin. I didn't really see the point of initializing them with a $var=""; statement considering the vars are not used in any database calls, plus they are essentially initialized with a value when they are used. If those fields are attempted to be passed into the page, since they aren't globalized, they should be nullified anyway.

However, I know you are doing funky things with plugins, serializing them etc, so I wanted to know what are your best practices for new vars in a plugin?

Chris_D 08-16-2005 06:46 PM

Fork off! ;)

Oblivion Knight 08-16-2005 09:13 PM

This doesn't seem to be functioning correctly if the option "Automatically Quote Post / Thread Title" is set to No.

Every time I click on the fork icon, the new thread title is "Forked Thread: " with the same added inside the URL tags. Shouldn't it be grabbing the thread title if no post title is defined?

GilbertZ 08-16-2005 09:21 PM

I wasn't sure the best way to handle that as the setting is set to "yes" for me.

Are you saying you want the post part of it to quote the title and leave the subject blank?

Oblivion Knight 08-16-2005 09:25 PM

Quote:

Originally Posted by GilbertZ
I wasn't sure the best way to handle that as the setting is set to "yes" for me.

Are you saying you want the post part of it to quote the title and leave the subject blank?

No, I have no problem with the way that the plugin functions.. :)

However, if the option is set to "No" - it should be grabbing the thread's title and inserting that instead of having nothing. Otherwise you could end up with several threads with "Forked Thread: " as the title - which makes no sense really.

GilbertZ 08-16-2005 09:43 PM

Quote:

Originally Posted by Oblivion Knight
No, I have no problem with the way that the plugin functions.. :)

However, if the option is set to "No" - it should be grabbing the thread's title and inserting that instead of having nothing. Otherwise you could end up with several threads with "Forked Thread: " as the title - which makes no sense really.

I was misunderstanding you. Now I think I see what you mean. You're saying that the "No" setting should not apply here since it is a forked thread, rather than a quoted post. Correct?

To fix it change

PHP Code:

if ($vbulletin->options['quotetitle'])
{
    if (
$parentposttitle != '')
    {
        
$posttitle $parentposttitle;
    }
    else
    {
        
$posttitle $threadinfo['title'];
    }
    
$posttitle unhtmlspecialchars($posttitle);
    
$posttitle preg_replace('#^(' preg_quote($vbphrase['reply_prefix'], '#') . '\s*)+#i'''$posttitle);
    
$newpost['title']="Fork of: $postinfo[title]";
}
else
{
    
$newpost['title']="Forked Thread: ";


to

PHP Code:

if ($parentposttitle != '')
{
    
$posttitle $parentposttitle;
}
else
{
    
$posttitle $threadinfo['title'];
}
$posttitle unhtmlspecialchars($posttitle);
$posttitle preg_replace('#^(' preg_quote($vbphrase['reply_prefix'], '#') . '\s*)+#i'''$posttitle);
$newpost['title']="Fork of: $postinfo[title]"

If that's what you meant I'll fix the original file.

Thanks for the feedback.

Oblivion Knight 08-17-2005 08:13 AM

I changed this part of code:
Code:

$newpost['title']="Fork of: $postinfo[title]";
To this:
Code:

$newpost['title'] = "Fork of: $posttitle";
Now it's working how I wanted.. Thanks :)

Erwin 08-17-2005 11:29 PM

Best forum idea for a long time! :) Won't be surprised if it gets incorporated as standard in future. :)

TTG 08-18-2005 12:48 AM

Quote:

Originally Posted by Erwin
Best forum idea for a long time! :) Won't be surprised if it gets incorporated as standard in future. :)

Agree with that .. excellent idea.
Clicked install.

Might be a good idea to zip the download.

GilbertZ 08-18-2005 05:17 AM

Quote:

Originally Posted by TTG
Agree with that .. excellent idea.
Clicked install.

Thanks.

Quote:

Might be a good idea to zip the download.
Really?
I don't know the protocol here, but the xml file is only 2.5k. And all images are precompressed and anyway mostly for preview. Would people really find it helpful to have a zip?

Quote:

Originally Posted by Erwin
Best forum idea for a long time! :) Won't be surprised if it gets incorporated as standard in future. :)

Thanks Doc. I've installed some of your awesome hacks, so I appreciate the compliment coming from you :)

Quote:

Originally Posted by Oblivion Knight
I changed this part of code:
Code:

$newpost['title']="Fork of: $postinfo[title]";
To this:
Code:

$newpost['title'] = "Fork of: $posttitle";
Now it's working how I wanted.. Thanks :)

Good catch :)
Now updated :)


NOTE TO ALL:
If you've installed this already and want to update, just uninstall and reinstall. Even the template you edited will probably not need to be touched.

If the current version is working for you I don't think you need to bother upgrading. It's not a major upgrade. The changes pretty much relate to phrases and if you had the "Quote Title on Reply" set to no.

amykhar 08-23-2005 01:50 PM

I LOVE this mod. A couple of feature suggestions/requests though.

1. Allow forked threads to be posted in a different forum than the one the original thread is in - based on forum permissions of course.
2. Add an admin/mod feature that would allow mods to fork and split a thread at the same time. In other words, I would fork a thread based on post x. Post x would be quoted and carried to the new thread. BUT, I could also select post y,z and q to be split from the original thread and added to the new one.

This is different from a regular split in that post x would stay in the original thread, just as in a regular thread forking.

Amy

KW802 08-23-2005 01:58 PM

Quote:

Originally Posted by Erwin
Best forum idea for a long time! :)

Agreed -- I wonder if it's too late to bug the Jelsoft guys about this for vB 3.5...... :D

This has joined "auto-merge doubleposts" on my lists of features that should be stock.

GilbertZ 08-23-2005 06:50 PM

Quote:

Originally Posted by amykhar
I LOVE this mod. A couple of feature suggestions/requests though.

1. Allow forked threads to be posted in a different forum than the one the original thread is in - based on forum permissions of course.
2. Add an admin/mod feature that would allow mods to fork and split a thread at the same time. In other words, I would fork a thread based on post x. Post x would be quoted and carried to the new thread. BUT, I could also select post y,z and q to be split from the original thread and added to the new one.

This is different from a regular split in that post x would stay in the original thread, just as in a regular thread forking.

Amy

Thanks Amy. Part 1 is in the wishlist. I know I won't have time for awhile to add it.

I've coded a feature like that for another (private) mod I've done in the 3.0 series, but I haven't seen enough code from 3.50 to be sure how to get the permissions right on that one.

It's probably only a couple of lines, but I need the sql code to popup up a list of forums the current user is allowed to post in. It took awhile to figure out how to do that correctly in 3.0. It also needs the displayorder of the forums. And no parent forums can be in the list unless they are open to new posts. So this is not the same code used in forumjump.

If someone feels like coming up with that sql code, I can probably do the rest pretty quickly.

Suggestion 2 is a great one. I've never modded the split code at all, so not sure what that would entail. Definitely don't have time to work on that one. But I'll add it to the wishlist when I get a chance.

amykhar 08-23-2005 07:28 PM

You may not need to query the forums at all. It might be available in the cache. I used a simple bit of code:

Code:

$forumchoice = array();

foreach (array_keys($vbulletin->forumcache) AS $forumid)
{
                $forumid = intval($forumid);
                $forumperms =& $vbulletin->userinfo['forumpermissions']["$forumid"];

                if (isset($vbulletin->forumcache["$forumid"]) AND ($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) AND ($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND verify_forum_password($forumid, $vbulletin->forumcache["$forumid"]['password'], false))
                {
                        $forumchoice[] = $forumid;
                }
}

to get me all of the forums that a user was allowed to view. You could probably use very similar code to get the ones that they can post in.


All times are GMT. The time now is 12:29 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.01464 seconds
  • Memory Usage 1,858KB
  • 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
  • (5)bbcode_code_printable
  • (4)bbcode_php_printable
  • (18)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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