Index: trunk/extensions/TorBlock/TorBlock.i18n.php |
— | — | @@ -17,6 +17,7 @@ |
18 | 18 | 'right-torunblocked' => 'Bypass automatic blocks of tor exit nodes', |
19 | 19 | 'tag-tor-description' => 'If this tag is set, an edit was made from a Tor exit node.', |
20 | 20 | 'tag-tor' => 'Made through tor', |
| 21 | + 'abusefilter-edit-builder-vars-tor-exit-node' => 'Whether or not the change was made through a tor exit node.', |
21 | 22 | ); |
22 | 23 | |
23 | 24 | /** Message documentation (Message documentation) |
Index: trunk/extensions/TorBlock/TorBlock.php |
— | — | @@ -35,6 +35,8 @@ |
36 | 36 | $wgHooks['AutopromoteCondition'][] = 'TorBlock::onAutopromoteCondition'; |
37 | 37 | $wgHooks['RecentChange_save'][] = 'TorBlock::onRecentChangeSave'; |
38 | 38 | $wgHooks['ListDefinedTags'][] = 'TorBlock::onListDefinedTags'; |
| 39 | +$wgHooks['AbuseFilter-filterAction'][] = 'TorBlock::onAbuseFilterFilterAction'; |
| 40 | +$wgHooks['AbuseFilter-builder'][] = 'TorBlock::onAbuseFilterBuilder'; |
39 | 41 | |
40 | 42 | // Define new autopromote condition |
41 | 43 | define('APCOND_TOR', 'tor'); // Numbers won't work, we'll get collisions |
Index: trunk/extensions/TorBlock/TorBlock.class.php |
— | — | @@ -40,6 +40,17 @@ |
41 | 41 | |
42 | 42 | return true; |
43 | 43 | } |
| 44 | + |
| 45 | + public static function onAbuseFilterFilterAction( &$vars, $title ) { |
| 46 | + $vars->setVar( 'tor_exit_node', self::isExitNode() ? 1 : 0 ); |
| 47 | + return true; |
| 48 | + } |
| 49 | + |
| 50 | + public static function onAbuseFilterBuilder( &$builder ) { |
| 51 | + wfLoadExtensionMessages( 'TorBlock' ); |
| 52 | + $builder['vars']['tor_exit_node'] = 'tor-exit-node'; |
| 53 | + return true; |
| 54 | + } |
44 | 55 | |
45 | 56 | public static function getExitNodes() { |
46 | 57 | if (is_array(self::$mExitNodes)) { |
Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php |
— | — | @@ -685,7 +685,8 @@ |
686 | 686 | |
687 | 687 | protected function getVarValue( $var ) { |
688 | 688 | $var = strtolower($var); |
689 | | - if ( ! array_key_exists( $var, AbuseFilter::$builderValues['vars'] ) ) { |
| 689 | + $builderValues = AbuseFilter::getBuilderValues(); |
| 690 | + if ( ! array_key_exists( $var, $builderValues['vars'] ) ) { |
690 | 691 | // If the variable is invalid, throw an exception |
691 | 692 | throw new AFPUserVisibleException( 'unrecognisedvar', |
692 | 693 | $this->mCur->pos, |
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -119,6 +119,17 @@ |
120 | 120 | return $vars; |
121 | 121 | } |
122 | 122 | |
| 123 | + public static function getBuilderValues() { |
| 124 | + static $realValues = null; |
| 125 | + |
| 126 | + if ($realValues) return $realValues; |
| 127 | + |
| 128 | + $realValues = self::$builderValues; |
| 129 | + wfRunHooks( 'AbuseFilter-builder', array( &$realValues ) ); |
| 130 | + |
| 131 | + return $realValues; |
| 132 | + } |
| 133 | + |
123 | 134 | public static function ajaxCheckSyntax( $filter ) { |
124 | 135 | wfLoadExtensionMessages( 'AbuseFilter' ); |
125 | 136 | |
— | — | @@ -424,6 +435,9 @@ |
425 | 436 | |
426 | 437 | public static function filterAction( $vars, $title ) { |
427 | 438 | global $wgUser,$wgMemc; |
| 439 | + |
| 440 | + // Add vars from extensions |
| 441 | + wfRunHooks( 'AbuseFilter-filterAction', array( &$vars, $title ) ); |
428 | 442 | |
429 | 443 | $dbr = wfGetDB( DB_SLAVE ); |
430 | 444 | |
— | — | @@ -940,7 +954,7 @@ |
941 | 955 | |
942 | 956 | $rules = Xml::textarea( $textName, $rules ); |
943 | 957 | |
944 | | - $dropDown = self::$builderValues; |
| 958 | + $dropDown = self::getBuilderValues(); |
945 | 959 | |
946 | 960 | // Generate builder drop-down |
947 | 961 | $builder = ''; |
— | — | @@ -1221,7 +1235,8 @@ |
1222 | 1236 | // I don't want to change the names of the pre-existing messages |
1223 | 1237 | // describing the variables, nor do I want to rewrite them, so I'm just |
1224 | 1238 | // mapping the variable names to builder messages with a pre-existing array. |
1225 | | - $variableMessageMappings = self::$builderValues['vars']; |
| 1239 | + $variableMessageMappings = self::getBuilderValues(); |
| 1240 | + $variableMessageMappings = $variableMessageMappings['vars']; |
1226 | 1241 | |
1227 | 1242 | $output .= |
1228 | 1243 | Xml::openElement( 'table', array( 'class' => 'mw-abuselog-details' ) ) . |