Index: trunk/extensions/AbuseFilter/AbuseFilter.php |
— | — | @@ -107,3 +107,8 @@ |
108 | 108 | $wgAbuseFilterUDPPrefix = 'abusefilter:'; |
109 | 109 | $wgAbuseFilterUDPAddress = null; |
110 | 110 | $wgAbuseFilterUDPPort = null; |
| 111 | + |
| 112 | +// Centralised filters |
| 113 | +$wgAbuseFilterCentralDB = null; |
| 114 | +$wgAbuseFilterIsCentral = false; |
| 115 | + |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php |
— | — | @@ -153,7 +153,9 @@ |
154 | 154 | 'tables' => array('abuse_filter', 'abuse_filter_action'), |
155 | 155 | 'fields' => array( |
156 | 156 | 'af_id', |
157 | | - '(af_enabled | af_deleted << 1) AS status', |
| 157 | + 'af_enabled', |
| 158 | + 'af_deleted', |
| 159 | + 'af_global', |
158 | 160 | 'af_public_comments', |
159 | 161 | 'af_hidden', |
160 | 162 | 'af_hit_count', |
— | — | @@ -220,12 +222,19 @@ |
221 | 223 | } |
222 | 224 | return htmlspecialchars( implode( ', ', $displayActions ) ); |
223 | 225 | case 'status': |
224 | | - if ($value & 2) |
225 | | - return wfMsgExt( 'abusefilter-deleted', 'parseinline' ); |
226 | | - elseif ($value & 1) |
227 | | - return wfMsgExt( 'abusefilter-enabled', 'parseinline' ); |
| 226 | + $statuses = array(); |
| 227 | + if ($row->af_deleted) |
| 228 | + $statuses[] = wfMsgExt( 'abusefilter-deleted', 'parseinline' ); |
| 229 | + elseif ($row->af_enabled) |
| 230 | + $statuses[] = wfMsgExt( 'abusefilter-enabled', 'parseinline' ); |
228 | 231 | else |
229 | | - return wfMsgExt( 'abusefilter-disabled', 'parseinline' ); |
| 232 | + $statuses[] = wfMsgExt( 'abusefilter-disabled', 'parseinline' ); |
| 233 | + |
| 234 | + global $wgAbuseFilterIsCentral; |
| 235 | + if ($row->af_global && $wgAbuseFilterIsCentral) |
| 236 | + $statuses[] = wfMsgExt( 'abusefilter-status-global', 'parseinline' ); |
| 237 | + |
| 238 | + return $wgLang->semicolonList( $statuses ); |
230 | 239 | case 'af_hidden': |
231 | 240 | $msg = $value ? 'abusefilter-hidden' : 'abusefilter-unhidden'; |
232 | 241 | return wfMsgExt( $msg, 'parseinline' ); |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php |
— | — | @@ -280,6 +280,10 @@ |
281 | 281 | // Build checkboxen |
282 | 282 | $checkboxes = array( 'hidden', 'enabled', 'deleted' ); |
283 | 283 | $flags = ''; |
| 284 | + |
| 285 | + global $wgAbuseFilterIsCentral; |
| 286 | + if ($wgAbuseFilterIsCentral) |
| 287 | + $checkboxes[] = 'global'; |
284 | 288 | |
285 | 289 | if (isset($row->af_throttled) && $row->af_throttled) { |
286 | 290 | global $wgAbuseFilterEmergencyDisableThreshold; |
— | — | @@ -582,6 +586,7 @@ |
583 | 587 | $obj->af_pattern = ''; |
584 | 588 | $obj->af_enabled = 1; |
585 | 589 | $obj->af_hidden = 0; |
| 590 | + $obj->af_global = 0; |
586 | 591 | return array( $obj, array() ); |
587 | 592 | } |
588 | 593 | |
— | — | @@ -641,6 +646,8 @@ |
642 | 647 | $row->af_deleted = $wgRequest->getBool( 'wpFilterDeleted' ); |
643 | 648 | $row->af_enabled = $wgRequest->getBool( 'wpFilterEnabled' ) && !$row->af_deleted; |
644 | 649 | $row->af_hidden = $wgRequest->getBool( 'wpFilterHidden' ); |
| 650 | + global $wgAbuseFilterIsCentral; |
| 651 | + $row->af_global = $wgRequest->getBool( 'wpFilterGlobal' ) && $wgAbuseFilterIsCentral; |
645 | 652 | |
646 | 653 | // Actions |
647 | 654 | global $wgAbuseFilterAvailableActions; |
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -336,14 +336,15 @@ |
337 | 337 | return htmlspecialchars( self::evaluateExpression( $expr ) ); |
338 | 338 | } |
339 | 339 | |
340 | | - public static function checkConditions( $conds, $vars, $ignoreError = true ) { |
| 340 | + public static function checkConditions( $conds, $vars, $ignoreError = true, |
| 341 | + $keepVars = 'resetvars' ) { |
341 | 342 | global $wgAbuseFilterParserClass; |
342 | 343 | |
343 | 344 | static $parser; |
344 | 345 | |
345 | 346 | wfProfileIn( __METHOD__ ); |
346 | 347 | |
347 | | - if ( is_null($parser) ) { |
| 348 | + if ( is_null($parser) || $keepVars == 'resetvars' ) { |
348 | 349 | $parser = new $wgAbuseFilterParserClass; |
349 | 350 | |
350 | 351 | $parser->setVars( $vars ); |
— | — | @@ -388,7 +389,8 @@ |
389 | 390 | |
390 | 391 | // Check conditions... |
391 | 392 | $pattern = trim($row->af_pattern); |
392 | | - if ( self::checkConditions( $pattern, $vars ) ) { |
| 393 | + if ( self::checkConditions( $pattern, $vars, true /* ignore errors */, |
| 394 | + 'keepvars' ) ) { |
393 | 395 | // Record match. |
394 | 396 | $filter_matched[$row->af_id] = true; |
395 | 397 | } else { |
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php |
— | — | @@ -118,6 +118,7 @@ |
119 | 119 | 'abusefilter-tools' => 'Abuse filter tools', |
120 | 120 | 'abusefilter-loglink' => 'View the abuse log', |
121 | 121 | 'abusefilter-return' => 'Return to filter management', |
| 122 | + 'abusefilter-status-global' => 'Global', |
122 | 123 | |
123 | 124 | // Options form |
124 | 125 | 'abusefilter-list-options' => 'Options', |
— | — | @@ -204,6 +205,7 @@ |
205 | 206 | 'abusefilter-edit-revert' => 'Revert actions taken by this filter', |
206 | 207 | 'abusefilter-edit-tools' => 'Tools:', |
207 | 208 | 'abusefilter-edit-test-link' => 'Test this filter against recent edits', |
| 209 | + 'abusefilter-edit-global' => 'Apply this filter globally', |
208 | 210 | |
209 | 211 | // Filter editing helpers |
210 | 212 | 'abusefilter-edit-builder-select' => 'Select an option to add it at the cursor', |