From 777dd95cdf27dfd3bcb292e9f9d7ecf52bdc0f11 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 28 Oct 2014 10:49:19 -0700 Subject: [PATCH] Add two hooks to allow for extensions to expose log_search values in the UI * SpecialLogAddLogSearchRelations Allows for adding the extra conditions needed by the query * LogEventsListGetExtraInputs Allows for adding extra input fields to interface Bug: 70850 Change-Id: If8bdbadd882d67cae82c862c7c38000e9329b04f --- docs/hooks.txt | 12 ++++++++++++ includes/logging/LogEventsList.php | 23 +++++++++++++++-------- includes/specials/SpecialLog.php | 3 +++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index b71c347279..240a772d3d 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1698,6 +1698,13 @@ optional localisation messages &$ignored Array of ignored message keys &$optional Array of optional message keys +'LogEventsListGetExtraInputs': When getting extra inputs to display on Special:Log +for a specific log type +$type: String of log type being displayed +$logEventsList: LogEventsList object for context and access to the WebRequest +&$input: string HTML of an input element + + 'LogEventsListShowLogExtract': Called before the string is added to OutputPage. Returning false will prevent the string from being added to the OutputPage. &$s: html string to show for the log extract @@ -2465,6 +2472,11 @@ UsersPager::getQueryInfo() $pager: The UsersPager instance $query: The query array to be returned +'SpecialLogAddLogSearchRelations': Add log relations to the current log +$type: String of the log type +$request: WebRequest object for getting the value provided by the current user +&$qc: Array for query conditions to add + 'SpecialMovepageAfterMove': Called after moving a page. $movePage: MovePageForm object $oldTitle: old title (object) diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index 70f1f1adb9..99e7151d8c 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -261,14 +261,21 @@ class LogEventsList extends ContextSource { * @return string */ private function getExtraInputs( $types ) { - $offender = $this->getRequest()->getVal( 'offender' ); - $user = User::newFromName( $offender, false ); - if ( !$user || ( $user->getId() == 0 && !IP::isIPAddress( $offender ) ) ) { - $offender = ''; // Blank field if invalid - } - if ( count( $types ) == 1 && $types[0] == 'suppress' ) { - return Xml::inputLabel( $this->msg( 'revdelete-offender' )->text(), 'offender', - 'mw-log-offender', 20, $offender ); + if ( count( $types ) == 1 ) { + if ( $types[0] == 'suppress' ) { + $offender = $this->getRequest()->getVal( 'offender' ); + $user = User::newFromName( $offender, false ); + if ( !$user || ( $user->getId() == 0 && !IP::isIPAddress( $offender ) ) ) { + $offender = ''; // Blank field if invalid + } + return Xml::inputLabel( $this->msg( 'revdelete-offender' )->text(), 'offender', + 'mw-log-offender', 20, $offender ); + } else { + // Allow extensions to add their own extra inputs + $input = ''; + wfRunHooks( 'LogEventsListGetExtraInputs', array( $types[0], $this, &$input ) ); + return $input; + } } return ''; diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php index d3aa6c48a7..99704a9c73 100644 --- a/includes/specials/SpecialLog.php +++ b/includes/specials/SpecialLog.php @@ -95,6 +95,9 @@ class SpecialLog extends SpecialPage { } elseif ( $offender && IP::isIPAddress( $offender->getName() ) ) { $qc = array( 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() ); } + } else { + // Allow extensions to add relations to their search types + wfRunHooks( 'SpecialLogAddLogSearchRelations', array( $opts->getValue( 'type' ), $this->getRequest(), &$qc ) ); } # Some log types are only for a 'User:' title but we might have been given -- 2.20.1