mediawiki-extensions-AbuseF.../AbuseLogHitFormatter.php
Szymon Świerkosz 93b7990fa3 (bug 18080) Send filter hits and changes to irc.wikimedia.org.
I have introduced a new option $wgAbuseFilterNotifications which
allows to configure the extension to send hit notifications to
Special:RecentChanges or UDP. It uses ManualLogEntry class:
ManualLogEntry->publish( 0, $wgAbuseFilterNotifications )

Log entries are _not_ accessible using Special:Log, that's bug 19494.

Change-Id: Ie4bda2f97aa295c0504ba869ef1a99c7a3d20f70
2012-05-04 16:45:19 +02:00

53 lines
1.6 KiB
PHP

<?php
/**
* This class formats abuse log notifications.
*/
class AbuseLogHitFormatter extends LogFormatter {
protected function getMessageParameters() {
$entry = $this->entry->getParameters();
$params = parent::getMessageParameters();
$filter_title = SpecialPage::getTitleFor( 'AbuseFilter', $entry['filter'] );
$filter_caption = $this->msg( 'abusefilter-log-detailedentry-local' )->params( $entry['filter'] );
$log_title = SpecialPage::getTitleFor( 'AbuseLog', $entry['log'] );
$log_caption = $this->msg('abusefilter-log-detailslink' );
$params[4] = $entry['action'];
if ( $this->plaintext ) {
$params[3] = '[[' . $filter_title->getPrefixedText() . '|' . $filter_caption . ']]';
$params[8] = '[[' . $log_title->getPrefixedText() . '|' . $log_caption . ']]';
} else {
$params[3] = Message::rawParam( Linker::link(
$filter_title,
htmlspecialchars( $filter_caption )
) );
$params[8] = Message::rawParam( Linker::link(
$log_title,
htmlspecialchars( $log_caption )
) );
}
$actions_taken = $entry['actions'];
if ( !strlen( trim( $actions_taken ) ) ) {
$actions_taken = $this->msg( 'abusefilter-log-noactions' );
} else {
$actions = explode( ',', $actions_taken );
$displayActions = array();
foreach ( $actions as $action ) {
$displayActions[] = AbuseFilter::getActionDisplay( $action );
}
$actions_taken = $this->context->getLanguage()->commaList( $displayActions );
}
$params[5] = $actions_taken;
// Bad things happen if the numbers are not in correct order
ksort($params);
return $params;
}
}