Thread Auto-Lock

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Anti-Spam Guide
Reef101
Registered User
Posts: 6
Joined: Tue Aug 25, 2009 3:50 am

Thread Auto-Lock

Post by Reef101 »

Hi,

I've searched through the forum and couldn't find anything matching my criteria.

I'm wonder if a MOD exists that would automatically lock a topic after it's created, so that the new topic can be read but not replied to.

Thanks
Anyasha
Registered User
Posts: 704
Joined: Mon Aug 07, 2006 4:02 am
Name: Anyasha

Re: Thread Auto-Lock

Post by Anyasha »

Although users will be able to edit their post and unlock it if you allow editing, there is a released MOD which allows you to lock on a topic on submission:

http://www.phpbb.com/community/viewtopi ... &t=1501915

If you want all members to be able to do this and not just moderators, change

Code: Select all

$post_data['topic_status']		= ($mode == 'post' && (isset($_POST['lock_topic']) && $auth->acl_get('m_lock', $forum_id))) ? true : false;
to

Code: Select all

$post_data['topic_status']		= ($mode == 'post' && (isset($_POST['lock_topic']))) ? true : false;
You could also make the "lock" button to be checked by default by adding checked="checked" on the posting template. Or you could maybe solve the editing problem by making the lock button checked but hidden.
Kiss me, I'm Polish!
Reef101
Registered User
Posts: 6
Joined: Tue Aug 25, 2009 3:50 am

Re: Thread Auto-Lock

Post by Reef101 »

Hey many thanks for the reply. If I editted the posting template, wouldn't that make the auto-lock do it for the entire board?

Thing is, I need this to only work in a specific forum section rather than the entire board.
Anyasha
Registered User
Posts: 704
Joined: Mon Aug 07, 2006 4:02 am
Name: Anyasha

Re: Thread Auto-Lock

Post by Anyasha »

Assuming you're using the above MOD, I would add this bit of code in posting.php under the 'S_LOCK_TOPIC_ALLOWED' line the MOD has you add:

Code: Select all

	'S_LOCK_TOPIC_MANDATORY'		=> ($forum_id =='FORUMID'),
so it looks like this:

Code: Select all

	'S_LOCK_TOPIC_ALLOWED'		=> (($mode == 'edit' || $mode == 'reply' || $mode == 'quote' || $mode == 'post') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false,
	'S_LOCK_TOPIC_MANDATORY'		=> ($forum_id =='FORUMID'),
and change

Code: Select all

	'S_LOCK_TOPIC_CHECKED'		=> ($lock_topic_checked) ? ' checked="checked"' : '',
to

Code: Select all

	'S_LOCK_TOPIC_CHECKED'		=> ($lock_topic_checked || $forum_id =='FORUMID') ? ' checked="checked"' : '',
and of course you will need to replace FORUMID with the id of the forum (which can be found by hovering your mouse over the link to that forum and finding f=1 or similar in the URL, the number after f= is the forum id) in BOTH instances.

Then, in posting_editor.html (or posting_body.html for subsilver) find this code you added:

Code: Select all

			<!-- IF S_LOCK_TOPIC_ALLOWED -->
				<div><label for="lock_topic"><input type="checkbox" name="lock_topic" id="lock_topic"{S_LOCK_TOPIC_CHECKED} /> {L_LOCK_TOPIC}</label></div>
			<!-- ENDIF -->
and change it to:

Code: Select all

         <!-- IF S_LOCK_TOPIC_ALLOWED -->
            <div<!-- IF S_LOCK_TOPIC_MANDATORY --> style="display:none;<!-- ENDIF -->"><label for="lock_topic"><input type="checkbox" name="lock_topic" id="lock_topic"{S_LOCK_TOPIC_CHECKED} /> {L_LOCK_TOPIC}</label></div>
         <!-- ENDIF -->
It works for me but PLEASE make backups of the files just in case I am wrong/made a mistake. This is a very roundabout way of doing it but in the end it should get you the results you want. If it doesn't seem to be working please let me know.
Kiss me, I'm Polish!
Reef101
Registered User
Posts: 6
Joined: Tue Aug 25, 2009 3:50 am

Re: Thread Auto-Lock

Post by Reef101 »

Anyasha wrote:Assuming you're using the above MOD, I would add this bit of code in posting.php under the 'S_LOCK_TOPIC_ALLOWED' line the MOD has you add:

Code: Select all

	'S_LOCK_TOPIC_MANDATORY'		=> ($forum_id =='FORUMID'),
so it looks like this:

Code: Select all

	'S_LOCK_TOPIC_ALLOWED'		=> (($mode == 'edit' || $mode == 'reply' || $mode == 'quote' || $mode == 'post') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false,
	'S_LOCK_TOPIC_MANDATORY'		=> ($forum_id =='FORUMID'),
and change

Code: Select all

	'S_LOCK_TOPIC_CHECKED'		=> ($lock_topic_checked) ? ' checked="checked"' : '',
to

Code: Select all

	'S_LOCK_TOPIC_CHECKED'		=> ($lock_topic_checked || $forum_id =='FORUMID') ? ' checked="checked"' : '',
and of course you will need to replace FORUMID with the id of the forum (which can be found by hovering your mouse over the link to that forum and finding f=1 or similar in the URL, the number after f= is the forum id) in BOTH instances.

Then, in posting_editor.html (or posting_body.html for subsilver) find this code you added:

Code: Select all

			<!-- IF S_LOCK_TOPIC_ALLOWED -->
				<div><label for="lock_topic"><input type="checkbox" name="lock_topic" id="lock_topic"{S_LOCK_TOPIC_CHECKED} /> {L_LOCK_TOPIC}</label></div>
			<!-- ENDIF -->
and change it to:

Code: Select all

         <!-- IF S_LOCK_TOPIC_ALLOWED -->
            <div<!-- IF S_LOCK_TOPIC_MANDATORY --> style="display:none;<!-- ENDIF -->"><label for="lock_topic"><input type="checkbox" name="lock_topic" id="lock_topic"{S_LOCK_TOPIC_CHECKED} /> {L_LOCK_TOPIC}</label></div>
         <!-- ENDIF -->
It works for me but PLEASE make backups of the files just in case I am wrong/made a mistake. This is a very roundabout way of doing it but in the end it should get you the results you want. If it doesn't seem to be working please let me know.

Many Many thanks for this. I'm actually away for a few days and remote access is being an arse (I suspect that the power may have tripped in my house). As with all the mods I install on my site(s), I always use my test domain to make sure so backup isn't an issue, it breaks it gets deleted and started again lol.

Again thank you

Reef101
Anyasha
Registered User
Posts: 704
Joined: Mon Aug 07, 2006 4:02 am
Name: Anyasha

Re: Thread Auto-Lock

Post by Anyasha »

You are most welcome. I hope it yields the results you're looking for!
Kiss me, I'm Polish!

Return to “[3.0.x] MOD Requests”