vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Close Thread with Reply (https://vborg.vbsupport.ru/showthread.php?t=33718)

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.

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:
Code:

  if ($closethread=="yes") {
      $DB_site->query("UPDATE thread SET open='0' WHERE threadid='$threadid'");
  }

with:
Code:

  if ($closethread=="yes"[high] and $permissions['canopenclose']==1[/high]) {
      $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. :)

FWC 01-02-2002 06:06 PM

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:
PHP Code:

  if ($permissions['canopenclose']==1) {
    
$closethreadchecked = ($closethread) ? " checked" "";
    eval(
"\$closethreadbox = \"".gettemplate("newpost_closethread")."\";");
  } else {
    
$closethreadbox="";
  } 

And this as the newpost_closethread template:
Quote:

<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

Quote:

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:
Quote:

Go to the end of that line, which by default should look like this:

newpost_closethread";

Before the double quotes, add this:

,newpost_closethread
It better should look like this:
Quote:

Go to the end of that line, which by default should look like this:

vbcode_colorbits";

Before the double quotes, add this:

,newpost_closethread
Greetz :p,
Mystics

JJR512 01-03-2002 04:17 PM

OK, thanks...I've updated the instructions.

Rose 01-03-2002 06:00 PM

Great hack, JJR. I installed the new, updated version at The Smallville Torch and it works like a charm.

I also installed the previously updated version at my board at Simpsons board. 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.

Rose 01-03-2002 07:44 PM

Quote:

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/attachmen...&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.

djr 01-21-2002 10:10 PM

Despite Firefly's security update 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.

Alex 01-27-2002 01:00 PM

Thank you for this usefull little hack. Very easy to install and it works :)

Alex 01-27-2002 01:13 PM

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?

Alex 01-27-2002 03:28 PM

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.

djr 01-27-2002 04:06 PM

AlexD.

This is already discussed here. There's still no solution for the problem though.

- djr

Warlord 01-27-2002 10:56 PM

Installed, works like a charm.

Alex 01-28-2002 04:10 AM

Ok, i fixed it. Here we go:

In the Hack Instructions find:
Code:

    } 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:
Code:

    } 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:
Code:

  if ($permissions['canopenclose']==1) {
    $closethreadchecked=iif(trim($closethread)=="yes","checked","");
    eval("\$closethreadbox = \"".gettemplate("newpost_closethread")."\";");
  } else {
    $closethreadbox="";
  }

and replace it with:
Code:

  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... :)

Alex 01-28-2002 04:15 AM

Oh, yes.. if you allready installed it, you can use this changes in your newreply.php...

djr 01-28-2002 05:08 AM

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:
PHP Code:

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.

PHP Code:

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.


All times are GMT. The time now is 02:46 AM.

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.01252 seconds
  • Memory Usage 1,849KB
  • 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
  • (6)bbcode_code_printable
  • (3)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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