mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-28 16:00:28 +00:00
3bc4bfc4d5
Adds an option for searching filters with a specific pattern in the main page, together with already existing options. Plain search and regex are available, only for users with the view-private right. The search is performed directly on the database. If the user actually searched for something, it is also added a column to Special:AbuseFilter showing a snippet of the pattern from each filter, with the query match highlighted. Depends on: I8144062b1f273d0d8932203ffcb7a71aca60bba9 Bug: T87455 Change-Id: Ibcd84ff84edca481328210ee857b0ab723028632
71 lines
2.2 KiB
PHP
71 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Class to build paginated filter list for wikis using global abuse filters
|
|
*/
|
|
class GlobalAbuseFilterPager extends AbuseFilterPager {
|
|
function __construct( $page, $conds, $linkRenderer, $query ) {
|
|
parent::__construct( $page, $conds, $linkRenderer, $query );
|
|
global $wgAbuseFilterCentralDB;
|
|
$this->mDb = wfGetDB( DB_REPLICA, [], $wgAbuseFilterCentralDB );
|
|
}
|
|
|
|
function formatValue( $name, $value ) {
|
|
$lang = $this->getLanguage();
|
|
$row = $this->mCurrentRow;
|
|
|
|
switch ( $name ) {
|
|
case 'af_id':
|
|
return $lang->formatNum( intval( $value ) );
|
|
case 'af_public_comments':
|
|
return $this->getOutput()->parseInline( $value );
|
|
case 'af_actions':
|
|
$actions = explode( ',', $value );
|
|
$displayActions = [];
|
|
foreach ( $actions as $action ) {
|
|
$displayActions[] = AbuseFilter::getActionDisplay( $action );
|
|
}
|
|
return htmlspecialchars( $lang->commaList( $displayActions ) );
|
|
case 'af_enabled':
|
|
$statuses = [];
|
|
if ( $row->af_deleted ) {
|
|
$statuses[] = $this->msg( 'abusefilter-deleted' )->parse();
|
|
} elseif ( $row->af_enabled ) {
|
|
$statuses[] = $this->msg( 'abusefilter-enabled' )->parse();
|
|
} else {
|
|
$statuses[] = $this->msg( 'abusefilter-disabled' )->parse();
|
|
}
|
|
if ( $row->af_global ) {
|
|
$statuses[] = $this->msg( 'abusefilter-status-global' )->parse();
|
|
}
|
|
|
|
return $lang->commaList( $statuses );
|
|
case 'af_hidden':
|
|
$msg = $value ? 'abusefilter-hidden' : 'abusefilter-unhidden';
|
|
return $this->msg( $msg )->parse();
|
|
case 'af_hit_count':
|
|
// If the rule is hidden, don't show it, even to priviledged local admins
|
|
if ( $row->af_hidden ) {
|
|
return '';
|
|
}
|
|
return $this->msg( 'abusefilter-hitcount' )->numParams( $value )->parse();
|
|
case 'af_timestamp':
|
|
$user = $row->af_user_text;
|
|
return $this->msg(
|
|
'abusefilter-edit-lastmod-text',
|
|
$lang->timeanddate( $value, true ),
|
|
$user,
|
|
$lang->date( $value, true ),
|
|
$lang->time( $value, true ),
|
|
$user
|
|
)->parse();
|
|
case 'af_group':
|
|
// If this is global, local name probably doesn't exist, but try
|
|
return AbuseFilter::nameGroup( $value );
|
|
break;
|
|
default:
|
|
throw new MWException( "Unknown row type $name!" );
|
|
}
|
|
}
|
|
}
|