PDA

View Full Version : Autoclose Thread After X Days Inactivity (Works from date of last post in thread!)


rwoelich
03-13-2006, 10:00 PM
Old Thread Autoclosing Hack
by Rob Woelich of www.teenhelp.org (http://www.teenhelp.org)


Update - 10/29/06:
Threads that have been autoclosed have the closed icon in the forum display (thanks to Kall for the code/suggestion). Also, the "New Reply" button still shows for admins and supermods who have permission to post in the thread.

This seems to work fine on 3.6.0+, but I'm not going to bother releasing it just for that version because it's such a simple hack. If something isn't working right, verify your template edits... if you use a custom skin/style, they could be different.


DESCRIPTION:
This is a relatively simple hack that makes a thread appear "closed" after a specified amount of time. The amount of time is calculated from the last post in the thread, not from the start of the thread, making this a very effective way to keep old topics from being brought up without locking them out while they're still being discussed.

This installation consists of:
1 Product XML Upload for 3.5.0+ (should work on all versions above)
3 Template Edits in the SHOWTHREAD template
1 Image Upload (Optional, really... looks better with image though)

Into more detail:

This hack installs plugins on your showthread and newreply pages. When a user views a thread, the plugin will check the date of the last post in the thread and if the post was made more than a predetermined amount of time ago (one month by default), the thread will appear closed to the user. The thread isn't actually set as closed in the database. If a user clicks on the "Closed" button, they'll be given a No Permission message, keeping them from replying, and the Quick Reply box at the bottom of the thread will be hidden from the user as well. Administrators and super moderators by default are still able to reply to autoclosed threads and will still see the Quick Reply box.

As mentioned, the expiration time is calculated from the last post in the thread, so if a thread is autoclosed and an admin or supermod makes a post in the thread, the thread will be reopened. Since the thread isn't actually set as closed in the database, it's important to note that using the "Open Thread" option from the thread administration menu won't reopen the thread to other users. The only thing that will keep the thread open is a post existing in the thread that's dated as to deter the expiration time.

INSTALLATION:
Complete installation and template editing instructions are included in the ZIP file.

CUSTOMIZATION:
This hack was designed for a specific purpose, to keep those old annoying topics from being brought back up after two months by that one annoying newb. ;)

However, there are a few customizations available, including the usergroups that can reply in the autoclosed threads, the amount of time until a thread is autoclosed, and the message displayed at the top of the thread when the thread has been autoclosed. Customization instructions are included in the ZIP file and are extensive enough for anybody to understand. :)

OTHER:
Two screenshots of an autoclosed thread have been included. One shows the Quick Reply still visible for administrators. Please click Install if you used and liked this... :D

Tralala
03-14-2006, 07:22 AM
What a nice idea. Good work!

rwoelich
03-14-2006, 07:31 AM
I just updated the ZIP file because I noticed that I didn't include one of the template edits to put the autoclose message at the bottom of the thread like in the screenshot. It should all be good now, though. ;)

LeeCHeSSS
03-14-2006, 04:56 PM
Would it be possible to only apply this in certain specific forums?

rwoelich
03-14-2006, 09:19 PM
Sure! Give me two seconds and I'll give you a modified code sample.

Ok, here it is... to apply this hack to only certain forums:

Open the plugin for the showthread_getinfo hook and find:
if ($thread['lastpost'] < (TIMENOW - 2592000))

And replace it with:
if ($thread['lastpost'] < (TIMENOW - 2592000) AND (in_array($thread['forumid'], array(1,2,3))))
...changing 1,2,3 to the forum ids you want to apply the hack to (you can add more or less as you please). Then in the newreply_start plugin, find:
if (($threadinfo['lastpost'] < (TIMENOW - 2592000)) AND ($vbulletin->userinfo[usergroupid]!=6 AND $vbulletin->userinfo[usergroupid]!=5))

And replace with:
if (($threadinfo['lastpost'] < (TIMENOW - 2592000)) AND ($vbulletin->userinfo[usergroupid]!=6 AND $vbulletin->userinfo[usergroupid]!=5) AND (in_array($thread['forumid'], array(1,2,3))))

On the other side, if you want to exclude only a few forums from using this hack, use the same procedure, but add an ! in front of the in_array (to look like !in_array) and then the forum id numbers you use would be the forums that you don't want to apply the hack to. Depending on whether you're excluding or including more forums, you may use either method. Use the one that you'll have to type the least forum ids.

;)

Fergal C
03-26-2006, 12:35 PM
Great idea, might use it to help control spam posts.

Tinbendr
03-30-2006, 01:08 AM
Clicked installed.

I have the Quick Reply turned off for ALL users, (a useless feature IMO), but the quickreply box is showing anyway.

bada_bing
03-30-2006, 02:34 AM
Looks like a sweet hack and something I need for my selling and trading forums.
I do have a couple questions before I click install.

- Will this work on vb 3.5.3 ?

- Also when does this hack start closing threads older then 30 days with no activity , does it start closing already created thread that are beyond 30 days with no activity or does it start with new threads created after the hack is installed?

- Also if this hack checks dates everytime a user enters that thread what is the query count and server load like?

Thanks

Logikos
04-04-2006, 05:36 AM
Hmm.. this is like mine here. https://vborg.vbsupport.ru/showthread.php?t=82827

kall
04-04-2006, 09:23 AM
Hmm.. this is like mine here. https://vborg.vbsupport.ru/showthread.php?t=82827
Similar yes. Normally, I would choose yours, but this one has the cute little box that tells the user about the fact that it has expired. :)

Chuck that in and you have a winner.

bada_bing
04-11-2006, 03:01 AM
Looks like a sweet hack and something I need for my selling and trading forums.
I do have a couple questions before I click install.

- Will this work on vb 3.5.3 ?

- Also when does this hack start closing threads older then 30 days with no activity , does it start closing already created thread that are beyond 30 days with no activity or does it start with new threads created after the hack is installed?

- Also if this hack checks dates everytime a user enters that thread what is the query count and server load like?

Thanks
Anyone?

Tinbendr
04-13-2006, 06:14 PM
Anyone?
- Will this work on vb 3.5.3 ?I installed with 3.5.3.

- Also when does this hack start closing threads older then 30 days with no activity , does it start closing already created thread that are beyond 30 days with no activity or does it start with new threads created after the hack is installed?My understanding is that is uses the last date of the last thread.


- Also if this hack checks dates everytime a user enters that thread what is the query count and server load like?
I don't know that one.

phonexpo
04-14-2006, 06:58 PM
Installed, thanks. Working fine on 3.5.4 !

nasser71
04-15-2006, 02:47 PM
nice jop m8
thanks
instaled

DementedMindz
04-16-2006, 02:38 AM
ill tell you what would be great for this is say the thread gets closed have it where they can set up a option to move threads to a 'recycle bin' forum this way it will get moved to that forum and closed... cause they have this hac that moves them https://vborg.vbsupport.ru/showthread.php?t=106774 but it basiclly does it if you chose... would be nice if it closed it and moved it... hope you usnderstand what i mean

nasser71
04-16-2006, 06:38 PM
hi
i did follow the install info but at the upper part the thread closed button appear and in the lower part of the thread you can see the add replay button
and even if the member press the add replay button or the thread closed button he can go to add replay page

any help in this matter is highly appreciated

rwoelich
04-24-2006, 08:27 PM
Clicked installed.

I have the Quick Reply turned off for ALL users, (a useless feature IMO), but the quickreply box is showing anyway.Hmm, weird. It might be showing up because by this mod it's set to show up for administrators even with the thread closed, so you might be the only one seeing it. Still, if you have it turned off anyway... my suggestion would be to not change the section of code for the Quick Reply. :p

rwoelich
04-24-2006, 08:32 PM
Looks like a sweet hack and something I need for my selling and trading forums.
I do have a couple questions before I click install.

- Will this work on vb 3.5.3 ?

- Also when does this hack start closing threads older then 30 days with no activity , does it start closing already created thread that are beyond 30 days with no activity or does it start with new threads created after the hack is installed?

- Also if this hack checks dates everytime a user enters that thread what is the query count and server load like?

ThanksShould work on 3.5.3, yes.

As for which threads it closes, it will close them if they were created before installation of the mod. It will close any thread that's gone more than 30 days without a reply. To prevent the thread being closed or to reopen the thread, simply post in the thread.

And for query count, it doesn't add any additional queries. It uses the info from the queries that are already used on your showthread.php or newreply.php page.

rwoelich
04-24-2006, 08:36 PM
hi
i did follow the install info but at the upper part the thread closed button appear and in the lower part of the thread you can see the add replay button
and even if the member press the add replay button or the thread closed button he can go to add replay page

any help in this matter is highly appreciatedDouble check to make sure you applied the template modifications correctly. It sounds like you might have missed the parts where you change the code for the new reply button, or incorrectly applied them.

zylstra
05-15-2006, 04:45 PM
Hmm.. this is like mine here. https://vborg.vbsupport.ru/showthread.php?t=82827
Not quite. This one does not modify the database. Another difference is that this one modifies the button to say "Closed Thread" rather than leaves the button as "Reply" only to tell the member on the next page that the thread cannot be replied to.

Stop
05-16-2006, 12:17 PM
I did every thing but still users can reply when clicking either on the Closed button or Post Reply. But Quick Reply is not showing though.
Need help here pls.

kall
05-29-2006, 07:00 AM
It would be benficial if the Closed icon would show in forumdisplay as well. :)

ricknlida
07-06-2006, 03:40 PM
We're using this mod and love it, but I'm wondering:

We've got a huge site, so no doubt the number of closed threads in users' subscribed threads folders is in the tens of thousands.

...so is there a way to make it so that any thread that is closed will come off of users' subscribed threads folder?

Thanks!

rwoelich
08-18-2006, 08:18 PM
Hey, sorry I've been away for a while.

Thanks for all the suggestions, I appreciate them. I'll do some work with this tonight to update it. :)

EasyTarget
09-08-2006, 06:58 PM
nice.

/me clicks install and waits for updates

Ninth Dimension
09-10-2006, 02:57 AM
Great hack... thank you very much :D

/install

cunder
10-07-2006, 01:26 PM
Great hack... thank you very much
but can you these ubdate to Vbulletin 3.6.2 please.

t would be benficial if it is also possible also te statusicon/thread_dot_lock.gif in forumdisplay also indicates that he is closed if a Thread Autoclose Thread After X Days.

thanks

cunder
10-08-2006, 07:12 AM
Great hack... thank you very much
but can you these ubdate to Vbulletin 3.6.2 please.

t would be benficial if it is also possible also te statusicon/thread_dot_lock.gif in forumdisplay also indicates that he is closed if a Thread Autoclose Thread After X Days.

thanks

Bump

kall
10-08-2006, 05:56 PM
Bump
I provided the plugin and code to the author to do this.. it's not overly difficult.

cunder
10-09-2006, 09:21 AM
I provided the plugin and code to the author to do this.. it's not overly difficult.

oke dith you already how you must do this ??

cunder
10-12-2006, 07:50 AM
is there already someone to no or this script become to ubdate to Vbulletin 3.6.2
please :tired:

cunder
10-22-2006, 09:46 AM
is there already someone to no or this script become to ubdate to Vbulletin 3.6.2
please :tired:

help please :(

cunder
10-28-2006, 12:00 PM
is there already someone to no or this script become to ubdate to Vbulletin 3.6.2
please :tired:

Bumb :cross-eyed:

rwoelich
10-30-2006, 07:53 AM
I've updated the hack to include Kall's modification of the thread status icons in the forum display to show up as closed (thanks :D) and have made one or two other tweaks.

Also, this works fine on 3.6.0+ but I'm not going to bother re-releasing it in the other category because it's such a simple hack. :)

When I get more time (I'm putting 60 hour weeks in at work :chinese:) I'll add some more features to this.

jyajay
11-04-2006, 12:06 PM
There is a minor bug in this hack. We have a forum were trash threads are moved and this forum is closed for new postings. But the hack allows to show the quickreply to group 5 and 6 anyway which causes a pretty ugly quickreply box ;)

I fixxed this by removing these two usergroups from the template edit:

before:
<if condition="($show['quickreply'] AND !$expiredthread) OR $bbuserinfo[usergroupid]==6 OR $bbuserinfo[usergroupid]==5">

after:
<if condition="($show['quickreply'] AND !$expiredthread)">

str8bourbon
11-23-2006, 03:05 AM
I've updated the hack to include Kall's modification of the thread status icons in the forum display to show up as closed (thanks :D) and have made one or two other tweaks.

Also, this works fine on 3.6.0+ but I'm not going to bother re-releasing it in the other category because it's such a simple hack. :)

When I get more time (I'm putting 60 hour weeks in at work :chinese:) I'll add some more features to this.

Simple for us because you did all the work! Thanks so much for making this publicly available. So many users were rooting up ancient threads on my forums and it was making quite a mess. Your work put a stop to that.

I have a small suggestion. The message says something to the effect of "received no new no posts for a year." Perhaps it would be better worded as "in over a year" or "in a year or more" or something to that effect. Pretty trivial point in any event, and I realize I can make it say whatever I want.

Anyway, too cool! Thanks again!

str8bourbon
11-23-2006, 02:17 PM
Simple for us because you did all the work! Thanks so much for making this publicly available. So many users were rooting up ancient threads on my forums and it was making quite a mess. Your work put a stop to that.

I have a small suggestion. The message says something to the effect of "received no new no posts for a year." Perhaps it would be better worded as "in over a year" or "in a year or more" or something to that effect. Pretty trivial point in any event, and I realize I can make it say whatever I want.

Anyway, too cool! Thanks again!

An addendum.

I just found something that you might want to add to this hack. It looks like even though a thread is closed by this hack, polls can still be voted on. And of course voting makes the post current and opens it back up again.

Would modifying the hack to keep people from voting in polls be difficult? I'd be happy to help if needed.

ForeverForums
03-08-2007, 11:23 PM
im getting this SQL error when i try to install this hack

Invalid SQL:

### INSERT QUERY GENERATED BY fetch_query_sql() ###
INSERT INTO plugin
(`active`, `executionorder`, `title`, `hookname`, `phpcode`, `product`)
VALUES
('1', '5', 'No Replies After 1 Month Inactive', 'newreply_start', 'if (($threadinfo[\'lastpost\'] < (TIMENOW - 2592000)) AND ($vbulletin->userinfo[usergroupid]!=6 AND $vbulletin->userinfo[usergroupid]!=5))\r\n{\r\n print_no_permission();\r\n}', 'autocl');

Burley
05-09-2007, 07:29 PM
great mod, really!!! usefull

is it possible to set the mod so that it makes an exception for specific threads? Sticky ones for instance?

Domenico
05-30-2007, 09:36 AM
Sure! Give me two seconds and I'll give you a modified code sample.

Ok, here it is... to apply this hack to only certain forums:

Open the plugin for the showthread_getinfo hook and find:
if ($thread['lastpost'] < (TIMENOW - 2592000))

And replace it with:
if ($thread['lastpost'] < (TIMENOW - 2592000) AND (in_array($thread['forumid'], array(1,2,3))))
...changing 1,2,3 to the forum ids you want to apply the hack to (you can add more or less as you please). Then in the newreply_start plugin, find:
if (($threadinfo['lastpost'] < (TIMENOW - 2592000)) AND ($vbulletin->userinfo[usergroupid]!=6 AND $vbulletin->userinfo[usergroupid]!=5))

And replace with:
if (($threadinfo['lastpost'] < (TIMENOW - 2592000)) AND ($vbulletin->userinfo[usergroupid]!=6 AND $vbulletin->userinfo[usergroupid]!=5) AND (in_array($thread['forumid'], array(1,2,3))))

On the other side, if you want to exclude only a few forums from using this hack, use the same procedure, but add an ! in front of the in_array (to look like !in_array) and then the forum id numbers you use would be the forums that you don't want to apply the hack to. Depending on whether you're excluding or including more forums, you may use either method. Use the one that you'll have to type the least forum ids.

;)

Well I did this but your hack still closes posts from all the forums instead of the forums I ant using your code. How come?

marty1881
05-22-2008, 09:04 PM
How do you change how long it takes till it closes. At the moment its at 1 month and i want it to be 2 weeks.

thewebhostingdi
06-30-2008, 04:06 AM
Is it working with vb 3.7 ?

RMS-Chef
07-09-2008, 02:42 AM
Is it working with vb 3.7 ?
I installed this early in the v3.6 line and am currently up to v3.7 and it has worked fine all the way.

mauro1947
01-27-2009, 05:42 PM
Nothing for vB 3.8 ?

elperi
08-03-2009, 04:39 PM
it works on 3.8.2.

Thanks a lot.

christon26
04-17-2011, 08:38 PM
I have this working on 3.8.7 and added a conditional to exclude stickies and it seems to be working fine so far :)


<hookname>newreply_start</hookname>
<phpcode><![CDATA[if (($threadinfo['lastpost'] < (TIMENOW - 2592000)) AND !$thread['sticky'] AND ($vbulletin->userinfo[usergroupid]!=6 AND $vbulletin->userinfo[usergroupid]!=5))

<hookname>showthread_getinfo</hookname>
<phpcode><![CDATA[if ($thread['lastpost'] < (TIMENOW - 2592000) AND !$thread['sticky'])

<hookname>threadbit_process</hookname>
<phpcode><![CDATA[if (($thread['lastpost'] < (TIMENOW - 2592000))AND $thread['open']AND !$thread['sticky']) {
Hope that helps someone :)