Add two hooks to allow for extensions to expose log_search values in the UI
authorKunal Mehta <legoktm@gmail.com>
Tue, 28 Oct 2014 17:49:19 +0000 (10:49 -0700)
committerKunal Mehta <legoktm@gmail.com>
Tue, 28 Oct 2014 17:59:36 +0000 (10:59 -0700)
* 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
includes/logging/LogEventsList.php
includes/specials/SpecialLog.php

index b71c347..240a772 100644 (file)
@@ -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)
index 70f1f1a..99e7151 100644 (file)
@@ -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 '';
index d3aa6c4..99704a9 100644 (file)
@@ -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