[MediaWiki-commits] [Gerrit] mediawiki...SpamRegex[master]: Version 1.4: Allow (or more accurately, require) providing a...

2016-12-01 Thread Jack Phoenix (Code Review)
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( '' );
}
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

[MediaWiki-commits] [Gerrit] mediawiki...SpamRegex[master]: Version 1.4: Allow (or more accurately, require) providing a...

2016-12-01 Thread Jack Phoenix (Code Review)
Jack Phoenix has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324855

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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SpamRegex 
refs/changes/55/324855/1

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( '' );
}
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