jenkins-bot has submitted this change and it was merged.

Change subject: Add two hooks to allow for extensions to expose log_search 
values in the UI
......................................................................


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
---
M docs/hooks.txt
M includes/logging/LogEventsList.php
M includes/specials/SpecialLog.php
3 files changed, 30 insertions(+), 8 deletions(-)

Approvals:
  Hoo man: Looks good to me, but someone else must approve
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/docs/hooks.txt b/docs/hooks.txt
index b71c347..240a772 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -1698,6 +1698,13 @@
 &$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 @@
 $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 70f1f1a..99e7151d 100644
--- a/includes/logging/LogEventsList.php
+++ b/includes/logging/LogEventsList.php
@@ -261,14 +261,21 @@
         * @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 d3aa6c4..99704a9 100644
--- a/includes/specials/SpecialLog.php
+++ b/includes/specials/SpecialLog.php
@@ -95,6 +95,9 @@
                        } 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

-- 
To view, visit https://gerrit.wikimedia.org/r/169540
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If8bdbadd882d67cae82c862c7c38000e9329b04f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to