MarcoAurelio has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405409 )

Change subject: Convert AutoProxyBlock to use extension registration
......................................................................

Convert AutoProxyBlock to use extension registration

Also other general fixes (licensing headers, etc.)

Change-Id: If92782871efb20151a4026a9cebd4c5489cf29a9
---
M AutoProxyBlock.body.php
M AutoProxyBlock.php
A extension.json
D install.php
A maintenance/install.php
5 files changed, 173 insertions(+), 76 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AutoProxyBlock 
refs/changes/09/405409/1

diff --git a/AutoProxyBlock.body.php b/AutoProxyBlock.body.php
index 115df1d..0a55d5f 100644
--- a/AutoProxyBlock.body.php
+++ b/AutoProxyBlock.body.php
@@ -1,5 +1,24 @@
 <?php
- 
+/**
+* AutoProxyBlock. Allows to automatically block or tag edits performed
+* by proxies.
+*
+* Copyright (C) 2011 Cryptocoryne
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.* 
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+*/
 class AutoProxyBlock {
        static function isProxy( $ip ) {
                global $wgMemc, $wgAutoProxyBlockSources;
diff --git a/AutoProxyBlock.php b/AutoProxyBlock.php
index 782c8c9..e9ef59e 100644
--- a/AutoProxyBlock.php
+++ b/AutoProxyBlock.php
@@ -1,58 +1,35 @@
 <?php
-if ( !defined( 'MEDIAWIKI' ) ) {
-       exit(1);
-}
-
-$dir = dirname(__FILE__);
-$wgExtensionCredits['antispam'][] = array(
-       'path'           => __FILE__,
-       'name'           => 'AutoProxyBlock',
-       'author'         => 'Cryptocoryne',
-       'version'        => '1.1.0',
-       'descriptionmsg' => 'autoproxyblock-desc',
-       'url'            => 
'https://www.mediawiki.org/wiki/Extension:AutoProxyBlock',
-);
-
-$wgMessagesDirs['AutoProxyBlock'] = __DIR__ . '/i18n';
-$wgAutoloadClasses['AutoProxyBlock'] = "$dir/AutoProxyBlock.body.php";
-
-// re-add proxyunbannable to sysops (removed from core)
-$wgAvailableRights[] = 'proxyunbannable';
-$wgGroupPermissions['sysop']['proxyunbannable'] = true;
-// protect special accounts from tagging proxy edits
-$wgAvailableRights[] = 'notagproxychanges';
-
-// set hooks
-$wgHooks['getUserPermissionsErrorsExpensive'][] = 'AutoProxyBlock::checkProxy';
-$wgHooks['RecentChange_save'][] = 'AutoProxyBlock::onRecentChangeSave';
-$wgHooks['ListDefinedTags'][] = 'AutoProxyBlock::addProxyTag';
-$wgHooks['ChangeTagsListActive'][] = 'AutoProxyBlock::addProxyTag';
-$wgHooks['AbuseFilter-filterAction'][] = 'AutoProxyBlock::AFSetVar';
-$wgHooks['AbuseFilter-builder'][] = 'AutoProxyBlock::AFBuilderVars';
-
-// array of actions, allowed to perform by proxy users
-$wgProxyCanPerform = array( 'read', 'edit', 'upload' );
-
-// add "proxy" tag to all edits, matched by this extension
-$wgTagProxyActions = true;
-
-// api is mediawiki api url, raw is local path to file with raw proxylist
-// key is regexp to check reason of block, retrieved from api
-$wgAutoProxyBlockSources = array();
-$wgAutoProxyBlockSources['api'][] = 'http://en.wikipedia.org/w/api.php';
-$wgAutoProxyBlockSources['raw'][] = '/var/www/mediawiki/proxy.list';
-$wgAutoProxyBlockSources['key'] = '/blocked proxy/i';
-
-// if set to true, log all blocked actions in Special:Log/proxyblock
-$wgAutoProxyBlockLog = false;
-
-if( $wgAutoProxyBlockLog ) {
-       $wgAvailableRights[] = 'autoproxyblock-log';
-       $wgGroupPermissions['bureaucrat']['autoproxyblock-log'] = true;
-       $wgLogTypes[] = 'proxyblock';
-       $wgLogNames['proxyblock']             = 'proxyblock-log-name';
-       $wgLogHeaders['proxyblock']           = 'proxyblock-log-header';
-       $wgLogActions['proxyblock/proxyblock'] = 'proxyblock-logentry';
-       $wgLogActions['proxyblock/blocked']   = 'proxyblock-logentry-blocked';
-       $wgLogRestrictions['proxyblock'] = 'autoproxyblock-log';
+/**
+* AutoProxyBlock. Allows to automatically block or tag edits performed
+* by proxies.
+*
+* Copyright (C) 2011 Cryptocoryne
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.* 
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+*/
+if ( function_exists( 'wfLoadExtension' ) ) {
+       wfLoadExtension( 'AutoProxyBlock' );
+       // Keep i18n globals so mergeMessageFileList.php doesn't break
+       $wgMessagesDirs['AutoProxyBlock'] = __DIR__ . '/i18n';
+       $wgExtensionMessagesFiles['AutoProxyBlockAlias'] = __DIR__ . 
'/AutoProxyBlock.alias.php';
+       wfWarn(
+               'Deprecated PHP entry point used for the AutoProxyBlock 
extension. ' .
+               'Please use wfLoadExtension instead, ' .
+               'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
+       );
+       return;
+} else {
+       die( 'This version of the AutoProxyBlock extension requires MediaWiki 
1.29+' );
 }
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..a205755
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,81 @@
+{
+       "name": "AutoProxyBlock",
+       "version": "1.2.0",
+       "author": "[https://www.mediawiki.org/wiki/User:Cryptocoryne 
Cryptocoryne]",
+       "url": "https://www.mediawiki.org/wiki/Extension:AutoProxyBlock";,
+       "descriptionmsg": "autoproxyblock-desc",
+       "license-name": "GPL-2.0-or-later",
+       "type": "antispam",
+       "AvailableRights": [
+               "proxyunbannable",
+               "notagproxychanges",
+               "autoproxyblock-log"
+       ],
+       "GroupPermissions": {
+               "sysop": {
+                       "proxyunbannable": true
+               },
+               "bureaucrat": {
+                       "autoproxyblock-log": true
+               }
+       },
+       "LogActions": {
+               "proxyblock/proxyblock": "proxyblock-logentry",
+               "proxyblock/blocked": "proxyblock-logentry-blocked"
+       },
+       "LogHeaders": {
+               "proxyblock": "proxyblock-log-header"
+       },
+       "LogNames": {
+               "proxyblock": "proxyblock-log-name"
+       },
+       "LogRestrictions": {
+               "proxyblock": "autoproxyblock-log"
+       },
+       "LogTypes": [
+               "proxyblock"
+       ],
+       "MessagesDirs": {
+               "AutoProxyBlock": [
+                       "i18n"
+               ]
+       },
+       "AutoloadClasses": {
+               "AutoProxyBlock": "AutoProxyBlock.body.php"
+       },
+       "Hooks": {
+               "getUserPermissionsErrorsExpensive": 
"AutoProxyBlock::checkProxy",
+               "RecentChange_save": "AutoProxyBlock::onRecentChangeSave",
+               "ListDefinedTags": "AutoProxyBlock::addProxyTag",
+               "ChangeTagsListActive": "AutoProxyBlock::addProxyTag",
+               "AbuseFilter-filterAction": "AutoProxyBlock::AFSetVar",
+               "AbuseFilter-builder": "AutoProxyBlock::AFBuilderVars"
+       },
+       "config": {
+               "ProxyCanPerform": {
+                       "value": [
+                               "read",
+                               "edit",
+                               "upload"
+                       ]
+               },
+               "TagProxyActions": {
+                       "value": true
+               },
+               "AutoProxyBlockSources": {
+                       "value": {
+                               "api": [
+                                       "http://en.wikipedia.org/w/api.php";
+                               ],
+                               "raw": [
+                                       "/var/www/mediawiki/proxy.list"
+                               ],
+                               "key": "/blocked proxy/i"
+                       }
+               },
+               "AutoProxyBlockLog": {
+                       "value": true
+               }
+       },
+       "manifest_version": 2
+}
diff --git a/install.php b/install.php
deleted file mode 100644
index b9e038c..0000000
--- a/install.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-require_once( dirname(__FILE__) . '/../../maintenance/commandLine.inc' );
-
-if ( method_exists( 'User', 'newSystemUser' ) ) {
-       $user = User::newSystemUser( 'AutoProxyBlock', array( 'steal' => true ) 
);
-} else {
-       $user = User::newFromName( 'AutoProxyBlock' );
-
-       if ( !$user->getId() ) {
-               $user->addToDatabase();
-               $user->saveSettings();
-               $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
-               $ssu->doUpdate();
-       } else {
-               $user->setPassword( null );
-               $user->setEmail( null );
-               $user->saveSettings();
-       }
-}
diff --git a/maintenance/install.php b/maintenance/install.php
new file mode 100644
index 0000000..354a368
--- /dev/null
+++ b/maintenance/install.php
@@ -0,0 +1,39 @@
+<?php
+/**
+* AutoProxyBlock. Allows to automatically block or tag edits performed
+* by proxies.
+*
+* Copyright (C) 2011 Cryptocoryne
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.* 
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+*/
+require_once( dirname(__FILE__) . '/../../../maintenance/commandLine.inc' );
+
+if ( method_exists( 'User', 'newSystemUser' ) ) {
+       $user = User::newSystemUser( 'AutoProxyBlock', array( 'steal' => true ) 
);
+} else {
+       $user = User::newFromName( 'AutoProxyBlock' );
+
+       if ( !$user->getId() ) {
+               $user->addToDatabase();
+               $user->saveSettings();
+               $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
+               $ssu->doUpdate();
+       } else {
+               $user->setPassword( null );
+               $user->setEmail( null );
+               $user->saveSettings();
+       }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If92782871efb20151a4026a9cebd4c5489cf29a9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AutoProxyBlock
Gerrit-Branch: master
Gerrit-Owner: MarcoAurelio <maure...@tools.wmflabs.org>

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

Reply via email to