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)
Ideas Centre
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 » Sat Jul 16, 2011 12:17 am

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: 4999
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Lock topic with a keyword

Post by AmigoJack » Mon Jul 18, 2011 12:36 pm

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 worst thing about censorship is ███████████

User avatar
Jessica
Former Team Member
Posts: 4341
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: Lock topic with a keyword

Post by Jessica » Mon Jul 18, 2011 12:44 pm

this is so cool. thanks
Please do not PM me for support unless it is absolutely necessary
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 » Mon Jul 18, 2011 4:27 pm

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 » Mon Jul 18, 2011 9:41 pm

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 » Wed Jul 20, 2011 4:21 pm

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”

Who is online

Users browsing this forum: No registered users and 14 guests

cron