mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-12-12 14:15:16 +00:00
ef7f867f35
Additional changes: * Removed phan-taint-check-plugin from extra, now inherited from mediawiki-phan-config. Change-Id: Ib63be75df4bfdbd2c5b97de5f80dbec715108c01
63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
/**
|
|
* This class formats abuse log notifications.
|
|
*
|
|
* Uses logentry-abusefilter-hit
|
|
*/
|
|
class AbuseLogHitFormatter extends LogFormatter {
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function getMessageParameters() {
|
|
$entry = $this->entry->getParameters();
|
|
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
|
|
$params = parent::getMessageParameters();
|
|
|
|
$filter_title = SpecialPage::getTitleFor( 'AbuseFilter', $entry['filter'] );
|
|
$filter_caption = $this->msg( 'abusefilter-log-detailedentry-local' )
|
|
->params( $entry['filter'] )
|
|
->text();
|
|
$log_title = SpecialPage::getTitleFor( 'AbuseLog', $entry['log'] );
|
|
$log_caption = $this->msg( 'abusefilter-log-detailslink' )->text();
|
|
|
|
$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( $linkRenderer->makeLink(
|
|
$filter_title,
|
|
$filter_caption
|
|
) );
|
|
$params[8] = Message::rawParam( $linkRenderer->makeLink(
|
|
$log_title,
|
|
$log_caption
|
|
) );
|
|
}
|
|
|
|
$actions_takenRaw = $entry['actions'];
|
|
if ( !strlen( trim( $actions_takenRaw ) ) ) {
|
|
$actions_taken = $this->msg( 'abusefilter-log-noactions' );
|
|
} else {
|
|
$actions = explode( ',', $actions_takenRaw );
|
|
$displayActions = [];
|
|
|
|
foreach ( $actions as $action ) {
|
|
$displayActions[] = AbuseFilter::getActionDisplay( $action );
|
|
}
|
|
$actions_taken = $this->context->getLanguage()->commaList( $displayActions );
|
|
}
|
|
$params[5] = Message::rawParam( $actions_taken );
|
|
|
|
// Bad things happen if the numbers are not in correct order
|
|
ksort( $params );
|
|
|
|
return $params;
|
|
}
|
|
}
|