View Full Version : Close Thread with Reply
JJR512
01-01-2002, 10:00 PM
This very simple hack will show a checkbox in the options area (with show signature, email notification, etc.) of the Reply
to Topic screen that allows you to close the thread at the same time as posting your reply to the thread. The checkbox will
only show to those that have permission to close the thread.
Tested by me on 2.2.1. Compatibility with earlier versions is likely but not proven.
This hack was requested by Freestyler here (https://vborg.vbsupport.ru/showthread.php?s=&threadid=33702).
EDIT: This hack has been updated; the attachment is now in Post #9.
RapCheck
01-02-2002, 06:19 AM
Great. Installing right now.
Freestyler
01-02-2002, 06:31 AM
Thankyou JJR512!
I'll get our 'vB guy' (Apollo) to install it as soon as he's got time, and we'll let you know how it goes!
Lesane
01-02-2002, 07:00 AM
Great little hack, thanks
-.valkyre
01-02-2002, 07:15 AM
Very useful indeed. I'm adding this hack when I transfer my forums to my new site. Thanks for a simple, yet every effective hack! :)
Martz
01-02-2002, 08:06 AM
A well overdue hack, good work fella :)
Mystics
01-02-2002, 02:09 PM
Thx!! Works great :)
Greetz,
Mystics
Admin
01-02-2002, 02:24 PM
Installed here, nice hack. :)
One thing though, to make sure users can't manipulate forms and close a thread, you should replace:
if ($closethread=="yes") {
$DB_site->query("UPDATE thread SET open='0' WHERE threadid='$threadid'");
}
with:
if ($closethread=="yes" and $permissions['canopenclose']==1) {
$DB_site->query("UPDATE thread SET open='0' WHERE threadid='$threadid'");
}
JJR512
01-02-2002, 04:09 PM
Good idea, FireFly! :) I've added that into the instructions.
The new instructions are attached to this post.
EDIT: This hack has been updated, and the instructions are now attached to Post #14 below.
Admin
01-02-2002, 04:25 PM
Security is always a good idea. :)
Good job, JJR! This will come in handy. :)
Tommy Boy
01-02-2002, 07:08 PM
Wouldn't it be better to add "newpost_closethread" to the $templatesused variable at the top of newreply.php, to save one SQL query on every reply page?
Also, to preserve the checkbox's state when previewing post, I would put this in newreply.php: if ($permissions['canopenclose']==1) {
$closethreadchecked = ($closethread) ? " checked" : "";
eval("\$closethreadbox = \"".gettemplate("newpost_closethread")."\";");
} else {
$closethreadbox="";
}And this as the newpost_closethread template:<br><input type="checkbox" name="closethread" value="yes"$closethreadchecked> <b>Close Thread After Reply</b>
JJR512
01-02-2002, 07:42 PM
How does putting the template name in the $templateused variable save a query?
JJR512
01-02-2002, 08:01 PM
I have updated the instructions so that the check box maintains its status during a reply preview, although I used a slightly different way (I used the iif function).
EDIT: Another update :rolleyes: attached in the next reply.
JJR512
01-02-2002, 08:31 PM
Sorry...
There was a potential problem I was unaware of, until I started testing with the preview function. Due to where in newreply.php I specified to place the code that actually closed the thread, the thread would have been closed immediately upon hitting the Preview button. Now I think that anyone that could use the checkbox and actually close the thread could probably also post a reply to a closed thread, so that wouldn't have been a problem...but if, after hitting Preview, the user just abandoned the reply (clicked the navigation link back into the forum or the home page or whatever, without submitting the reply), the thread would still be closed. Therefore, I have adjusted the instructions so the thread isn't closed until the reply is actually submitted.
If you have already installed this hack, you should undo the first step of modifying newreply.php (just find what it tells you to add, and remove it). Then download the new instructions and do what it says in the same step.
Tommy Boy
01-02-2002, 09:00 PM
Originally posted by JJR512
How does putting the template name in the $templateused variable save a query? All the templates mentioned in this variable are loaded first, using one SQL query for all of them together. If you then request a template which was not mentioned there, an additional SQL query is made to retrieve it.
Thanks for fixing your hack! I think I accidently closed a thread while I was playing with it, but now I can't find it... :( Oh well, let my users think I'm a bad administrator. ;)
JJR512
01-02-2002, 09:06 PM
OK, thanks for explaining that...I didn't really know what the point of that variable was. Now I have some hacks to go fix...:( :D
(I've updated the previously-posted instructions to reflect an appropriate change.)
Lucky
01-03-2002, 11:30 AM
Man is this a time saver! Thanks:)
It would be even better if you could add sticky, move, etc...
Just a thought.
Mystics
01-03-2002, 11:37 AM
@JJR512
Thx for the Hack, but in your last updated instructions is a new (small) bug :rolleyes:
@Point 3. you wrote:Go to the end of that line, which by default should look like this:
newpost_closethread";
Before the double quotes, add this:
,newpost_closethreadIt better should look like this:Go to the end of that line, which by default should look like this:
vbcode_colorbits";
Before the double quotes, add this:
,newpost_closethreadGreetz :p,
Mystics
JJR512
01-03-2002, 04:17 PM
OK, thanks...I've updated the instructions.
Great hack, JJR. I installed the new, updated version at The Smallville Torch (www.simpsonsboard.com/ted) and it works like a charm.
I also installed the previously updated version at my board at Simpsons board (www.simpsonsboard.com). What are the differences? I seem to have no problems with the hack at SB as is. But, if I need to reinstall, please let me know.
JJR512
01-03-2002, 07:33 PM
Without knowing which exact version you have, I couldn't really tell you what the difference is...you can find which version you have in the instructions.txt file, there's a version history at the top. That also tells you what the differences are.
Basically, the C and D releases are fine (D is just fixes a poorly-written instruction as pointed out by Mystics). In all the earlier versions, a thread would get closed even if someone who had checked the box just hit the Preview button, and this might not be desirable operation. In the original version, there was also a small security hole that could allow anyone to close any thread if they knew how to manipulate forms data and tried it. Functionally, every version has done the basic idea of what this hack is, but I would use at least version C.
Originally posted by JJR512
Without knowing which exact version you have, I couldn't really tell you what the difference is...you can find which version you have in the instructions.txt file, there's a version history at the top. That also tells you what the differences are.
Basically, the C and D releases are fine (D is just fixes a poorly-written instruction as pointed out by Mystics). In all the earlier versions, a thread would get closed even if someone who had checked the box just hit the Preview button, and this might not be desirable operation. In the original version, there was also a small security hole that could allow anyone to close any thread if they knew how to manipulate forms data and tried it. Functionally, every version has done the basic idea of what this hack is, but I would use at least version C.
I'm using vbulletin version 2.2.1. I'll reinstall the first hack (at simpsonsboard) with the new hack. Thanks for the update and great work! :s On a side note, I still haven't messed with the locationbit, but it's no biggie. *lol* Thanks again
Hooper
01-04-2002, 01:06 AM
JJR,
Any chance you might attatch a fully updated file to your first post. This thread is full of updates and changes. Would be nice to have a completed hack to grab from post one.
Just a thought.
JJR512
01-04-2002, 05:15 AM
The current release is in Post #15; this is the link to the attachment: https://vborg.vbsupport.ru/attachment.php?s=&postid=210636
What I don't like about having the attachment stay in the first post is that for some other hacks, especially popular ones that spawn multi-page threads, as I read through the thread and see various problems and issues brought up, discussed, solved, etc., I'm left wondering, did the attachment get updated with the fixes? So I thought that instead of doing it that way, I would post a new attachment in any thread where I announce an update, and delete the previous attachment...but each time, make sure to specify where the attachment was. The post numbers are great for this. Also, this method makes it so that someone can't just look at the first post in the thread, read the original description of the hack and just download it without actually going through the thread to read about the various nuances and tricks. Granted, this particular hack is very simple, but another of mine isn't.
Despite Firefly's security update (https://vborg.vbsupport.ru/showthread.php?postid=210550#post210550) normal users can still close a thread although they did not started the thread themselves.
Our board has for all registered users configured 'can open/close own threads' set to 'yes'. With this option set, every user is able to use 'Close Thread with Reply' and thus closing the thread. When the option 'can open/close own threads' is set to 'no', the 'Close Thread with Reply' option disappears.
Even tough the hack check for permissions, it checks for the wrong permission, more specific for the permission 'can open/close own threads'. I couldn't find an option 'can open/close threads other threads' anywhere.
Just to let you know. Alas, I can't use the hack right now :-(
Lucky
01-22-2002, 05:17 AM
Good job DJR,
I never even noticed that.
Joshua Clinard
01-25-2002, 02:35 PM
Please fix this.
Thank you for this usefull little hack. Very easy to install and it works :)
ups, something isn't right. I, as an admin, see the checkbox an can use it. My Mods doesn't see it, but can open/close threads in their forums on the normal way.
What is wrong?
seems depending on Groups Permissions. But i have Stanard-Permissions for our Mods.
Must be one of these settings:
Can Move own threads to other forums
Can open / close own threads
Can delete own threads by deleting the first post
These settings are turned off for my mods.
AlexD.
This is already discussed here (https://vborg.vbsupport.ru/showthread.php?postid=214868#post214868). There's still no solution for the problem though.
- djr
Warlord
01-27-2002, 10:56 PM
Installed, works like a charm.
Ok, i fixed it. Here we go:
In the Hack Instructions find: } else {
if ($closethread=="yes" and $permissions['canopenclose']==1) {
$DB_site->query("UPDATE thread SET open='0' WHERE threadid='$threadid'");
}
if ($attachmentid and !$foruminfo[moderateattach]) {
$DB_site->query("UPDATE thread SET attach = attach + 1 WHERE threadid = '$threadid'");
}and replace it with: } else {
if ($closethread=="yes" and ($bbuserinfo[usergroupid]==5 || $bbuserinfo[usergroupid]==6 || $bbuserinfo[usergroupid]==7)) {
$DB_site->query("UPDATE thread SET open='0' WHERE threadid='$threadid'");
}
if ($attachmentid and !$foruminfo[moderateattach]) {
$DB_site->query("UPDATE thread SET attach = attach + 1 WHERE threadid = '$threadid'");
}
Find: if ($permissions['canopenclose']==1) {
$closethreadchecked=iif(trim($closethread)=="yes","checked","");
eval("\$closethreadbox = \"".gettemplate("newpost_closethread")."\";");
} else {
$closethreadbox="";
}and replace it with: if ($bbuserinfo[usergroupid]==5 || $bbuserinfo[usergroupid]==6 || $bbuserinfo[usergroupid]==7) {
$closethreadchecked=iif(trim($closethread)=="yes","checked","");
eval("\$closethreadbox = \"".gettemplate("newpost_closethread")."\";");
} else {
$closethreadbox="";
}This changes make the checkbox available for mods (usergroupid 7), Super Mods (usergroupid 5) and Admins (usergroupid 6). If you don't like any of these groups to have the checkbox, delete that usergroup from the if-question --> $bbuserinfo[usergroupid]==X and the || beetween the next group.
Sorry for my bad english... :)
Oh, yes.. if you allready installed it, you can use this changes in your newreply.php...
Super fix! :up: Major thanks!
Lesane
01-28-2002, 07:12 AM
Thnx for the fix AlexD
pwr_sneak
02-05-2002, 02:33 PM
if you still want it the way, it should work, try this:
if ($permissions['canopenclose'] and (ismoderator($threadinfo[forumid],"canopenclose") or $isstarter=$DB_site->query_first("SELECT postuserid FROM thread WHERE threadid='$threadid' and postuserid='$bbuserinfo[userid]'"))) {
$closethreadchecked=iif(trim($closethread)=="yes","checked","");
eval("\$closethreadbox = \"".gettemplate("newpost_closethread")."\";");
} else {
$closethreadbox="";
}
it checks, if the user can open close own threads (and started this thread) or is moderator with this rights.
See it in Action on http://www.hotornot.de
JJR512
02-05-2002, 11:27 PM
I tried the fix by pwr_sneak.
What I found is that as an Admin, if I change the permissions for the admin user group to NOT be able to close own threads, that I did not see the checkbox for ANY thread, regardless of who started it.
Correct me if I'm wrong, but the way the hack is in the last version that I posted, will work just fine for the vast majority of people who use the default permissions scheme, where admins can close any thread, mods can close threads in their forums, and regular members cannot close any threads at all, right? If this is true, then I'm leaving my version posted as-is. If you use a different permission scheme, then it kind of complicates things, and I think part of the problem is that there is no permission setting (that I can find) that lets a user or user group be able to close any thread, just the one where they can close their own threads.
pwr_sneak
02-06-2002, 07:32 AM
Your last Version uses hard-coded usergroupid and it don't let the user close his own thread if he started it.
If you changed your Admin Usergroup not to close their own threads, why should they have permission to close any thread??
Anyway, I got another Version which should work for not only the majority of forums but all, because its fully based upon the permission system in VBulletin.
if (ismoderator($threadinfo[forumid],"canopenclose") or ($permissions['canopenclose'] and $isstarter=$DB_site->query_first("SELECT postuserid FROM thread WHERE threadid='$threadid' and postuserid='$bbuserinfo[userid]'"))) {
$closethreadchecked=iif(trim($closethread)=="yes","checked","");
eval("\$closethreadbox = \"".gettemplate("newpost_closethread")."\";");
} else {
$closethreadbox="";
}
Try to understand what it does, and then use it on your forums :)
It first checks if the user is Moderator for this Forum or even SuperModerator and then (if not) asks for the permission "Close own threads" and if the User has started this thread.
Wolf42
02-06-2002, 09:09 AM
Is working fine!
Thanks to all :up:
Joshua Clinard
02-24-2002, 10:25 PM
Man, it seems that every hack I want to install has problems with it! Why don't people update thier hacks?
JJR512
02-25-2002, 07:45 PM
Not to sound rude or offenseive, but maybe when you get your Hacks number up to oh, say about 12 or so, AND get a message board with almost 150,000 posts, maybe then you won't need to ask a question like that. ;)
My hack does work as-is for me. That makes sense because I developed it for my board. Admins can close any thread with it; Moderators can close threads in their forums; and members cannot close any threads, even their own. This is the default way vBulletin works in terms of who can close what thread, and it's the system I use. My hack works fine for it. Aparently, although I haven't tested it yet, I guess pwr_sneak's version works for ALL situations.
As soon as I am able, I will test his update and fix my hack with it (assuming you, pwr_sneak, don't mind if I do that?).
Joshua Clinard
03-10-2002, 07:34 PM
Sorry, this message was intended to be posted in another thread.
eva2000
03-12-2002, 11:37 PM
from Freddie https://vborg.vbsupport.ru/showthread.php?s=&postid=228959#post228959 suggested using the permissions system so is this correct for instructions ?
ismoderator($foruminfo['forumid'])
find lines 242-245 in newreply.php
} else {
if ($attachmentid and !$foruminfo[moderateattach]) {
$DB_site->query("UPDATE thread SET attach = attach + 1 WHERE threadid = '$threadid'");
}
change to
} else {
if ($closethread=="yes" and ismoderator($foruminfo['forumid']) ) {
$DB_site->query("UPDATE thread SET open='0' WHERE threadid='$threadid'");
}
if ($attachmentid and !$foruminfo[moderateattach]) {
$DB_site->query("UPDATE thread SET attach = attach + 1 WHERE threadid = '$threadid'");
}
Find, on or around Line 450:
$maxattachsize_temp = getmaxattachsize();
Add BEFORE that:
if (ismoderator($foruminfo['forumid'])) {
$closethreadchecked=iif(trim($closethread)=="yes","checked","");
eval("\$closethreadbox = \"".gettemplate("newpost_closethread")."\";");
} else {
$closethreadbox="";
}
is it correct ?
gsnetworks
04-16-2002, 02:56 AM
Good job.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.