Jack Phoenix has submitted this change and it was merged.

Change subject: Version 1.4: Allow (or more accurately, require) providing a 
reason for blocking a phrase
......................................................................


Version 1.4: Allow (or more accurately, require) providing a reason for 
blocking a phrase

Per Samantha, empty reasons are not allowed.

Bug: T152168
Change-Id: Ibea6f90826a23795836aed1c7f91dedb67928458
---
M backend/spamRegexForm.php
M backend/spamRegexList.php
M extension.json
M i18n/en.json
M sql/spam_regex.sql
M templates/ui.tmpl.php
6 files changed, 28 insertions(+), 5 deletions(-)

Approvals:
  Jack Phoenix: Verified; Looks good to me, approved



diff --git a/backend/spamRegexForm.php b/backend/spamRegexForm.php
index 5f9a3f0..98423d0 100644
--- a/backend/spamRegexForm.php
+++ b/backend/spamRegexForm.php
@@ -11,6 +11,11 @@
        public $mBlockedPhrase;
 
        /**
+        * @var string $mBlockedReason Reason for blocking a phrase
+        */
+       public $mBlockedReason;
+
+       /**
         * @var bool $mBlockedTextbox Is the phrase to be blocked in article 
text?
         */
        public $mBlockedTextbox;
@@ -36,6 +41,7 @@
                // urldecode() to avoid *displaying* \ as %5C etc.; even w/o it 
the
                // entries are saved correctly to the DB
                $this->mBlockedPhrase = $request->getVal( 'wpBlockedPhrase', 
urldecode( $request->getVal( 'text', $par ) ) );
+               $this->mBlockedReason = $request->getVal( 'wpBlockedReason' );
                $this->mBlockedTextbox = $request->getCheck( 'wpBlockedTextbox' 
) ? 1 : 0;
                $this->mBlockedSummary = $request->getCheck( 'wpBlockedSummary' 
) ? 1 : 0;
                $this->context = $context;
@@ -104,6 +110,12 @@
                        return;
                }
 
+               /* make sure that we have a good reason for doing all this... */
+               if ( !$this->mBlockedReason ) {
+                       $this->showForm( $this->context->msg( 
'spamregex-error-no-reason' )->escaped() );
+                       return;
+               }
+
                /* insert to memc */
                if ( !empty( $this->mBlockedTextbox ) ) {
                        spamRegexList::updateMemcKeys( 'add', 
$this->mBlockedPhrase, 0 );
@@ -121,7 +133,8 @@
                                'spam_timestamp' => wfTimestampNow(),
                                'spam_user' => 
$this->context->getUser()->getName(),
                                'spam_textbox' => $this->mBlockedTextbox,
-                               'spam_summary' => $this->mBlockedSummary
+                               'spam_summary' => $this->mBlockedSummary,
+                               'spam_reason' => $this->mBlockedReason
                        ),
                        __METHOD__,
                        array( 'IGNORE' )
diff --git a/backend/spamRegexList.php b/backend/spamRegexList.php
index 9668145..601ea1e 100644
--- a/backend/spamRegexList.php
+++ b/backend/spamRegexList.php
@@ -145,7 +145,8 @@
                                        $unblock_phrase,
                                        $row->spam_user,
                                        $date,
-                                       $time
+                                       $time,
+                                       $row->spam_reason
                                );
                                $out->addHTML( '</ul>' );
                        }
diff --git a/extension.json b/extension.json
index 7b95c52..298406c 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "Regular Expression Spam Block",
-       "version": "1.3",
+       "version": "1.4",
        "author": [
                "Bartek Łapiński",
                "Alexandre Emsenhuber",
diff --git a/i18n/en.json b/i18n/en.json
index 4aab62a..2df42fb 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -13,7 +13,7 @@
        "spamregex-currently-blocked": "'''Currently blocked phrases:'''",
        "spamregex-move": "The reason you entered contained a blocked phrase.",
        "spamregex-no-currently-blocked": "'''There are no blocked phrases.'''",
-       "spamregex-log": "* '''$1''' $2 ([{{SERVER}}$3&text=$4 remove]) added 
by $5 on $6 at $7",
+       "spamregex-log": "* '''$1''' $2 ([{{SERVER}}$3&text=$4 remove]) added 
by $5 on $6 at $7 (reason: $8)",
        "spamregex-page-title-1": "Block phrase using regular expressions",
        "spamregex-unblock-success": "Unblock succedeed",
        "spamregex-unblock-message": "Phrase '''$1''' has been unblocked from 
editing.",
@@ -25,6 +25,8 @@
        "spamregex-warning-2": "Please check at least one blocking mode.",
        "spamregex-already-blocked": "\"$1\" is already blocked",
        "spamregex-phrase-block": "Phrase to block:",
+       "spamregex-reason": "Reason:",
+       "spamregex-error-no-reason": "You need to provide a reason for blocking 
a phrase!",
        "spamregex-phrase-block-text": "block phrase in page text",
        "spamregex-phrase-block-summary": "block phrase in summary",
        "spamregex-block-submit": "Block&nbsp;this&nbsp;phrase",
diff --git a/sql/spam_regex.sql b/sql/spam_regex.sql
index 7a07b0a..3f09488 100644
--- a/sql/spam_regex.sql
+++ b/sql/spam_regex.sql
@@ -4,7 +4,8 @@
        spam_timestamp char(14) NOT NULL,
        spam_user varchar(255) NOT NULL,
        spam_textbox int(1) NOT NULL default 1,
-       spam_summary int(1) NOT NULL default 0
+       spam_summary int(1) NOT NULL default 0,
+       spam_reason varchar(255) NOT NULL
 ) /*$wgDBTableOptions*/;
 
 CREATE UNIQUE INDEX /*i*/spam_text ON /*_*/spam_regex (spam_text);
diff --git a/templates/ui.tmpl.php b/templates/ui.tmpl.php
index ee900a0..de05b74 100644
--- a/templates/ui.tmpl.php
+++ b/templates/ui.tmpl.php
@@ -24,6 +24,12 @@
                        </td>
                </tr>
                <tr>
+                       <td align="right"><?php echo wfMessage( 
'spamregex-reason' )->parse() ?></td>
+                       <td align="left">
+                               <input tabindex="1" name="wpBlockedReason" 
value="" size="75" />
+                       </td>
+               </tr>
+               <tr>
                        <td align="right">&#160;</td>
                        <td align="left">
                                <input type="checkbox" tabindex="2" 
name="wpBlockedTextbox" id="wpBlockedTextbox" value="1" checked="checked" />

-- 
To view, visit https://gerrit.wikimedia.org/r/324855
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibea6f90826a23795836aed1c7f91dedb67928458
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SpamRegex
Gerrit-Branch: master
Gerrit-Owner: Jack Phoenix <j...@countervandalism.net>
Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to