Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -376,6 +376,7 @@ |
377 | 377 | wfLoadExtensionMessages( 'AbuseFilter' ); |
378 | 378 | |
379 | 379 | global $wgUser; |
| 380 | + $filterUser = AbuseFilter::getFilterUser(); |
380 | 381 | |
381 | 382 | // Create a block. |
382 | 383 | $block = new Block; |
— | — | @@ -392,6 +393,16 @@ |
393 | 394 | |
394 | 395 | $block->insert(); |
395 | 396 | |
| 397 | + // Log it |
| 398 | + # Prepare log parameters |
| 399 | + $logParams = array(); |
| 400 | + $logParams[] = 'indefinite'; |
| 401 | + $logParams[] = 'nocreate, angry-autoblock'; |
| 402 | + |
| 403 | + $log = new LogPage( 'block' ); |
| 404 | + $log->addEntry( 'block', Title::makeTitle( NS_USER, $wgUser->getName() ), |
| 405 | + wfMsgForContent( 'abusefilter-blockreason', $rule_desc ), $logParams, self::getFilterUser() ); |
| 406 | + |
396 | 407 | $display .= wfMsgNoTrans( 'abusefilter-blocked-display', $rule_desc ) ."<br />\n"; |
397 | 408 | break; |
398 | 409 | case 'throttle': |
— | — | @@ -421,6 +432,18 @@ |
422 | 433 | |
423 | 434 | $display .= wfMsgNoTrans( 'abusefilter-degrouped', $rule_desc ) ."<br />\n"; |
424 | 435 | |
| 436 | + // Log it. |
| 437 | + $log = new LogPage( 'rights' ); |
| 438 | + |
| 439 | + $log->addEntry( 'rights', |
| 440 | + $wgUser->getUserPage(), |
| 441 | + wfMsgForContent( 'abusefilter-degroupreason', $rule_desc ), |
| 442 | + array( |
| 443 | + implode( ', ', $groups ), |
| 444 | + wfMsgForContent( 'rightsnone' ) |
| 445 | + ) |
| 446 | + , self::getFilterUser() ); |
| 447 | + |
425 | 448 | break; |
426 | 449 | case 'blockautopromote': |
427 | 450 | wfLoadExtensionMessages( 'AbuseFilter' ); |
— | — | @@ -513,4 +536,36 @@ |
514 | 537 | public static function autoPromoteBlockKey( $user ) { |
515 | 538 | return wfMemcKey( 'abusefilter', 'block-autopromote', $user->getId() ); |
516 | 539 | } |
| 540 | + |
| 541 | + public static function getFilterUser() { |
| 542 | + wfLoadExtensionMessages( 'AbuseFilter' ); |
| 543 | + |
| 544 | + $user = User::newFromName( wfMsgForContent( 'abusefilter-blocker' ) ); |
| 545 | + $user->load(); |
| 546 | + if ($user->getId() && $user->mPassword == '') { |
| 547 | + // Already set up. |
| 548 | + return $user; |
| 549 | + } |
| 550 | + |
| 551 | + // Not set up. Create it. |
| 552 | + |
| 553 | + if (!$user->getId()) { |
| 554 | + $user->addToDatabase(); |
| 555 | + $user->saveSettings(); |
| 556 | + } else { |
| 557 | + // Take over the account |
| 558 | + $user->setPassword( null ); |
| 559 | + $user->setEmail( null ); |
| 560 | + $user->saveSettings(); |
| 561 | + } |
| 562 | + |
| 563 | + # Promote user so it doesn't look too crazy. |
| 564 | + $user->addGroup( 'sysop' ); |
| 565 | + |
| 566 | + # Increment site_stats.ss_users |
| 567 | + $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); |
| 568 | + $ssu->doUpdate(); |
| 569 | + |
| 570 | + return $user; |
| 571 | + } |
517 | 572 | } |
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php |
— | — | @@ -40,8 +40,10 @@ |
41 | 41 | 'abusefilter-autopromote-blocked' => "This action has been automatically identified as harmful, and it has been disallowed. |
42 | 42 | In addition, as a security measure, some privileges routinely granted to established accounts have been temporarily revoked from your account. |
43 | 43 | A brief description of the abuse rule which your action matched is: $1", |
| 44 | + |
44 | 45 | 'abusefilter-blocker' => 'Abuse filter', |
45 | 46 | 'abusefilter-blockreason' => 'Automatically blocked by abuse filter. Rule description: $1', |
| 47 | + 'abusefilter-degroupreason' => 'Rights automatically stripped by abuse filter. Rule description: $1', |
46 | 48 | |
47 | 49 | 'abusefilter-accountreserved' => 'This account name is reserved for use by the abuse filter.', |
48 | 50 | |
Index: trunk/extensions/AbuseFilter/install.php |
— | — | @@ -20,6 +20,7 @@ |
21 | 21 | } else { |
22 | 22 | // Sorry dude, we need this account. |
23 | 23 | $user->setPassword( null ); |
| 24 | + $user->setEmail( null ); |
24 | 25 | $user->saveSettings(); |
25 | 26 | } |
26 | 27 | |