Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: vbgamer45 on August 06, 2009, 12:30:14 AM

Title: Auto Lock Old Topics
Post by: vbgamer45 on August 06, 2009, 12:30:14 AM
Link to the mod (https://custom.simplemachines.org/index.php?mod=2040)

Auto Lock Old Topics


Original Author: Arantor
SMF Version: 2.0.X
Mod Version: 2.0

Description:
This mod adds a Scheduled Task to check for topics that have not been replied to in a while, and automatically lock them. You can change it on a per-board setting, so different boards have different amounts of time if you like, and you can specify never to lock old posts. You can also have it optionally ignore or lock sticky topics.

ChangeLog:
2.0 - December 27, 2012
Taken over by Runic
Updated for 2.0.x

1.3 - November 1, 2009
Updated for RC2 compatibility

1.2 - October 19, 2009
Minor bugfix regarding admin panel quick search

1.1 - September 25, 2009
Minor bugfix for situations of days entered being more than 9999
English-British translation added

1.0 - July 30, 2009
First release

Why Not Visit:
http://www.smfhacks.com (http://www.smfhacks.com)
Title: Re: Auto Lock Old Topics
Post by: JBlaze on August 06, 2009, 12:35:25 AM
Congrats on another approved mod Arantor ;D
Title: Re: Auto Lock Old Topics
Post by: Kadimi on August 06, 2009, 02:26:55 AM
Great idea, let me try it...
Title: Re: Auto Lock Old Topics
Post by: Dzonny on August 06, 2009, 05:42:08 AM
Nice one Arantor... :)
Title: Re: Auto Lock Old Topics
Post by: Eclipse16V on August 06, 2009, 05:19:57 PM
Nice,
this is what I search the last time.
I will test it on my board and than you become the German Lang.
Title: Re: Auto Lock Old Topics
Post by: jossanaijr on August 07, 2009, 04:19:36 PM
Yes, I know.... but it will be nice to have it to 1.1.10 ...
Great mod.
Title: Re: Auto Lock Old Topics
Post by: Arantor on August 07, 2009, 04:28:51 PM
I won't be back porting the mod to 1.1; it requires the Scheduled Tasks system. While in theory it could be (and has been) added, there just isn't the structure in 1.1 to make this viable.
Title: Re: Auto Lock Old Topics
Post by: jossanaijr on August 07, 2009, 04:52:08 PM
Quote from: jossanaijr on August 07, 2009, 04:19:36 PM
Yes, I know.... but it will be nice to have it to 1.1.10 ...
Title: Re: Auto Lock Old Topics
Post by: Arantor on August 07, 2009, 04:53:13 PM
If someone is willing to port it to 1.1, I'm happy to allow the code to be used by anyone who wants/needs to; it's straight-forward enough though.
Title: Re: Auto Lock Old Topics
Post by: nr on August 09, 2009, 05:50:08 AM
Is what I want to wait long.

Should enable 1.1.10 support.  ;)

Thank you.  :)
Title: Re: Auto Lock Old Topics
Post by: Arantor on August 09, 2009, 08:52:47 AM
Quote from: nr on August 09, 2009, 05:50:08 AM
Should enable 1.1.10 support.  ;)

I will not be supporting 1.1 with this mod. 1.1 does not have the necessary systems in place to do it, and adding them would clash with other mods that also run regular tasks, meaning that it is very easy to slow your 1.1 forum down to a crawl.
Title: Re: Auto Lock Old Topics
Post by: vagrant on August 18, 2009, 04:06:12 PM
Nice mod, thanks.

Just one question before i try it tho if i may.

How does it handle users who have a thread set on notify ?
I would not want my board sending out tons of "your thread has been locked" emails like when i last locked a lot of threads by hand :(

That said if it runs once a day then it may not be too many.
Title: Re: Auto Lock Old Topics
Post by: Arantor on August 19, 2009, 03:00:39 PM
The lock is applied by a database change, I don't believe any notifications should be being sent.
Title: Re: Auto Lock Old Topics
Post by: Temar on August 30, 2009, 12:02:06 PM
Hi, i was after a module to delete topics after so many days
but this needed to be board specific as some board shouldn't have topics deleted
i found your module but it was for lock
it was exactly what i was after except it locked not deleted
and was wondering if you could add that option please
Title: Re: Auto Lock Old Topics
Post by: Arantor on August 30, 2009, 12:04:09 PM
This would actually be easier to write as a completely new mod rather than modifying this one, because you'd end up with two pages of configuration otherwise.

I'll add it to my to-do list for you.

EDIT: http://ara.ixos.org/index.php?issue=123.0 covers it.
Title: Re: Auto Lock Old Topics
Post by: Temar on August 30, 2009, 01:03:59 PM
Quote
* revise member post counts
can this be optional some how as i would prob pref if people had a full post count not what hasn't been removed cuz of old
Title: Re: Auto Lock Old Topics
Post by: Arantor on August 30, 2009, 01:06:01 PM
It would be optional - but it's still something I need to think about in implementation.

But it'll look weird for a user to have say 5000 posts but only a fraction of that visible from Show Posts etc.
Title: Re: Auto Lock Old Topics
Post by: aw06 on September 08, 2009, 12:10:31 PM
would LOOOOVVVEEEEEE if i could get this mod on 1.1.10 ..

Or even a auto move mod
Title: Re: Auto Lock Old Topics
Post by: Arantor on September 08, 2009, 12:17:46 PM
I'm not going to rewrite this for 1.1.10 just off the bat. I would consider it as a sponsored development however.
Title: Re: Auto Lock Old Topics
Post by: aw06 on September 20, 2009, 02:01:39 PM
Quote from: Arantor on September 08, 2009, 12:17:46 PM
I'm not going to rewrite this for 1.1.10 just off the bat. I would consider it as a sponsored development however.

Send me a PM with details ..... I'm running a classifieds forum , a mod like this would be essential for me
Title: Re: Auto Lock Old Topics
Post by: Arantor on September 20, 2009, 02:07:20 PM
I'd consider pricing auto locking old threads for 1.1.10 (same functionality as this mod) at $50. Please PM me if you're interested.
Title: Re: Auto Lock Old Topics
Post by: aw06 on September 20, 2009, 05:31:26 PM
ok, will contact you if i decide to indulge
Title: Re: Auto Lock Old Topics
Post by: Arantor on September 25, 2009, 11:13:22 AM
Oh, I've today added a variant mod, Auto Purge Old Topics - same deal as this one, just it removes old topics. It's currently awaiting approval by the Customizer team.
Title: Re: Auto Lock Old Topics
Post by: defensieforum on September 26, 2009, 05:17:10 AM
Quote
I'd consider pricing auto locking old threads for 1.1.10 (same functionality as this mod) at $50. Please PM me if you're interested.

Has anyone already ordered a version for 1.1.x? And if so, will this become public available to?
I could realy use this mode but are still using 1.1.10 at this moment. I don't know if it is possible to use this source code and implement it in 1.1.10 by running something like a cron job?
Title: Re: Auto Lock Old Topics
Post by: Arantor on September 26, 2009, 05:21:50 AM
No one has ordered as yet.

Yes, it could be done through a cron job, which would be ideal, and essentially it would just have to call virtually the same query as in scheduled_autoLock. You're free to use the code but it will need work to change over to the 1.1 database method (or you do it manually with mysql_query)

The reason I'm not prepared to make this for 1.1 without investment is that there is no task scheduler in 1.1 while there is in 2.0, meaning this can be used by people without access to cron on their server.
Title: Re: Auto Lock Old Topics
Post by: defensieforum on September 26, 2009, 05:27:59 AM
Okay I will have a look at the code next week and try to make it compatible with de 1.1.x database an run it by cron job.
But I am not sure about the schedule function in 1.1.x. If I am correct there is a setting to optimize the database every xx days in the admin section. This should also use some form of schedule function....

regards,

Peter
Title: Re: Auto Lock Old Topics
Post by: Arantor on September 26, 2009, 05:37:30 AM
There is - kind of. I suppose you *could* push it into there, but I wouldn't recommend it. Purging posts then optimising tables is suitably blocking that on even a modest forum it would start to get painful.
Title: Re: Auto Lock Old Topics
Post by: aw06 on September 28, 2009, 06:20:31 PM
Quote from: defensieforum on September 26, 2009, 05:27:59 AM
Okay I will have a look at the code next week and try to make it compatible with de 1.1.x database an run it by cron job.
But I am not sure about the schedule function in 1.1.x. If I am correct there is a setting to optimize the database every xx days in the admin section. This should also use some form of schedule function....

regards,

Peter

What I'm figuring in SMF 1.1.10 and all SMF for that matter, we have the option to display a warning to users when a topic has not been posted in for any amount of days we set. So this auto-lock mod maybe somehow could be added as a trigger of that built in SMF feature, which to me seems like some kinda of scheduler ...

So if i set the forums to warn a user about a topic after 90 days, would be nice to have an option to also lock said topic after 90 days has passed .... And maybe this can be simply hard coded into smf without the use of a mod ...

What do you think king Arantor ??
Title: Re: Auto Lock Old Topics
Post by: Arantor on September 28, 2009, 06:23:30 PM
Except that the trigger isn't calculated like that at all.

Internally there's just a count of days, and if the topic hasn't had a reply in that long, it just displays the message; it isn't worked out until actually displaying the thread.

You could have it auto lock on viewing the thread, I suppose, but it's not the same.
Title: Re: Auto Lock Old Topics
Post by: aw06 on September 28, 2009, 06:27:53 PM
Quote from: Arantor on September 28, 2009, 06:23:30 PM
You could have it auto lock on viewing the thread, I suppose, but it's not the same.

Hmmm, this would be useable as well 8) can it be hard coded ? or this needs a mod ?

" Warning: This message has not been replied to in 90 Days and will now be locked "
Title: Re: Auto Lock Old Topics
Post by: Arantor on September 28, 2009, 06:30:37 PM
It would have to be a mod.

What I am contemplating doing is waiting until Auto Purge Old Topics is approved and considering making a single 1.1. compatible mod that handles both, since it's easier to do that way as then there's only one central point of task scheduling. I will not commit to doing this, it's just something I had considered as an idle thought.
Title: Re: Auto Lock Old Topics
Post by: kiano on November 04, 2009, 06:36:20 AM
hi guys)

u can add this query to your Cron jobs. this query is for SMF 1.1.10 and locks old topics (how old? 90 days)

update smf_topics, smf_messages set smf_topics.locked=1 where smf_messages.id_msg=smf_topics.id_last_msg and (unix_timestamp(now()) - unix_timestamp(from_unixtime(smf_messages.posterTime)) > 60*60*24*90);

where 60*60*24*90 - 90 days in seconds.

Donations: Z444012958716
Thanks))
Title: Re: Auto Lock Old Topics
Post by: Arantor on November 04, 2009, 06:44:06 AM
Thanks for that snippet (note that you shouldn't just use smf_ as the prefix; not all users have that).

This mod will shortly be obsolete once I finish the big brother version that has support for 1.1 in it too.
Title: Re: Auto Lock Old Topics
Post by: aw06 on November 04, 2009, 07:28:12 AM
Quote from: kiano on November 04, 2009, 06:36:20 AM
hi guys)

u can add this query to your Cron jobs. this query is for SMF 1.1.10 and locks old topics (how old? 90 days)

update smf_topics, smf_messages set smf_topics.locked=1 where smf_messages.id_msg=smf_topics.id_last_msg and (unix_timestamp(now()) - unix_timestamp(from_unixtime(smf_messages.posterTime)) > 60*60*24*90);

where 60*60*24*90 - 90 days in seconds.

Donations: Z444012958716
Thanks))

Where exactly to add this ??

Quote from: Arantor on November 04, 2009, 06:44:06 AM
Thanks for that snippet (note that you shouldn't just use smf_ as the prefix; not all users have that).

This mod will shortly be obsolete once I finish the big brother version that has support for 1.1 in it too.

Will the ads be locked regardless .. lets say someone posted in the topic a day before the lock time .. will it still be lock .. the idea we want something to lock 'inactive topics' and not so much topics made x days ago.. and how soon will your mod be ready ?
Title: Re: Auto Lock Old Topics
Post by: Arantor on November 04, 2009, 07:33:41 AM
Quote from: aw06 on November 04, 2009, 07:28:12 AM
Where exactly to add this ??

In a separate file that starts by loading SSI.php and calling it from cron in your forum control panel.

QuoteWill the ads be locked regardless .. lets say someone posted in the topic a day before the lock time .. will it still be lock .. the idea we want something to lock 'inactive topics' and not so much topics made x days ago.. and how soon will your mod be ready ?

The mod as currently being built allows you to pick on a per board level how many days passed since the last reply to a topic before locking, and optionally ignoring sticky threads. E.g. a thread with no reply in 15 days can be locked, not a topic 15 days old (note that this is actually the same as this mod already does)

As ever, when it's done. I'm temporarily suspending some development due to RL issues and a pretty much total loss of self confidence though. (Which I do not wish to discuss publicly, thanks)

It is in any case a lot of work to backport to 1.1 since there is no scheduled task system in 1.1.
Title: Re: Auto Lock Old Topics
Post by: aw06 on November 04, 2009, 07:37:01 AM
OK, will wait on your mod ... as doing it the cron job way sounds complicated.. :-[
Title: Re: Auto Lock Old Topics
Post by: kiano on November 04, 2009, 08:30:28 AM
if u want to add cron job, u must do:

1) make file query.sql (or other name)
2) cron job command: mysql -u mysql_user --password=your_password < path_to_your_sql-file
Title: Re: Auto Lock Old Topics
Post by: tderheim on November 24, 2009, 12:26:48 AM
Quote from: kiano on November 04, 2009, 06:36:20 AM
update smf_topics, smf_messages set smf_topics.locked=1 where smf_messages.id_msg=smf_topics.id_last_msg and (unix_timestamp(now()) - unix_timestamp(from_unixtime(smf_messages.posterTime)) > 60*60*24*90);
A simple solution to an annoying problem.  Thank you much - I modified the query a bit and then added it to my scheduler.  Works like a charm.  Maybe my server is especially fast, but I just locked about 6,000 posts in a small fraction of a second so I'm not sure the "heavy blocking" is an issue.  Although naturally it makes more sense to implement it as a cronjob, especially for bigger boards.
Title: Re: Auto Lock Old Topics
Post by: Arantor on November 24, 2009, 12:39:34 AM
The query is pretty light all round actually.

Just easier to implement on 2.0 to do it regularly.
Title: Re: Auto Lock Old Topics
Post by: smc1979 on January 20, 2010, 02:08:45 PM
Would it be possible to make a request? I am using this on my forum and having it auto lock topics over 30 days old with no replies.
What would be nice is if it could add a post to each one saying something like

"Topic Auto Locked Due To No Replies In 30 or more Days"

You can have it pull the number of days from the settings.

Thanks again for this add on :-)

Shane
Title: Re: Auto Lock Old Topics
Post by: Arantor on January 20, 2010, 02:10:39 PM
The only thing with that is that it would automatically end up bumping every single one of those posts in the process (and there's no way around it, either)
Title: Re: Auto Lock Old Topics
Post by: smc1979 on January 20, 2010, 02:22:13 PM
Ah, very good point.
I wonder if there is just some way users reading the forum will nknow its been auto locked. Would changing the topic title cause it to be updated in the same way as a post?

Example:
Current topic title: "Port Forwarding Help"
Changed title after lock: "Port Forwarding Help (Auto Locked Due To Inactivity)"

Shane
Title: Re: Auto Lock Old Topics
Post by: Arantor on January 20, 2010, 02:26:46 PM
No, that could be achieved without too much hassle, I think.

I will see if I can find time to do this, to be honest I'm really busy with SimpleDesk development, so it will be a while before I get to look at this.
Title: Re: Auto Lock Old Topics
Post by: smc1979 on January 20, 2010, 02:30:27 PM
That would be great  ;)
I'm a VB programmer so I cant change it my self. I'm thinking it can't be to much f a pain since your already opening the topic to lock it, adding the text should go along with it. I will keep an eye out for an update.

Thanks again
Shane
Title: Re: Auto Lock Old Topics
Post by: Arantor on January 20, 2010, 02:34:46 PM
Actually, I don't open the topic at all, as such. From what I remember when I wrote it, the scheduled task runs a single DB query per board to just update all of them at once. I wouldn't bolt this on, however, since that would require another table join (right now it joins topics to messages on the last message to get the last update time)
Title: Re: Auto Lock Old Topics
Post by: smc1979 on January 20, 2010, 02:40:36 PM
None the less, if it is something you can do that would be great. Its just looking at the locked topics I just to let users know why it was locked :-)

you can see what I am referring to here http://forums.pcwintech.com/
I help users and when they are fixed I lock the thread. But sometimes a user never returns to finish, so lots of old open topics. They are all now closed thanks to your add on how ever :-)

Shane
Title: Re: Auto Lock Old Topics
Post by: aw06 on April 19, 2010, 11:53:14 AM
So this works only on SMF 2.0 using the scheduling system, but can't it be back ported to SMF 1.1.11 .. and then use the post warning notification that we set to warn a user that a post if x days old, so when the warning comes up the post would auto lock ??

Not possible ?
Title: Re: Auto Lock Old Topics
Post by: Arantor on April 19, 2010, 11:56:15 AM
Um, not really, no, because 1.1's code doesn't quite work like that. Besides that doesn't auto lock, that only means if someone tries to reply to an old topic it locks it, which isn't the same thing.

IMHO, if you want that... ask for a new mod in Mod Requests (http://www.simplemachines.org/community/index.php?board=79.0).

I would also encourage you not to confuse what's "not possible" with "what people can't be bothered to write" or "what's a significant amount of effort to write". What you're asking for isn't huge, but it's not trivial either.
Title: Re: Auto Lock Old Topics
Post by: aw06 on April 19, 2010, 12:03:17 PM
Figured this would be the right place to start asking being as it's being done in 2.0 ,.. mod authors may want to take on the challenge .. but i will make a mod request..
Title: Re: Auto Lock Old Topics
Post by: Arantor on April 19, 2010, 12:04:00 PM
Apart from the fact that both have 'lock' in the title and handle locking of older posts... there's little or nothing in common between the two.
Title: Re: Auto Lock Old Topics
Post by: Jack_40k on August 07, 2010, 03:58:13 AM
Hey guys,

I'm having trouble with the mod. I can't see it. Where is it accessed from in the menu? I assumed it would be under Configuration>Modification settings, but it's not there? I'm running SMF 2.0 RC3

Everything seems to be installed fine.. All the code is there..
Title: Re: Auto Lock Old Topics
Post by: live627 on September 28, 2010, 06:42:59 PM
You may be missing the setting per-board. Go to where you modify a board.
Title: Re: Auto Lock Old Topics
Post by: Oya on September 28, 2010, 06:56:43 PM
um no there isnt one

its all in admin > configuration > modifications > auto lock old topics
Title: Re: Auto Lock Old Topics
Post by: live627 on September 29, 2010, 03:21:07 PM
That's what I assumed from the mod page

"You can change it on a per-board setting"
Title: Re: Auto Lock Old Topics
Post by: Oya on September 29, 2010, 05:18:55 PM
yeah... its per board - but all in one place
Title: Re: Auto Lock Old Topics
Post by: samurai-lupin on October 17, 2010, 10:58:39 PM
I would throw in USD 25.00 to purchase a version of his MOD for SMF 1.1 ... anyone else interested?
Title: Re: Auto Lock Old Topics
Post by: samurai-lupin on November 05, 2010, 05:37:17 PM
BUmp
Title: Re: Auto Lock Old Topics
Post by: samurai-lupin on December 06, 2010, 03:02:14 PM
Bump. I still would like this mod available for SMF 1.1 and offer USD 30.00 for it.
Title: Re: Auto Lock Old Topics
Post by: aw06 on February 17, 2011, 02:13:24 PM
Quote from: Arantor on September 08, 2009, 12:17:46 PM
I'm not going to rewrite this for 1.1.10 just off the bat. I would consider it as a sponsored development however.

How much would you charge to Back-port this to 1.1.x I'm interested
Title: Re: Auto Lock Old Topics
Post by: Arantor on February 17, 2011, 02:19:30 PM
I don't do 1.1 mods, even for money, sorry.
Title: Re: Auto Lock Old Topics
Post by: aw06 on February 17, 2011, 02:21:45 PM
Quote from: Arantor on February 17, 2011, 02:19:30 PM
I don't do 1.1 mods, even for money, sorry.

OK Sir .. Gotcha :P
2.0 Really made allot of people throw in the 1.1.x towel :D

That's the main downfall i see with 1.1.x .. Mods .. So easy to install mods on 2.0, should have been that way from day 1 :P
Title: Re: Auto Lock Old Topics
Post by: Arantor on February 17, 2011, 02:23:41 PM
I don't even do 2.0 mods except in case of emergency, these days.
Title: Re: Auto Lock Old Topics
Post by: aw06 on February 17, 2011, 02:27:24 PM
Quote from: Arantor on February 17, 2011, 02:23:41 PM
I don't even do 2.0 mods except in case of emergency, these days.

o ok .. i see
Title: Re: Auto Lock Old Topics
Post by: zzuzu on February 28, 2011, 09:29:22 AM
Is there chance for 2.0 RC4? With switching from RC3 to RC4, mod stopped working which is sad. But if you don't have time for it, I completely understand. But still... thank you for your hard work :)
Title: Re: Auto Lock Old Topics
Post by: Arantor on February 28, 2011, 09:31:20 AM
The upgrade would have uninstalled the mod but I see no reason why you shouldn't be able to reinstall it.
Title: Re: Auto Lock Old Topics
Post by: WasdMan on March 05, 2011, 01:47:20 PM
This is where you find it?

http://custom.simplemachines.org/mods/index.php?action=download;mod=2040;id=109098;image (http://custom.simplemachines.org/mods/index.php?action=download;mod=2040;id=109098;image)
Title: Re: Auto Lock Old Topics
Post by: Arantor on March 05, 2011, 03:51:49 PM
That's just the scheduled task. The actual configuration is in Admin > Configuration > Modifications...
Title: Re: Auto Lock Old Topics
Post by: Black Viper on March 09, 2011, 05:35:27 PM
Auto Lock Old Topics does not have the option to install on SMF 2.0 RC4 as the "install" link is absent, but I just faked it out by setting the advanced option to SMF RC3 and install as well as "run now" worked. Whether or not it will do so tomorrow, I do not know.

Thanks for reading and I appreciate your efforts Arantor.
Title: Re: Auto Lock Old Topics
Post by: Interested bystander on October 28, 2011, 04:29:39 PM
I installed this on my 2.0.1 forum using the emulation option and emulated 2.0 RC1 when I installed it.   A user in the 2.x support forum who had done this said that it worked fine for him.   Unfortunately even though it says the install was successful and functionality should be available I have been unable to find the location for setting the time for locking topics, or anything else related to this mod.    I asked in the original topic but was told I should repost the question here.   Can anyone give me the path in 2.0.1 to find the fields for entering the length of time before topics are automatically locked?
Title: Re: Auto Lock Old Topics
Post by: live627 on October 29, 2011, 03:51:18 AM
What language do you use?
Title: Re: Auto Lock Old Topics
Post by: Interested bystander on October 29, 2011, 10:32:40 AM
English.
Title: Re: Auto Lock Old Topics
Post by: Shambles on October 29, 2011, 01:00:58 PM
Admin > Configuration > Modification Settings... > Auto Lock
Title: Re: Auto Lock Old Topics
Post by: Interested bystander on October 30, 2011, 11:12:03 AM
Many thanks.
Title: Re: Auto Lock Old Topics
Post by: hamre on January 08, 2012, 05:23:00 PM
Is there any mod like this for 2.0.2?
Title: Re: Auto Lock Old Topics
Post by: Arantor on January 08, 2012, 05:52:08 PM
I see no reason why this shouldn't work on 2.0.2 with a little persuasion. See the wiki on 'how to run mods that are for a different version of SMF'
Title: Re: Auto Lock Old Topics
Post by: amiralib on February 10, 2012, 12:51:32 AM
its very useful
please upgrade for 2.02
Title: Re: Auto Lock Old Topics
Post by: usa4all on July 08, 2012, 04:02:13 PM
I parsed the and add them manually to my 2.0.2 version.  Ik can see the settings and save them. The only thing is that i don't find it back in scheduled tasks.

Is there any one who got this working in 2.0.2?
Title: Re: Auto Lock Old Topics
Post by: Arantor on July 08, 2012, 04:03:05 PM
You didn't complete the manual installation, there is a database query which has to be run too, as per the installer.
Title: Re: Auto Lock Old Topics
Post by: usa4all on July 08, 2012, 04:06:25 PM
You mean this:
Quote./Sources/ScheduledTasks.php
Vind (op het einde van het bestand): [Selecteer]

?>

Ervoor toevoegen: [Selecteer]

function scheduled_autoLock()
{
   global $modSettings, $sourcedir, $mbname, $txt, $smcFunc, $scripturl;

   // Need this in order to load the language files.
   loadEssentialThemeData();
   
   $boards_to_lock = array();
   
   // work out which boards we will be looking at
   $settings = array_keys($modSettings);
   foreach($settings as $setting) {
      if(substr($setting, 0, 8) == 'autoLock') {
         $thissetting = (int) substr($setting, 9);
         if($modSettings[$setting] > 0)
            $boards_to_lock[] = $thissetting;
      }
   }

I dit that part..
Title: Re: Auto Lock Old Topics
Post by: NanoSector on July 08, 2012, 04:13:28 PM
no, there's a file included int he package, probably some kind of Install.php, upload that to the SMF root directory and run it from there.
Title: Re: Auto Lock Old Topics
Post by: usa4all on July 08, 2012, 04:17:04 PM
That will do it!  TX!!
Title: Re: Auto Lock Old Topics
Post by: cydewaze on September 12, 2012, 08:34:20 PM
Does this mod work on 2.02?
Title: Re: Auto Lock Old Topics
Post by: usa4all on September 13, 2012, 11:23:53 AM
Quote from: cydewaze on September 12, 2012, 08:34:20 PM
Does this mod work on 2.02?

Yup, It works on my forum
Title: Re: Auto Lock Old Topics
Post by: zarachrome on January 01, 2014, 05:40:41 AM
Hi all :)

Nice mod, Arantor. Thank you very much, because it is very usefull.
But I have a problem: every time it runs I get an undefined error in my site, telling something on line 1667 in ScheduledTasks.php.
I do not know what it means and how to fix it.
Could you help me, please?
Thank you in advance.

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fcl.ly%2FT9xJ%2Fauto_lock-error-2.jpg&hash=235bfb890490a130e84160a21fdc42768a7467de)
Title: Re: Auto Lock Old Topics
Post by: Arantor on January 01, 2014, 10:08:09 AM
What error, exactly? I'd also like to know why you're not getting the same error for line 1665 too.
Title: Re: Auto Lock Old Topics
Post by: zarachrome on May 23, 2014, 09:00:27 AM
Sorry, I have not seen your answer till today.
I've been very busy.

I'll try to get some error codes and post here, but thank you anyway.
Title: Re: Auto Lock Old Topics
Post by: agentblackhat on December 12, 2014, 11:16:49 AM
What would I need to edit to change the mod so that it locks a topic 30 days after creation and not the last post? Or is there another mod that can do this?
Title: Re: Auto Lock Old Topics
Post by: diegolyanky on October 22, 2020, 11:39:42 PM

A quick question:

What if is installed on a huge forum with more than 160K non locked topics? ... Will this make that forum become slow or server overload? ...

How it works? ... It has a scheduled task?
Title: Re: Auto Lock Old Topics
Post by: vbgamer45 on October 23, 2020, 01:19:50 AM
From the description
"This mod adds a Scheduled Task to check for topics that have not been replied to in a while, and automatically lock them. You can change it on a per-board setting, so different boards have different amounts of time if you like, and you can specify never to lock old posts. You can also have it optionally ignore or lock sticky topics."
Title: Re: Auto Lock Old Topics
Post by: diegolyanky on October 23, 2020, 07:52:41 PM

Installed and executed.

It only took 25 seconds to flag over 130,000 topics as blocked.

GREAT JOB, VBGAMER !  ;)

YOU'RE THE BOSS !!!  ::)
Title: Re: Auto Lock Old Topics
Post by: vbgamer45 on October 23, 2020, 07:55:21 PM
Well Arantor built it and he does do great code. I just do bug fixes now if any found.
Title: Re: Auto Lock Old Topics
Post by: rcane on February 02, 2022, 04:20:15 PM
How difficult would it be to swap out 'lock' with remove?
Title: Re: Auto Lock Old Topics
Post by: vbgamer45 on February 02, 2022, 04:40:23 PM
Wouldn't be that hard I would think just change to removetopic call I think
Title: Re: Auto Lock Old Topics
Post by: Arantor on February 02, 2022, 04:44:20 PM
@vbgamer45 maybe salvage something from https://custom.simplemachines.org/index.php?mod=2171 ?
Title: Re: Auto Lock Old Topics
Post by: Doug Heffernan on February 02, 2022, 04:46:19 PM
Quote from: Arantor on February 02, 2022, 04:44:20 PM@vbgamer45 maybe salvage something from https://custom.simplemachines.org/index.php?mod=2171 ?

What mod is that @Arantor? The link redirects me to the mods page.
Title: Re: Auto Lock Old Topics
Post by: vbgamer45 on February 02, 2022, 04:58:22 PM
@Arantor  are you open to have someone work on that mod. Not visible since it was removed from mod site
Title: Re: Auto Lock Old Topics
Post by: Arantor on February 02, 2022, 05:37:07 PM
I'm happy for anyone to pick it up and do whatever's needed to get it out again. I just don't want to be responsible for its maintenance.

@Doug Heffernan so this mod had a companion mod called Auto Purge Old Topics that I wrote (I originally wrote this one too), but it probably needs some love to be out in the community again.
Title: Re: Auto Lock Old Topics
Post by: rcane on February 02, 2022, 07:59:53 PM
Quote from: vbgamer45 on February 02, 2022, 04:40:23 PMWouldn't be that hard I would think just change to removetopic call I think

would that be in the scheduledTasks.php? 

I'm pretty dang new with php but it looks like the db UPDATE work is done in there.
Title: Re: Auto Lock Old Topics
Post by: vbgamer45 on February 02, 2022, 10:26:53 PM
The mod that Arantor built does all this might need some tweaks
Title: Re: Auto Lock Old Topics
Post by: rcane on February 03, 2022, 08:27:34 AM
Quote from: vbgamer45 on February 02, 2022, 10:26:53 PMThe mod that Arantor built does all this might need some tweaks
.

yeah that's what I meant.  in the scheduled tasks.php the function appears in there.  Rather than lock I'd like to replace 'lock' with 'remove'.  I don't need to lock topics really...but this one board would be greatly served if I could just wipe it daily.
Title: Re: Auto Lock Old Topics
Post by: Arantor on February 03, 2022, 08:44:01 AM
As in, there is already a mod for deletion too, it's just not publicly visible right this moment.
Title: Re: Auto Lock Old Topics
Post by: Marina3 on November 19, 2022, 04:29:14 AM
Will this mod work on smf 2.1.2?
Title: Re: Auto Lock Old Topics
Post by: Doug Heffernan on November 19, 2022, 06:01:19 AM
Quote from: Marina3 on November 19, 2022, 04:29:14 AMWill this mod work on smf 2.1.2?

You can check the COMPATIBLE WITH field for mods to see on what version(s) of Smf they will work.
Title: Re: Auto Lock Old Topics
Post by: Steve on November 20, 2022, 06:26:41 PM
Quote from: Marina3 on November 19, 2022, 04:29:14 AMWill this mod work on smf 2.1.2?
Just tested this so the answer to your question is no, not without emulation (which I didn't test).

Doug's advice is valid though. Check what it IS compatible with. Then if you want to try and install it, backup everything and give it a try. Much better if you could try it on a test forum though.
Title: Re: Auto Lock Old Topics
Post by: @rjen on March 30, 2023, 04:40:56 PM
I have taken up a little project to see if I can port this mod to SM2.1 and make it hooks only.

Just looking for an example mod to find what hook(s) to use for the maintenance task? Anyone can give a hint with an example or what Hook to use for the maintenance task?

Thanks in advance...
Title: Re: Auto Lock Old Topics
Post by: Arantor on March 30, 2023, 05:37:27 PM
Use the callable option in the scheduled tasks table to reference an external file/function, since call_helper should be able to load the file from that if you pass it in correctly when setting it up.

The syntax you will want will be filename.php|function_to_call in that file.
Title: Re: Auto Lock Old Topics
Post by: rcane on March 30, 2023, 05:38:55 PM
Quote from: Arantor on March 30, 2023, 05:37:27 PMUse the callable option in the scheduled tasks table to reference an external file/function, since call_helper should be able to load the file from that if you pass it in correctly when setting it up.

The syntax you will want will be filename.php|function_to_call in that file.

...
Title: Re: Auto Lock Old Topics
Post by: vbgamer45 on March 30, 2023, 05:51:50 PM
Check out my RSS Feed Poster plugin has a scheduled task option .
Title: Re: Auto Lock Old Topics
Post by: Arantor on March 30, 2023, 06:21:13 PM
@rcane literally none of my advice there was meant for you, nor is any of it relevant to you, unless you upgraded to 2.1 already... it's an implementation shorthand on implementing this specific problem as posed by the person before me.
Title: Re: Auto Lock Old Topics
Post by: rcane on March 30, 2023, 08:41:27 PM
Yeah I saw that.  I put that in my reason for editing—that it was the wrong thread I was looking at.
Title: Re: Auto Lock Old Topics
Post by: @rjen on March 31, 2023, 04:07:38 AM
I got the mod working, but there is one thing that puzzles me...

I added a scheduled task to the smf_scheduled_tasks table
This task refers to auto_lock
2023-03-31_100206.jpg

I also included a function "scheduled_auto_lock" into my source
2023-03-31_100251.jpg

Now the task is showing in the admin panel, and when I execute it (manually), it succesfully executes...
But I do not know how it gets to call the function "scheduled_auto_lock" or even loads the source file because I do not call it anywhere for the task execution?

What am I mssing here?

2023-03-31_100316.jpg
Title: Re: Auto Lock Old Topics
Post by: @rjen on March 31, 2023, 07:30:36 AM
Quote from: Arantor on March 30, 2023, 05:37:27 PMUse the callable option in the scheduled tasks table to reference an external file/function, since call_helper should be able to load the file from that if you pass it in correctly when setting it up.

The syntax you will want will be filename.php|function_to_call in that file.

Hold the phone, finally your directions sunk in... this must be what I was missing... should have read better before I posted... lemme check that first

Guess this is what was intended...
2023-03-31_133257.jpg
Title: Re: Auto Lock Old Topics
Post by: @rjen on March 31, 2023, 07:36:22 AM
Well, seems it still needs something else?

2023-03-31_133541.jpg
Title: Re: Auto Lock Old Topics
Post by: @rjen on March 31, 2023, 09:31:54 AM
Okay, I managed to make the mod completely working on SMF2.1, but I had to make one file edit: did not manage to make it all hooks :-(

The only way I could get the task to run scheduled was by making this code change...

<file name="$sourcedir/ScheduledTasks.php">
<operation>
<search position="end" />
<add><![CDATA[

function scheduled_auto_lock()
{
global $sourcedir;

require_once($sourcedir . '/Auto_lock.php');
auto_lock_topics();

return true;
}

]]></add>
</operation>
</file>

</modification>
Title: Re: Auto Lock Old Topics
Post by: @rjen on March 31, 2023, 09:43:07 AM
@vbgamer45 if you you interested I can share the updated Mod code with you if you want to release it for SMF2.1...
Title: Re: Auto Lock Old Topics
Post by: vbgamer45 on March 31, 2023, 09:57:00 AM
Sure, that would be great
Title: Re: Auto Lock Old Topics
Post by: Diego Andrés on March 31, 2023, 10:02:43 AM
I believe pre_include hook might do the trick to make it hooks only?
Title: Re: Auto Lock Old Topics
Post by: @rjen on March 31, 2023, 10:06:02 AM
Quote from: Diego Andrés on March 31, 2023, 10:02:43 AMI believe pre_include hook might do the trick to make it hooks only?

let's check that. I guess your idea is to just call the mod source file with the pre_include hook?
Title: Re: Auto Lock Old Topics
Post by: @rjen on March 31, 2023, 11:05:30 AM
Fixed, all hooks. I'll send a copy to vbgamer
Title: Re: Auto Lock Old Topics
Post by: Arantor on March 31, 2023, 01:16:07 PM
You don't even need hooks for the scheduled task itself - your issue with the row in the database table is that you used a / as the separator and not a | as the code requires...
Title: Re: Auto Lock Old Topics
Post by: @rjen on March 31, 2023, 02:25:56 PM
Quote from: Arantor on March 31, 2023, 01:16:07 PMYou don't even need hooks for the scheduled task itself - your issue with the row in the database table is that you used a / as the separator and not a | as the code requires...
tnx
Title: Re: Auto Lock Old Topics
Post by: vbgamer45 on April 02, 2023, 02:09:21 PM
Added
 SMF 2.1 version by @rjen