Filter AbuseLog by triggering action

For now, there is an "Other" field which will show all but hard-coded actions.

Bug: T187971
Change-Id: If564aced2e9cd933d8cfcf7cb96166aa279f2823
This commit is contained in:
Matěj Suchánek 2018-03-04 15:02:45 +01:00
parent 88f714fed1
commit 853936316f
3 changed files with 47 additions and 0 deletions

View file

@ -57,6 +57,9 @@
"abusefilter-log-search-entries-all": "All entries",
"abusefilter-log-search-entries-hidden": "Hidden entries only",
"abusefilter-log-search-entries-visible": "Visible entries only",
"abusefilter-log-search-action-label": "Triggering action:",
"abusefilter-log-search-action-other": "Other",
"abusefilter-log-search-action-any": "Any",
"abusefilter-log-search-action-taken-label": "Action taken:",
"abusefilter-log-search-action-taken-any": "Any",
"abusefilter-log-search-submit": "Search",

View file

@ -90,6 +90,9 @@
"abusefilter-log-search-entries-all": "Option allowing to find all entries in abuse log.",
"abusefilter-log-search-entries-hidden": "Option allowing to find hidden entries only in abuse log.",
"abusefilter-log-search-entries-visible": "Option allowing to find visible entries only in abuse log.",
"abusefilter-log-search-action-label": "Label for options allowing to find entries with specified action that triggered abuse filters.",
"abusefilter-log-search-action-other": "Option allowing to find all entries triggered by an unspecified action in abuse log.\n{{Identical|Other}}",
"abusefilter-log-search-action-any": "Option allowing to find any entry in abuse log.\n{{Identical|Any}}",
"abusefilter-log-search-action-taken-label": "Label for options allowing to find entries with specified action taken by abuse filters.",
"abusefilter-log-search-action-taken-any": "Option allowing to find any entry in abuse log.\n{{Identical|Any}}",
"abusefilter-log-search-submit": "Button text to search log in abuse filter log page.\n{{Identical|Search}}",

View file

@ -15,6 +15,11 @@ class SpecialAbuseLog extends SpecialPage {
*/
protected $mSearchTitle;
/**
* @var string
*/
protected $mSearchAction;
/**
* @var string
*/
@ -129,6 +134,7 @@ class SpecialAbuseLog extends SpecialPage {
$this->mSearchPeriodEnd = $request->getText( 'wpSearchPeriodEnd' );
$this->mSearchTitle = $request->getText( 'wpSearchTitle' );
$this->mSearchFilter = null;
$this->mSearchAction = $request->getText( 'wpSearchAction' );
$this->mSearchActionTaken = $request->getText( 'wpSearchActionTaken' );
if ( self::canSeeDetails() ) {
$this->mSearchFilter = $request->getText( 'wpSearchFilter' );
@ -151,6 +157,21 @@ class SpecialAbuseLog extends SpecialPage {
);
}
/**
* @return string[]
*/
private function getAllFilterableActions() {
return [
'edit',
'move',
'upload',
'stashupload',
'delete',
'createaccount',
'autocreateaccount',
];
}
/**
* Builds the search form
*/
@ -188,6 +209,16 @@ class SpecialAbuseLog extends SpecialPage {
],
],
];
$filterableActions = $this->getAllFilterableActions();
$actions = array_combine( $filterableActions, $filterableActions );
$actions[ $this->msg( 'abusefilter-log-search-action-other' )->text() ] = 'other';
$actions[ $this->msg( 'abusefilter-log-search-action-any' )->text() ] = 'any';
$formDescriptor['SearchAction'] = [
'label-message' => 'abusefilter-log-search-action-label',
'type' => 'select',
'options' => $actions,
'default' => 'any',
];
$options = [
$this->msg( 'abusefilter-log-noactions' )->text() => 'noactions',
$this->msg( 'abusefilter-log-search-action-taken-any' )->text() => '',
@ -449,6 +480,16 @@ class SpecialAbuseLog extends SpecialPage {
}
}
if ( $this->mSearchAction ) {
$filterableActions = $this->getAllFilterableActions();
if ( in_array( $this->mSearchAction, $filterableActions ) ) {
$conds['afl_action'] = $this->mSearchAction;
} elseif ( $this->mSearchAction === 'other' ) {
$list = $dbr->makeList( [ 'afl_action' => $filterableActions ], LIST_OR );
$conds[] = "NOT ( $list )";
}
}
$pager = new AbuseLogPager( $this, $conds );
$pager->doQuery();
$result = $pager->getResult();