Polybuildr has uploaded a new change for review.

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

Change subject: Add option to block user in special page
......................................................................

Add option to block user in special page

Added a button next to the username that can be used to block the user
with 'nocreate', 'noemail' and 'autoblock' options set for an indefinite
period of time.

Change-Id: I1890623998195c8fced8945268e9e7a8763bfe82
---
M static/js/ext.smitespam.retriever.js
1 file changed, 47 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SmiteSpam 
refs/changes/40/222840/1

diff --git a/static/js/ext.smitespam.retriever.js 
b/static/js/ext.smitespam.retriever.js
index 4b1d808..9eb8848 100644
--- a/static/js/ext.smitespam.retriever.js
+++ b/static/js/ext.smitespam.retriever.js
@@ -158,12 +158,58 @@
                        groupedPages.sort( function ( a, b ) {
                                return b.totalSpamValue - a.totalSpamValue;
                        } );
+                       function onBlockButton() {
+                               var $this = $( this );
+                               var username = $this.parent().data( 'username' 
);
+                               $this.prop( 'disabled', true );
+                               $.post( mw.config.get( 'wgScriptPath' ) + 
'/api.php?action=block&format=json',
+                                       {
+                                               user: username,
+                                               token: editToken,
+                                               nocreate: '',
+                                               noemail: '',
+                                               autoblock: '',
+                                               reason: 'Spamming'
+                                       },
+                                       'json'
+                               ).done( function ( data ) {
+                                       if ( 'block' in data ) {
+                                               $( '#smitespam-page-list th 
button' ).each( function () {
+                                                       var $this = $( this );
+                                                       if ( 
$this.parent().data( 'username' )  === username ) {
+                                                               
$this.parent().append( ' (Blocked)' );
+                                                               $this.remove();
+                                                               return false;
+                                                       }
+                                               } );
+                                       } else if ( 'error' in data ) {
+                                               $( '#smitespam-page-list th 
button' ).each( function () {
+                                                       var $this = $( this );
+                                                       if ( 
$this.parent().data( 'username' )  === username ) {
+                                                               
$this.parent().append( ' (Failed to block)' );
+                                                               $this.remove();
+                                                               return false;
+                                                       }
+                                               } );
+                                       }
+                               } );
+                       }
                        for ( i = 0; i < groupedPages.length; i++ ) {
                                var group = groupedPages[i].pages;
                                var groupCreator = groupedPages[i].creator;
                                var $creatorCell = $( '<th>' ).attr( 'colspan', 
5 )
                                        .html( mw.msg( 'smitespam-created-by' ) 
+ ' ' +
-                                       ( users[groupCreator] ? 
users[groupCreator].link : groupCreator ) );
+                                               ( users[groupCreator] ? 
users[groupCreator].link : groupCreator ) )
+                                       .data( 'username', groupCreator );
+                               if ( users[groupCreator] ) {
+                                       if ( users[groupCreator].blocked ) {
+                                               $creatorCell.append( ' 
(Blocked)' );
+                                       } else {
+                                               var $blockButton = $( 
'<button>' ).text( 'Block' ).on( 'click', onBlockButton );
+                                               $creatorCell.append( ' ' );
+                                               $creatorCell.append( 
$blockButton );
+                                       }
+                               }
                                var $creatorRow = $( '<tr>' ).append( 
$creatorCell );
                                $( '#smitespam-page-list' ).append( $creatorRow 
);
                                $( '#smitespam-page-list' ).append( '<tr>' +

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1890623998195c8fced8945268e9e7a8763bfe82
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SmiteSpam
Gerrit-Branch: master
Gerrit-Owner: Polybuildr <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to