Allow gender based localisation for 'lastmodifiedatby'
[lhc/web/wiklou.git] / includes / LogEventsList.php
index 2f5664c..ac6c9fc 100644 (file)
@@ -24,7 +24,7 @@ class LogEventsList {
        private $out;
        public $flags;
 
-       function __construct( $skin, $out, $flags = 0 ) {
+       public function __construct( $skin, $out, $flags = 0 ) {
                $this->skin = $skin;
                $this->out = $out;
                $this->flags = $flags;
@@ -38,40 +38,47 @@ class LogEventsList {
        private function preCacheMessages() {
                // Precache various messages
                if( !isset( $this->message ) ) {
-                       $messages = 'revertmerge protect_change unblocklink revertmove undeletelink revdel-restore rev-delundel hist';
-                       foreach( explode(' ', $messages ) as $msg ) {
-                               $this->message[$msg] = wfMsgExt( $msg, array( 'escape') );
+                       $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink',
+                               'revertmove', 'undeletelink', 'revdel-restore', 'rev-delundel', 'hist', 'diff',
+                               'pipe-separator' );
+                       foreach( $messages as $msg ) {
+                               $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
                        }
                }
        }
 
        /**
         * Set page title and show header for this log type
-        * @param string $type
+        * @param $type String
         */
        public function showHeader( $type ) {
                if( LogPage::isLogType( $type ) ) {
                        $this->out->setPageTitle( LogPage::logName( $type ) );
-                       $this->out->addHtml( LogPage::logHeader( $type ) );
+                       $this->out->addHTML( LogPage::logHeader( $type ) );
                }
        }
 
        /**
         * Show options for the log list
-        * @param string $type,
-        * @param string $user,
-        * @param string $page,
-        * @param string $pattern
-        * @param int $y year
-        * @param int $y month
-        * @param bool $filter
+        * @param $type String
+        * @param $user String
+        * @param $page String
+        * @param $pattern String
+        * @param $year Integer: year
+        * @param $month Integer: month
+        * @param $filter: array
+        * @param $tagFilter: array?
         */
-       public function showOptions( $type='', $user='', $page='', $pattern='', $y='', $m='', $filter=null ) {
+       public function showOptions( $type = '', $user = '', $page = '', $pattern = '', $year = '', 
+               $month = '', $filter = null, $tagFilter='' ) 
+       {
                global $wgScript, $wgMiserMode;
                $action = htmlspecialchars( $wgScript );
                $title = SpecialPage::getTitleFor( 'Log' );
                $special = htmlspecialchars( $title->getPrefixedDBkey() );
 
+               $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
+
                $this->out->addHTML( "<form action=\"$action\" method=\"get\"><fieldset>" .
                        Xml::element( 'legend', array(), wfMsg( 'log' ) ) .
                        Xml::hidden( 'title', $special ) . "\n" .
@@ -79,28 +86,31 @@ class LogEventsList {
                        $this->getUserInput( $user ) . "\n" .
                        $this->getTitleInput( $page ) . "\n" .
                        ( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) .
-                       "<p>" . $this->getDateMenu( $y, $m ) . "\n" .
-                       ( empty($filter) ? "</p><p>".$this->getFilterLinks( $type, $filter )."\n" : "" ) .
+                       "<p>" . Xml::dateMenu( $year, $month ) . "\n" .
+                       ( $tagSelector ? Xml::tags( 'p', null, implode( '&nbsp;', $tagSelector ) ) :'' ). "\n" .
+                       ( $filter ? "</p><p>".$this->getFilterLinks( $type, $filter )."\n" : "" ) . "\n" .
                        Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
                        "</fieldset></form>"
                );
        }
        
-       private function getFilterLinks( $logtype, $filter ) {
-               global $wgTitle;
+       private function getFilterLinks( $logType, $filter ) {
+               global $wgTitle, $wgLang;
                // show/hide links
-               $showhide = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
+               $messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
                // Option value -> message mapping
                $links = array();
+               $hiddens = ''; // keep track for "go" button
                foreach( $filter as $type => $val ) {
-                       $onoff = 1 - intval($val);
-                       $link = $this->skin->makeKnownLinkObj( $wgTitle, $showhide[$onoff],
-                               wfArrayToCGI( array( "hide{$type}log" => $onoff ), $this->getDefaultQuery() )
+                       $hideVal = 1 - intval($val);
+                       $link = $this->skin->makeKnownLinkObj( $wgTitle, $messages[$hideVal],
+                               wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() )
                        );
-                       $links[$type] = wfMsgHtml( "logshowhide-{$type}", $link );
+                       $links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
+                       $hiddens .= Xml::hidden( "hide_{$type}_log", $val ) . "\n";
                }
                // Build links
-               return implode( ' | ', $links );
+               return '<small>'.$wgLang->pipeList( $links ) . '</small>' . $hiddens;
        }
        
        private function getDefaultQuery() {
@@ -118,8 +128,8 @@ class LogEventsList {
        }
 
        /**
-        * @return string Formatted HTML
-        * @param string $queryType
+        * @param $queryType String
+        * @return String: Formatted HTML
         */
        private function getTypeMenu( $queryType ) {
                global $wgLogRestrictions, $wgUser;
@@ -127,19 +137,19 @@ class LogEventsList {
                $html = "<select name='type'>\n";
 
                $validTypes = LogPage::validTypes();
-               $m = array(); // Temporary array
+               $typesByName = array(); // Temporary array
 
                // First pass to load the log names
                foreach( $validTypes as $type ) {
                        $text = LogPage::logName( $type );
-                       $m[$text] = $type;
+                       $typesByName[$text] = $type;
                }
 
                // Second pass to sort by name
-               ksort($m);
+               ksort($typesByName);
 
                // Third pass generates sorted XHTML content
-               foreach( $m as $text => $type ) {
+               foreach( $typesByName as $text => $type ) {
                        $selected = ($type == $queryType);
                        // Restricted types
                        if ( isset($wgLogRestrictions[$type]) ) {
@@ -156,50 +166,19 @@ class LogEventsList {
        }
 
        /**
-        * @return string Formatted HTML
-        * @param string $user
+        * @param $user String
+        * @return String: Formatted HTML
         */
        private function getUserInput( $user ) {
-               return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 15, $user );
+               return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'mw-log-user', 15, $user );
        }
 
        /**
-        * @return string Formatted HTML
-        * @param string $title
+        * @param $title String
+        * @return String: Formatted HTML
         */
        private function getTitleInput( $title ) {
-               return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'page', 20, $title );
-       }
-
-       /**
-        * @return string Formatted HTML
-        * @param int $year
-        * @param int $month
-        */
-       private function getDateMenu( $year, $month ) {
-               # Offset overrides year/month selection
-               if( $month && $month !== -1 ) {
-                       $encMonth = intval( $month );
-               } else {
-                       $encMonth = '';
-               }
-               if ( $year ) {
-                       $encYear = intval( $year );
-               } else if( $encMonth ) {
-                       $thisMonth = intval( gmdate( 'n' ) );
-                       $thisYear = intval( gmdate( 'Y' ) );
-                       if( intval($encMonth) > $thisMonth ) {
-                               $thisYear--;
-                       }
-                       $encYear = $thisYear;
-               } else {
-                       $encYear = '';
-               }
-               return Xml::label( wfMsg( 'year' ), 'year' ) . ' '.
-                       Xml::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) .
-                       ' '.
-                       Xml::label( wfMsg( 'month' ), 'month' ) . ' '.
-                       Xml::monthSelector( $encMonth, -1 );
+               return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'mw-log-page', 20, $title );
        }
 
        /**
@@ -219,15 +198,15 @@ class LogEventsList {
                return "</ul>\n";
        }
 
-               /**
-        * @param Row $row a single row from the result set
-        * @return string Formatted HTML list item
-        * @private
+       /**
+        * @param $row Row: a single row from the result set
+        * @return String: Formatted HTML list item
         */
        public function logLine( $row ) {
                global $wgLang, $wgUser, $wgContLang;
 
                $title = Title::makeTitle( $row->log_namespace, $row->log_title );
+               $classes = array( "mw-logline-{$row->log_type}" );
                $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->log_timestamp), true );
                // User links
                if( self::isDeleted($row,LogPage::DELETED_USER) ) {
@@ -246,13 +225,13 @@ class LogEventsList {
                $paramArray = LogPage::extractParams( $row->log_params );
                $revert = $del = '';
                // Some user can hide log items and have review links
-               if( $wgUser->isAllowed( 'deleterevision' ) ) {
-                       $del = $this->showhideLinks( $row ) . ' ';
+               if( !($this->flags & self::NO_ACTION_LINK) && $wgUser->isAllowed( 'deleterevision' ) ) {
+                       $del = $this->getShowHideLinks( $row ) . ' ';
                }
                // Add review links and such...
                if( ($this->flags & self::NO_ACTION_LINK) || ($row->log_deleted & LogPage::DELETED_ACTION) ) {
                        // Action text is suppressed...
-               } else if( self::typeAction($row,'move','move') && !empty($paramArray[0]) && $wgUser->isAllowed( 'move' ) ) {
+               } else if( self::typeAction($row,'move','move','move') && !empty($paramArray[0]) ) {
                        $destTitle = Title::newFromText( $paramArray[0] );
                        if( $destTitle ) {
                                $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ),
@@ -263,55 +242,76 @@ class LogEventsList {
                                        '&wpMovetalk=0' ) . ')';
                        }
                // Show undelete link
-               } else if( self::typeAction($row,array('delete','suppress'),'delete') && $wgUser->isAllowed( 'delete' ) ) {
+               } else if( self::typeAction($row,array('delete','suppress'),'delete','delete') ) {
                        $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Undelete' ),
                                $this->message['undeletelink'], 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')';
-               // Show unblock link
-               } else if( self::typeAction($row,array('block','suppress'),'block') && $wgUser->isAllowed( 'block' ) ) {
-                       $revert = '(' .  $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Ipblocklist' ),
-                               $this->message['unblocklink'],
-                               'action=unblock&ip=' . urlencode( $row->log_title ) ) . ')';
+               // Show unblock/change block link
+               } else if( self::typeAction($row,array('block','suppress'),array('block','reblock'),'block') ) {
+                       $revert = '(' .
+                               $this->skin->link( SpecialPage::getTitleFor( 'Ipblocklist' ),
+                                       $this->message['unblocklink'],
+                                       array(),
+                                       array( 'action' => 'unblock', 'ip' => $row->log_title ),
+                                       'known' ) 
+                               . $this->message['pipe-separator'] .
+                               $this->skin->link( SpecialPage::getTitleFor( 'Blockip', $row->log_title ), 
+                                       $this->message['change-blocklink'],
+                                       array(), array(), 'known' ) .
+                               ')';
                // Show change protection link
-               } else if( self::typeAction($row,'protect',array('modify','protect','unprotect')) ) {
-                       $revert .= ' (' .  $this->skin->makeKnownLinkObj( $title, $this->message['hist'], 
-                               'action=history&offset=' . urlencode($row->log_timestamp) ) . ')';
-                       if( $wgUser->isAllowed('protect') && $row->log_action != 'unprotect' ) {
-                               $revert .= ' (' .  $this->skin->makeKnownLinkObj( $title, $this->message['protect_change'], 
-                                       'action=unprotect' ) . ')';
+               } else if( self::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) {
+                       $revert .= ' (' . 
+                               $this->skin->link( $title,
+                                       $this->message['hist'],
+                                       array(),
+                                       array( 'action' => 'history', 'offset' => $row->log_timestamp ) );
+                       if( $wgUser->isAllowed( 'protect' ) ) {
+                               $revert .= $this->message['pipe-separator'] .
+                                       $this->skin->link( $title,
+                                               $this->message['protect_change'],
+                                               array(),
+                                               array( 'action' => 'protect' ),
+                                               'known' );
                        }
+                       $revert .= ')';
                // Show unmerge link
-               } else if ( self::typeAction($row,'merge','merge') ) {
+               } else if( self::typeAction($row,'merge','merge','mergehistory') ) {
                        $merge = SpecialPage::getTitleFor( 'Mergehistory' );
                        $revert = '(' .  $this->skin->makeKnownLinkObj( $merge, $this->message['revertmerge'],
                                wfArrayToCGI( array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(), 
                                        'mergepoint' => $paramArray[1] ) ) ) . ')';
                // If an edit was hidden from a page give a review link to the history
-               } else if( self::typeAction($row,array('delete','suppress'),'revision') && $wgUser->isAllowed( 'deleterevision' ) ) {
-                       if( count($paramArray) == 2 ) {
+               } else if( self::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
+                       if( count($paramArray) >= 2 ) {
                                $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
                                // Different revision types use different URL params...
                                $key = $paramArray[0];
-                               // Link to each hidden object ID, $paramArray[1] is the url param
+                               // $paramArray[1] is a CVS of the IDs
                                $Ids = explode( ',', $paramArray[1] );
-                               $revParams = '';
-                               foreach( $Ids as $n => $id ) {
-                                       $revParams .= '&' . urlencode($key) . '[]=' . urlencode($id);
+                               $query = urlencode($paramArray[1]);
+                               $revert = array();
+                               // Diff link for single rev deletions
+                               if( $key === 'oldid' && count($Ids) == 1 ) {
+                                       $token = urlencode( $wgUser->editToken( intval($Ids[0]) ) );
+                                       $revert[] = $this->skin->makeKnownLinkObj( $title, $this->message['diff'], 
+                                               'diff='.intval($Ids[0])."&unhide=1&token=$token" );
                                }
-                               $revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'], 
-                                       'target=' . $title->getPrefixedUrl() . $revParams ) . ')';
+                               // View/modify link...
+                               $revert[] = $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
+                                       'target='.$title->getPrefixedUrl()."&$key=$query" );
+                               // Pipe links
+                               $revert = '(' . implode(' | ',$revert) . ')';
                        }
                // Hidden log items, give review link
-               } else if( self::typeAction($row,array('delete','suppress'),'event') && $wgUser->isAllowed( 'deleterevision' ) ) {
-                       if( count($paramArray) == 1 ) {
+               } else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
+                       if( count($paramArray) >= 1 ) {
                                $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
+                               // $paramArray[1] is a CVS of the IDs
                                $Ids = explode( ',', $paramArray[0] );
+                               $query = urlencode($paramArray[0]);
                                // Link to each hidden object ID, $paramArray[1] is the url param
-                               $logParams = '';
-                               foreach( $Ids as $n => $id ) {
-                                       $logParams .= '&logid[]=' . intval($id);
-                               }
                                $revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'], 
-                                       'target=' . $title->getPrefixedUrl() . $logParams ) . ')';
+                                       'target='.$title->getPrefixedUrl()."&logid=$query" ) . ')';
                        }
                // Self-created users
                } else if( self::typeAction($row,'newusers','create2') ) {
@@ -322,7 +322,8 @@ class LogEventsList {
                                $revert = $this->skin->userToolLinks( 1, $title->getDBkey() );
                        }
                        if( $time < '20080129000000' ) {
-                               # Suppress $comment from old entries (before 2008-01-29), not needed and can contain incorrect links
+                               # Suppress $comment from old entries (before 2008-01-29),
+                               # not needed and can contain incorrect links
                                $comment = '';
                        }
                // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
@@ -334,45 +335,62 @@ class LogEventsList {
                if( self::isDeleted($row,LogPage::DELETED_ACTION) ) {
                        $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
                } else {
-                       $action = LogPage::actionText( $row->log_type, $row->log_action, $title, $this->skin, $paramArray, true );
+                       $action = LogPage::actionText( $row->log_type, $row->log_action, $title,
+                               $this->skin, $paramArray, true );
                }
 
-               return "<li>$del$time $userLink $action $comment $revert</li>\n";
+               // Any tags...
+               list($tagDisplay, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'logevent' );
+               $classes = array_merge( $classes, $newClasses );
+
+               if( $revert != '' ) {
+                       $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
+               }
+
+               return Xml::tags( 'li', array( "class" => implode( ' ', $classes ) ),
+                       $del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert . " $tagDisplay" ) . "\n";
        }
 
        /**
-        * @param Row $row
+        * @param $row Row
         * @return string
         */
-       private function showhideLinks( $row ) {
+       private function getShowHideLinks( $row ) {
                $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
                // If event was hidden from sysops
                if( !self::userCan( $row, LogPage::DELETED_RESTRICTED ) ) {
-                       $del = $this->message['rev-delundel'];
+                       $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
+                               '('.$this->message['rev-delundel'].')' );
                } else if( $row->log_type == 'suppress' ) {
-                       // No one should be hiding from the oversight log
-                       $del = $this->message['rev-delundel'];
+                       $del = ''; // No one should be hiding from the oversight log
                } else {
                        $target = SpecialPage::getTitleFor( 'Log', $row->log_type );
-                       $del = $this->skin->makeKnownLinkObj( $revdel, $this->message['rev-delundel'],
-                               'target=' . $target->getPrefixedUrl() . '&logid='.$row->log_id );
-                       // Bolden oversighted content
-                       if( self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) )
-                               $del = "<strong>$del</strong>";
+                       $page = Title::makeTitle( $row->log_namespace, $row->log_title );
+                       $query = array( 'target' => $target->getPrefixedDBkey(),
+                               'logid' => $row->log_id, 'page' => $page->getPrefixedDBkey() );
+                       $del = $this->skin->revDeleteLink( $query,
+                               self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) );
                }
-               return "<tt>(<small>$del</small>)</tt>";
+               return $del;
        }
 
        /**
-        * @param Row $row
-        * @param mixed $type (string/array)
-        * @param mixed $action (string/array)
+        * @param $row Row
+        * @param $type Mixed: string/array
+        * @param $action Mixed: string/array
+        * @param $right string
         * @return bool
         */
-       public static function typeAction( $row, $type, $action ) {
-               $match = is_array($type) ? in_array($row->log_type,$type) : $row->log_type == $type;
+       public static function typeAction( $row, $type, $action, $right='' ) {
+               $match = is_array($type) ?
+                       in_array($row->log_type,$type) : $row->log_type == $type;
                if( $match ) {
-                       $match = is_array($action) ? in_array($row->log_action,$action) : $row->log_action == $action;
+                       $match = is_array($action) ?
+                               in_array($row->log_action,$action) : $row->log_action == $action;
+                       if( $match && $right ) {
+                               global $wgUser;
+                               $match = $wgUser->isAllowed( $right );
+                       }
                }
                return $match;
        }
@@ -380,9 +398,9 @@ class LogEventsList {
        /**
         * Determine if the current user is allowed to view a particular
         * field of this log row, if it's marked as deleted.
-        * @param Row $row
-        * @param int $field
-        * @return bool
+        * @param $row Row
+        * @param $field Integer
+        * @return Boolean
         */
        public static function userCan( $row, $field ) {
                if( ( $row->log_deleted & $field ) == $field ) {
@@ -398,9 +416,9 @@ class LogEventsList {
        }
 
        /**
-        * @param Row $row
-        * @param int $field one of DELETED_* bitfield constants
-        * @return bool
+        * @param $row Row
+        * @param $field Integer: one of DELETED_* bitfield constants
+        * @return Boolean
         */
        public static function isDeleted( $row, $field ) {
                return ($row->log_deleted & $field) == $field;
@@ -408,12 +426,12 @@ class LogEventsList {
 
        /**
         * Quick function to show a short log extract
-        * @param OutputPage $out
-        * @param string $type
-        * @param string $page
-        * @param string $user
-        * @param int $lim
-        * @param array $conds
+        * @param $out OutputPage
+        * @param $type String
+        * @param $page String
+        * @param $user String
+        * @param $lim Integer
+        * @param $conds Array
         */
        public static function showLogExtract( $out, $type='', $page='', $user='', $lim=0, $conds=array() ) {
                global $wgUser;
@@ -434,25 +452,26 @@ class LogEventsList {
                return $pager->getNumRows();
        }
 
-        /**
+       /**
         * SQL clause to skip forbidden log types for this user
-        * @param Database $db
-        * @returns mixed (string or false)
+        * @param $db Database
+        * @param $audience string, public/user
+        * @return mixed (string or false)
         */
-       public static function getExcludeClause( $db ) {
+       public static function getExcludeClause( $db, $audience = 'public' ) {
                global $wgLogRestrictions, $wgUser;
                // Reset the array, clears extra "where" clauses when $par is used
                $hiddenLogs = array();
                // Don't show private logs to unprivileged users
-               foreach( $wgLogRestrictions as $logtype => $right ) {
-                       if( !$wgUser->isAllowed($right) ) {
-                               $safetype = $db->strencode( $logtype );
-                               $hiddenLogs[] = $safetype;
+               foreach( $wgLogRestrictions as $logType => $right ) {
+                       if( $audience == 'public' || !$wgUser->isAllowed($right) ) {
+                               $safeType = $db->strencode( $logType );
+                               $hiddenLogs[] = $safeType;
                        }
                }
                if( count($hiddenLogs) == 1 ) {
                        return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
-               } elseif( !empty( $hiddenLogs ) ) {
+               } elseif( $hiddenLogs ) {
                        return 'log_type NOT IN (' . $db->makeList($hiddenLogs) . ')';
                }
                return false;
@@ -465,30 +484,37 @@ class LogEventsList {
 class LogPager extends ReverseChronologicalPager {
        private $type = '', $user = '', $title = '', $pattern = '';
        public $mLogEventsList;
+
        /**
-       * constructor
-       * @param LogEventsList $loglist,
-       * @param string $type,
-       * @param string $user,
-       * @param string $page,
-       * @param string $pattern
-       * @param array $conds
-       */
-       function __construct( $list, $type='', $user='', $title='', $pattern='', $conds=array(), $y=false, $m=false ) {
+        * constructor
+        * @param $list LogEventsList
+        * @param $type String
+        * @param $user String
+        * @param $title String
+        * @param $pattern String
+        * @param $conds Array
+        * @param $year Integer
+        * @param $month Integer
+        */
+       public function __construct( $list, $type = '', $user = '', $title = '', $pattern = '', 
+               $conds = array(), $year = false, $month = false, $tagFilter = '' ) 
+       {
                parent::__construct();
                $this->mConds = $conds;
 
                $this->mLogEventsList = $list;
 
-               $this->limitType( $type );
+               $this->limitType( $type ); // also excludes hidden types
                $this->limitUser( $user );
                $this->limitTitle( $title, $pattern );
-               $this->getDateCond( $y, $m );
+               $this->getDateCond( $year, $month );
+               $this->mTagFilter = $tagFilter;
        }
 
-       function getDefaultQuery() {
+       public function getDefaultQuery() {
                $query = parent::getDefaultQuery();
                $query['type'] = $this->type;
+               $query['user'] = $this->user;
                $query['month'] = $this->mMonth;
                $query['year'] = $this->mYear;
                return $query;
@@ -497,11 +523,16 @@ class LogPager extends ReverseChronologicalPager {
        public function getFilterParams() {
                global $wgFilterLogTypes, $wgUser, $wgRequest;
                $filters = array();
+               if( $this->type ) {
+                       return $filters;
+               }
                foreach( $wgFilterLogTypes as $type => $default ) {
                        // Avoid silly filtering
-                       if( $type !== $this->type && ($type !== 'patrol' || $wgUser->useNPPatrol()) ) {
-                               $filters[$type] = $wgRequest->getInt( "hide{$type}log", $default );
-                               $this->mConds[] = 'log_type != '.$this->mDb->addQuotes( $this->mDb->strencode($type) );
+                       if( $type !== 'patrol' || $wgUser->useNPPatrol() ) {
+                               $hide = $wgRequest->getInt( "hide_{$type}_log", $default );
+                               $filters[$type] = $hide;
+                               if( $hide )
+                                       $this->mConds[] = 'log_type != ' . $this->mDb->addQuotes( $type );
                        }
                }
                return $filters;
@@ -510,33 +541,36 @@ class LogPager extends ReverseChronologicalPager {
        /**
         * Set the log reader to return only entries of the given type.
         * Type restrictions enforced here
-        * @param string $type A log type ('upload', 'delete', etc)
-        * @private
+        * @param $types String or array: Log types ('upload', 'delete', etc)
         */
-       private function limitType( $type ) {
+       private function limitType( $types ) {
                global $wgLogRestrictions, $wgUser;
+               // If $types is not an array, make it an array
+               $types = (array)$types;
                // Don't even show header for private logs; don't recognize it...
-               if( isset($wgLogRestrictions[$type]) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
-                       $type = '';
+               foreach ( $types as $type ) {
+                       if( isset( $wgLogRestrictions[$type] ) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
+                               $types = array_diff( $types, array( $type ) );
+                       }
                }
-               // Don't show private logs to unpriviledged users
-               $hideLogs = LogEventsList::getExcludeClause( $this->mDb );
+               // Don't show private logs to unprivileged users.
+               // Also, only show them upon specific request to avoid suprises.
+               $audience = $types ? 'user' : 'public';
+               $hideLogs = LogEventsList::getExcludeClause( $this->mDb, $audience );
                if( $hideLogs !== false ) {
                        $this->mConds[] = $hideLogs;
                }
-               if( empty($type) ) {
-                       return false;
+               if( $types ) {
+                       $this->type = $types;
+                       $this->mConds['log_type'] = $types;
                }
-               $this->type = $type;
-               $this->mConds['log_type'] = $type;
        }
 
        /**
         * Set the log reader to return only entries by the given user.
-        * @param string $name (In)valid user name
-        * @private
+        * @param $name String: (In)valid user name
         */
-       function limitUser( $name ) {
+       private function limitUser( $name ) {
                if( $name == '' ) {
                        return false;
                }
@@ -551,7 +585,12 @@ class LogPager extends ReverseChronologicalPager {
                           but for now it won't pass anywhere behind the optimizer */
                        $this->mConds[] = "NULL";
                } else {
+                       global $wgUser;
                        $this->mConds['log_user'] = $userid;
+                       // Paranoia: avoid brute force searches (bug 17342)
+                       if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+                               $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_USER . ' = 0';
+                       }
                        $this->user = $usertitle->getText();
                }
        }
@@ -559,11 +598,11 @@ class LogPager extends ReverseChronologicalPager {
        /**
         * Set the log reader to return only entries affecting the given page.
         * (For the block and rights logs, this is a user page.)
-        * @param string $page Title name as text
-        * @private
+        * @param $page String: Title name as text
+        * @param $pattern String
         */
-       function limitTitle( $page, $pattern ) {
-               global $wgMiserMode;
+       private function limitTitle( $page, $pattern ) {
+               global $wgMiserMode, $wgUser;
 
                $title = Title::newFromText( $page );
                if( strlen($page) == 0 || !$title instanceof Title )
@@ -592,9 +631,13 @@ class LogPager extends ReverseChronologicalPager {
                        $this->mConds['log_namespace'] = $ns;
                        $this->mConds['log_title'] = $title->getDBkey();
                }
+               // Paranoia: avoid brute force searches (bug 17342)
+               if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+                       $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_ACTION . ' = 0';
+               }
        }
 
-       function getQueryInfo() {
+       public function getQueryInfo() {
                $this->mConds[] = 'user_id = log_user';
                # Don't use the wrong logging index
                if( $this->title || $this->pattern || $this->user ) {
@@ -604,20 +647,26 @@ class LogPager extends ReverseChronologicalPager {
                } else {
                        $index = array( 'USE INDEX' => array( 'logging' => 'times' ) );
                }
-               return array(
+               $info = array(
                        'tables' => array( 'logging', 'user' ),
                        'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', 'log_title', 'log_params',
                                'log_comment', 'log_id', 'log_deleted', 'log_timestamp', 'user_name', 'user_editcount' ),
                        'conds' => $this->mConds,
-                       'options' => $index
+                       'options' => $index,
+                       'join_conds' => array( 'user' => array( 'INNER JOIN', 'user_id=log_user' ) ),
                );
+
+               ChangeTags::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'],
+                       $info['join_conds'], $info['options'], $this->mTagFilter );
+
+               return $info;
        }
 
        function getIndexField() {
                return 'log_timestamp';
        }
 
-       function getStartBody() {
+       public function getStartBody() {
                wfProfileIn( __METHOD__ );
                # Do a link batch query
                if( $this->getNumRows() > 0 ) {
@@ -634,7 +683,7 @@ class LogPager extends ReverseChronologicalPager {
                return '';
        }
 
-       function formatRow( $row ) {
+       public function formatRow( $row ) {
                return $this->mLogEventsList->logLine( $row );
        }
 
@@ -661,6 +710,10 @@ class LogPager extends ReverseChronologicalPager {
        public function getMonth() {
                return $this->mMonth;
        }
+
+       public function getTagFilter() {
+               return $this->mTagFilter;
+       }
 }
 
 /**
@@ -670,26 +723,28 @@ class LogPager extends ReverseChronologicalPager {
 class LogReader {
        var $pager;
        /**
-        * @param WebRequest $request For internal use use a FauxRequest object to pass arbitrary parameters.
+        * @param $request WebRequest: for internal use use a FauxRequest object to pass arbitrary parameters.
         */
        function __construct( $request ) {
                global $wgUser, $wgOut;
+               wfDeprecated(__METHOD__);
                # Get parameters
                $type = $request->getVal( 'type' );
                $user = $request->getText( 'user' );
                $title = $request->getText( 'page' );
                $pattern = $request->getBool( 'pattern' );
-               $y = $request->getIntOrNull( 'year' );
-               $m = $request->getIntOrNull( 'month' );
+               $year = $request->getIntOrNull( 'year' );
+               $month = $request->getIntOrNull( 'month' );
+               $tagFilter = $request->getVal( 'tagfilter' );
                # Don't let the user get stuck with a certain date
                $skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
                if( $skip ) {
-                       $y = '';
-                       $m = '';
+                       $year = '';
+                       $month = '';
                }
                # Use new list class to output results
                $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
-               $this->pager = new LogPager( $loglist, $type, $user, $title, $pattern, $y, $m );
+               $this->pager = new LogPager( $loglist, $type, $user, $title, $pattern, $year, $month, $tagFilter );
        }
 
        /**
@@ -707,17 +762,20 @@ class LogReader {
  */
 class LogViewer {
        const NO_ACTION_LINK = 1;
+
        /**
-        * @var LogReader $reader
+        * LogReader object
         */
        var $reader;
+
        /**
-        * @param LogReader &$reader where to get our data from
-        * @param integer $flags Bitwise combination of flags:
+        * @param &$reader LogReader: where to get our data from
+        * @param $flags Integer: Bitwise combination of flags:
         *     LogEventsList::NO_ACTION_LINK   Don't show restore/unblock/block links
         */
        function __construct( &$reader, $flags = 0 ) {
                global $wgUser;
+               wfDeprecated(__METHOD__);
                $this->reader =& $reader;
                $this->reader->pager->mLogEventsList->flags = $flags;
                # Aliases for shorter code...
@@ -753,7 +811,7 @@ class LogViewer {
         * Output just the list of entries given by the linked LogReader,
         * with extraneous UI elements. Use for displaying log fragments in
         * another page (eg at Special:Undelete)
-        * @param OutputPage $out where to send output
+        * @param $out OutputPage: where to send output
         */
        public function showList( &$out ) {
                $logBody = $this->pager->getBody();