Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: dada78641 on January 27, 2023, 04:19:08 PM

Title: "Soft" locking old/stale topics
Post by: dada78641 on January 27, 2023, 04:19:08 PM
Hi everyone. I'm currently working on setting up an SMF 2.0.19 forum with a custom theme.

I've been interested in locking older topics to ensure people can't necropost in them and bring them back to the forefront. Like, say, all topics that haven't received new replies in over 6 months.

Getting all stale topics is simple and automatically locking them is easy too, but I kind of want to display them differently than "regular" locked topics that a moderator manually decided to lock. I also would like to show a message saying something like "This topic hasn't received replies in the past n months so you can't reply".

So my question is, how would you store the information about these topics? I don't mind making a separate table for it, storing the information in there, and then requesting it every time a list of topics is being displayed, but maybe there's a more "proper" way to do this? Is there some kind of metadata storage for custom purposes?

Appreciate any thoughts on this :)

edit: just to clarify, my thinking is: I'll lock the topics, but also add the ids to a separate store so that I know to visually display their locked status a bit differently than normal locked topics. But other than that they behave like real locked topics. At least that's my idea.
Title: Re: "Soft" locking old/stale topics
Post by: Diego Andrés on January 27, 2023, 04:27:31 PM
Did you try with this mod: https://custom.simplemachines.org/index.php?mod=2040
Title: Re: "Soft" locking old/stale topics
Post by: dada78641 on January 27, 2023, 04:44:08 PM
Quote from: Diego Andrés on January 27, 2023, 04:27:31 PMDid you try with this mod: https://custom.simplemachines.org/index.php?mod=2040
I've seen that there are a number of mods that auto lock topics, but I want something a little bit different in terms of how it looks to viewers. Like, I'd prefer it if 90% of the forum isn't just lock icons, basically. :)

Just auto locking posts by itself isn't very hard as far as I can tell. But from what I can tell I don't think there's a mod that does exactly what I described in my post?

Which is fine, I'm OK to build it by myself. I'm just wondering how I would store the data. But I guess probably I just need to make my own table for this?

Thanks for your thoughts
Title: Re: "Soft" locking old/stale topics
Post by: Doug Heffernan on January 27, 2023, 06:06:23 PM
Quote from: dada78641 on January 27, 2023, 04:19:08 PMHi everyone. I'm currently working on setting up an SMF 2.0.19 forum with a custom theme.

May I ask why you are not using 2.1.3.?
Title: Re: "Soft" locking old/stale topics
Post by: dada78641 on January 27, 2023, 06:47:06 PM
Quote from: Doug Heffernan on January 27, 2023, 06:06:23 PM
Quote from: dada78641 on January 27, 2023, 04:19:08 PMHi everyone. I'm currently working on setting up an SMF 2.0.19 forum with a custom theme.

May I ask why you are not using 2.1.3.?

The main reason is that I'm converting a very old forum, and we have an old theme that I'm remaking which was built around an older SMF theme. So it seemed more natural to base the work on the 2.0.19 default theme. 2.0.19 is definitely old and not the cutting edge but it didn't look so old to me that it seemed like a terrible idea (although of course I'm not sure!) The converter I found also only goes to 2.0 and it's buggy to boot (I'll have to dig deep and do some fixes..), so for now I decided to just roll with this instead of trying to figure out the 2.1 branch.

I do think eventually I'll make a project of upgrading to the 2.1 branch. Is what I'm trying to achieve easier on that, or is there some kind of provision in the 2.1 branch for doing things similar to this?
Title: Re: "Soft" locking old/stale topics
Post by: Kindred on January 27, 2023, 07:07:17 PM
2.0.x is near end of life.
There is a good chance that it will not be updated again,  and know that php 8.2 breaks it.
Title: Re: "Soft" locking old/stale topics
Post by: Sesquipedalian on January 28, 2023, 10:05:40 PM
If you're doing custom work, it definitely makes more sense to do it based on SMF 2.1. Once you have successfully converted your existing forum to SMF 2.0, just run the Large Upgrade (https://download.simplemachines.org/) package for SMF 2.1 to get up to date.

You will also find it easier and cleaner to create a custom modification to do what you want for SMF 2.1. You can simply use the existing integration hooks to disable replies on topics over a certain age.

You would probably be most interested in the integrate_display_buttons hook in Display.php (so that the reply option is removed when viewing a topic), and the integrate_post_end and integrate_post2_start hooks in Post.php, in order to head off anyone attempting to post by manually entering URL parameters.
Title: Re: "Soft" locking old/stale topics
Post by: dada78641 on January 29, 2023, 06:06:46 AM
Thanks, I'll definitely make a project of upgrading once we get things up and running. Right now we're getting pretty close to having it all working and our old forum is actually falling apart, so I'll probably do it a bit later, but I do definitely see the point in doing so! Especially since it seems it's much easier to do things like this in 2.1.