Lock topic with a keyword

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)
Get Involved
Locked
User avatar
Black Antitoon
Registered User
Posts: 219
Joined: Mon Dec 25, 2006 12:12 pm
Contact:

Lock topic with a keyword

Post by Black Antitoon »

Hello!

There was a lovely MOD for phpBB 2 which does not seem to exist for phpBB 3.

That is... if you are a moderator and type in your post the word "locked" (or any other keyword which you can set) the topic is automatically locked without the need of marking the checkbox. This is not really that useful, but locking a topic by just saying "locked" makes you feel great, trust me! :mrgreen:

Anybody willing to write such a MOD? Pleeeease? :roll:
Do you recognise my avatar? :)
User avatar
AmigoJack
Registered User
Posts: 6113
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Lock topic with a keyword

Post by AmigoJack »

Open /posting.php and find:

Code: Select all

        if ($submit)
        {
            // Lock/Unlock Topic
            $change_topic_status = $post_data['topic_status'];
            $perm_lock_unlock = ($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; 
After, add:

Code: Select all

            /*** 2011-07-18 BEGIN AmigoJack
                Lock a topic by submitting a keyword in a post while being able to lock topics ***/
            define( 'MOD_LOCK_WORD', 'locked' );  // The word to be used in the post text
            if( $perm_lock_unlock ) {  // Does it make sense AND are we able to lock the topic?
                if( preg_match( '#\\b'. MOD_LOCK_WORD. '\\b#i', $message_parser-> message ) ) $topic_lock= TRUE;
            }
            /*** 2011-07-18 END ***/ 
As the comments indicate: change locked to the keyword you want to use. Uses word boundaries, so you won't lock a topic with words like blocked or lockedit. Works case insensitive. Tested.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: Lock topic with a keyword

Post by Jessica »

this is so cool. thanks
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein
User avatar
martin123456
I've Been Banned!
Posts: 726
Joined: Sat Mar 05, 2011 7:44 pm

Re: Lock topic with a keyword

Post by martin123456 »

Interesting but is it permission related or will it lock a topic if any member's say the magic word ?

Code: Select all

<!-- IF S_CODE_UNTIDY and S_MESS_ON_INDEX Good If_Not_TIDY_Then_SUBMIT -->
User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: Lock topic with a keyword

Post by 4_seven »

some times ago i've build something similar and (of course) the rights
$auth->acl_get('m_lock', $forum_id) or $auth->acl_get('f_user_lock', $forum_id)
are included in this part of posting.php: http://www.phpbb.com/community/viewtopi ... #p13024782 ;)
Current Mods | Mod Base | php(BB) programming | No help via PM
User avatar
Black Antitoon
Registered User
Posts: 219
Joined: Mon Dec 25, 2006 12:12 pm
Contact:

Re: Lock topic with a keyword

Post by Black Antitoon »

I LOVE YOU GUYS!!! :D Will test this as soon as I get my hands onto a PC (not a mobile phone like now). :mrgreen:
Do you recognise my avatar? :)
Locked

Return to “[3.0.x] MOD Requests”