From 853936316f7c50a1d103ff00ecddb31eb6ed1e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= Date: Sun, 4 Mar 2018 15:02:45 +0100 Subject: [PATCH] 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 --- i18n/en.json | 3 ++ i18n/qqq.json | 3 ++ includes/special/SpecialAbuseLog.php | 41 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/i18n/en.json b/i18n/en.json index 7e335abc6..fb78e3dfc 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -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", diff --git a/i18n/qqq.json b/i18n/qqq.json index 6fb769ef9..78cbea068 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -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}}", diff --git a/includes/special/SpecialAbuseLog.php b/includes/special/SpecialAbuseLog.php index 8d764bcc0..496fc69f0 100644 --- a/includes/special/SpecialAbuseLog.php +++ b/includes/special/SpecialAbuseLog.php @@ -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();