2008-04-02 05:48:16 +00:00
|
|
|
<?php
|
|
|
|
|
# Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2008 Aaron Schulz
|
|
|
|
|
# http://www.mediawiki.org/
|
|
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
# http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
|
2008-04-02 17:43:57 +00:00
|
|
|
class LogEventsList {
|
2008-04-02 05:48:16 +00:00
|
|
|
const NO_ACTION_LINK = 1;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
private $skin;
|
2008-04-12 06:11:09 +00:00
|
|
|
private $out;
|
2008-04-02 16:24:30 +00:00
|
|
|
public $flags;
|
2008-04-02 05:48:16 +00:00
|
|
|
|
2008-12-24 00:09:19 +00:00
|
|
|
public function __construct( $skin, $out, $flags = 0 ) {
|
Prevent E_STRICT warning on editing a non-existent page / starting a new page:
-------------------------------
Strict Standards: Only variables should be passed by reference in includes/EditPage.php on line 2233
EditPage.showDeletionLog(Object:OutputPage) # line 685, file: includes/EditPage.php
EditPage.showIntro() # line 450, file: includes/EditPage.php
EditPage.edit() # line 348, file: includes/EditPage.php
EditPage.submit() # line 490, file: includes/Wiki.php
MediaWiki.performAction(Object:OutputPage, Object:Article, Object:Title, Object:User, Object:WebRequest) # line 59, file: includes/Wiki.php
MediaWiki.initialize(Object:Title, Object:Article, Object:OutputPage, Object:User, Object:WebRequest) # line 92, file: index.php
-------------------------------
2008-06-02 06:44:05 +00:00
|
|
|
$this->skin = $skin;
|
|
|
|
|
$this->out = $out;
|
2008-04-02 05:48:16 +00:00
|
|
|
$this->flags = $flags;
|
|
|
|
|
$this->preCacheMessages();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* As we use the same small set of messages in various methods and that
|
|
|
|
|
* they are called often, we call them once and save them in $this->message
|
|
|
|
|
*/
|
|
|
|
|
private function preCacheMessages() {
|
|
|
|
|
// Precache various messages
|
|
|
|
|
if( !isset( $this->message ) ) {
|
2008-12-26 12:07:42 +00:00
|
|
|
$messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink',
|
2009-05-30 21:17:17 +00:00
|
|
|
'revertmove', 'undeletelink', 'undeleteviewlink', 'revdel-restore', 'rev-delundel', 'hist', 'diff',
|
2009-03-22 01:07:42 +00:00
|
|
|
'pipe-separator' );
|
2008-12-24 00:09:19 +00:00
|
|
|
foreach( $messages as $msg ) {
|
2009-02-10 13:04:18 +00:00
|
|
|
$this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
|
|
|
|
* Set page title and show header for this log type
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $type String
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-12 06:11:09 +00:00
|
|
|
public function showHeader( $type ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
if( LogPage::isLogType( $type ) ) {
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->out->setPageTitle( LogPage::logName( $type ) );
|
2008-11-06 22:20:29 +00:00
|
|
|
$this->out->addHTML( LogPage::logHeader( $type ) );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show options for the log list
|
2009-05-02 14:34:45 +00:00
|
|
|
* @param $types string or Array
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $user String
|
|
|
|
|
* @param $page String
|
|
|
|
|
* @param $pattern String
|
|
|
|
|
* @param $year Integer: year
|
|
|
|
|
* @param $month Integer: month
|
2009-02-12 19:02:14 +00:00
|
|
|
* @param $filter: array
|
|
|
|
|
* @param $tagFilter: array?
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2009-05-02 14:34:45 +00:00
|
|
|
public function showOptions( $types=array(), $user='', $page='', $pattern='', $year='',
|
|
|
|
|
$month = '', $filter = null, $tagFilter='' )
|
2008-11-04 00:33:09 +00:00
|
|
|
{
|
2008-04-02 05:48:16 +00:00
|
|
|
global $wgScript, $wgMiserMode;
|
|
|
|
|
$action = htmlspecialchars( $wgScript );
|
|
|
|
|
$title = SpecialPage::getTitleFor( 'Log' );
|
|
|
|
|
$special = htmlspecialchars( $title->getPrefixedDBkey() );
|
2009-05-02 14:34:45 +00:00
|
|
|
// For B/C, we take strings, but make sure they are converted...
|
|
|
|
|
$types = ($types === '') ? array() : (array)$types;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-01-30 23:24:29 +00:00
|
|
|
$tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
|
|
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->out->addHTML( "<form action=\"$action\" method=\"get\"><fieldset>" .
|
2008-04-02 05:48:16 +00:00
|
|
|
Xml::element( 'legend', array(), wfMsg( 'log' ) ) .
|
|
|
|
|
Xml::hidden( 'title', $special ) . "\n" .
|
2009-05-02 14:34:45 +00:00
|
|
|
$this->getTypeMenu( $types ) . "\n" .
|
2008-04-02 05:48:16 +00:00
|
|
|
$this->getUserInput( $user ) . "\n" .
|
|
|
|
|
$this->getTitleInput( $page ) . "\n" .
|
|
|
|
|
( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) .
|
2009-02-12 19:23:14 +00:00
|
|
|
"<p>" . Xml::dateMenu( $year, $month ) . "\n" .
|
2009-01-30 23:24:29 +00:00
|
|
|
( $tagSelector ? Xml::tags( 'p', null, implode( ' ', $tagSelector ) ) :'' ). "\n" .
|
2009-05-02 14:34:45 +00:00
|
|
|
( $filter ? "</p><p>".$this->getFilterLinks( $filter )."\n" : "" ) . "\n" .
|
2008-04-12 06:11:09 +00:00
|
|
|
Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
|
2008-10-27 07:18:36 +00:00
|
|
|
"</fieldset></form>"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-02 14:34:45 +00:00
|
|
|
/**
|
|
|
|
|
* @param $filter Array
|
|
|
|
|
* @return String: Formatted HTML
|
|
|
|
|
*/
|
|
|
|
|
private function getFilterLinks( $filter ) {
|
2009-02-10 13:10:43 +00:00
|
|
|
global $wgTitle, $wgLang;
|
2008-10-27 07:18:36 +00:00
|
|
|
// show/hide links
|
2008-11-04 00:33:09 +00:00
|
|
|
$messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
|
2008-10-27 07:18:36 +00:00
|
|
|
// Option value -> message mapping
|
|
|
|
|
$links = array();
|
2009-02-12 19:02:14 +00:00
|
|
|
$hiddens = ''; // keep track for "go" button
|
2008-10-27 07:18:36 +00:00
|
|
|
foreach( $filter as $type => $val ) {
|
2008-11-04 00:33:09 +00:00
|
|
|
$hideVal = 1 - intval($val);
|
|
|
|
|
$link = $this->skin->makeKnownLinkObj( $wgTitle, $messages[$hideVal],
|
|
|
|
|
wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() )
|
2008-10-27 07:18:36 +00:00
|
|
|
);
|
2008-11-04 00:33:09 +00:00
|
|
|
$links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
|
2009-02-12 19:02:14 +00:00
|
|
|
$hiddens .= Xml::hidden( "hide_{$type}_log", $val ) . "\n";
|
2008-10-27 07:18:36 +00:00
|
|
|
}
|
|
|
|
|
// Build links
|
2009-02-12 19:02:14 +00:00
|
|
|
return '<small>'.$wgLang->pipeList( $links ) . '</small>' . $hiddens;
|
2008-10-27 07:18:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getDefaultQuery() {
|
|
|
|
|
if ( !isset( $this->mDefaultQuery ) ) {
|
|
|
|
|
$this->mDefaultQuery = $_GET;
|
|
|
|
|
unset( $this->mDefaultQuery['title'] );
|
|
|
|
|
unset( $this->mDefaultQuery['dir'] );
|
|
|
|
|
unset( $this->mDefaultQuery['offset'] );
|
|
|
|
|
unset( $this->mDefaultQuery['limit'] );
|
|
|
|
|
unset( $this->mDefaultQuery['order'] );
|
|
|
|
|
unset( $this->mDefaultQuery['month'] );
|
|
|
|
|
unset( $this->mDefaultQuery['year'] );
|
|
|
|
|
}
|
|
|
|
|
return $this->mDefaultQuery;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2009-05-02 14:34:45 +00:00
|
|
|
* @param $queryTypes Array
|
2008-12-07 19:56:02 +00:00
|
|
|
* @return String: Formatted HTML
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2009-05-02 14:34:45 +00:00
|
|
|
private function getTypeMenu( $queryTypes ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
global $wgLogRestrictions, $wgUser;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
$html = "<select name='type'>\n";
|
2008-04-02 05:48:16 +00:00
|
|
|
|
|
|
|
|
$validTypes = LogPage::validTypes();
|
2008-11-04 00:33:09 +00:00
|
|
|
$typesByName = array(); // Temporary array
|
2008-04-02 05:48:16 +00:00
|
|
|
|
|
|
|
|
// First pass to load the log names
|
|
|
|
|
foreach( $validTypes as $type ) {
|
|
|
|
|
$text = LogPage::logName( $type );
|
2008-11-04 00:33:09 +00:00
|
|
|
$typesByName[$text] = $type;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Second pass to sort by name
|
2008-11-04 00:33:09 +00:00
|
|
|
ksort($typesByName);
|
2008-04-02 05:48:16 +00:00
|
|
|
|
2009-05-02 14:34:45 +00:00
|
|
|
// Note the query type
|
|
|
|
|
$queryType = count($queryTypes) == 1 ? $queryTypes[0] : '';
|
2008-04-02 05:48:16 +00:00
|
|
|
// Third pass generates sorted XHTML content
|
2008-11-04 00:33:09 +00:00
|
|
|
foreach( $typesByName as $text => $type ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$selected = ($type == $queryType);
|
|
|
|
|
// Restricted types
|
|
|
|
|
if ( isset($wgLogRestrictions[$type]) ) {
|
|
|
|
|
if ( $wgUser->isAllowed( $wgLogRestrictions[$type] ) ) {
|
2008-04-12 06:11:09 +00:00
|
|
|
$html .= Xml::option( $text, $type, $selected ) . "\n";
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2008-04-12 06:11:09 +00:00
|
|
|
$html .= Xml::option( $text, $type, $selected ) . "\n";
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
$html .= '</select>';
|
|
|
|
|
return $html;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $user String
|
|
|
|
|
* @return String: Formatted HTML
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
|
|
|
|
private function getUserInput( $user ) {
|
2009-03-22 16:36:37 +00:00
|
|
|
return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'mw-log-user', 15, $user );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $title String
|
|
|
|
|
* @return String: Formatted HTML
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
|
|
|
|
private function getTitleInput( $title ) {
|
2009-03-22 16:36:37 +00:00
|
|
|
return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'mw-log-page', 20, $title );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
|
|
|
|
* @return boolean Checkbox
|
|
|
|
|
*/
|
|
|
|
|
private function getTitlePattern( $pattern ) {
|
2008-04-12 06:11:09 +00:00
|
|
|
return '<span style="white-space: nowrap">' .
|
|
|
|
|
Xml::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $pattern ) .
|
|
|
|
|
'</span>';
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 17:43:57 +00:00
|
|
|
public function beginLogEventsList() {
|
2008-04-08 18:20:28 +00:00
|
|
|
return "<ul>\n";
|
2008-04-02 07:10:41 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 17:43:57 +00:00
|
|
|
public function endLogEventsList() {
|
2008-04-08 18:20:28 +00:00
|
|
|
return "</ul>\n";
|
2008-04-02 07:10:41 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-12-07 19:56:02 +00:00
|
|
|
/**
|
|
|
|
|
* @param $row Row: a single row from the result set
|
|
|
|
|
* @return String: Formatted HTML list item
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
|
|
|
|
public function logLine( $row ) {
|
|
|
|
|
global $wgLang, $wgUser, $wgContLang;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
$title = Title::makeTitle( $row->log_namespace, $row->log_title );
|
2009-01-28 19:08:18 +00:00
|
|
|
$classes = array( "mw-logline-{$row->log_type}" );
|
2008-04-02 05:48:16 +00:00
|
|
|
$time = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->log_timestamp), true );
|
|
|
|
|
// User links
|
2008-04-02 17:11:58 +00:00
|
|
|
if( self::isDeleted($row,LogPage::DELETED_USER) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$userLink = '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
|
|
|
|
|
} else {
|
2008-04-08 21:22:44 +00:00
|
|
|
$userLink = $this->skin->userLink( $row->log_user, $row->user_name ) .
|
2008-04-08 23:30:36 +00:00
|
|
|
$this->skin->userToolLinks( $row->log_user, $row->user_name, true, 0, $row->user_editcount );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
// Comment
|
2008-04-02 18:46:32 +00:00
|
|
|
if( self::isDeleted($row,LogPage::DELETED_COMMENT) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$comment = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
|
|
|
|
|
} else {
|
|
|
|
|
$comment = $wgContLang->getDirMark() . $this->skin->commentBlock( $row->log_comment );
|
|
|
|
|
}
|
|
|
|
|
// Extract extra parameters
|
|
|
|
|
$paramArray = LogPage::extractParams( $row->log_params );
|
|
|
|
|
$revert = $del = '';
|
|
|
|
|
// Some user can hide log items and have review links
|
2009-04-04 17:00:01 +00:00
|
|
|
if( !($this->flags & self::NO_ACTION_LINK) && $wgUser->isAllowed( 'deleterevision' ) ) {
|
2008-11-04 00:33:09 +00:00
|
|
|
$del = $this->getShowHideLinks( $row ) . ' ';
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
// Add review links and such...
|
2008-09-05 17:34:44 +00:00
|
|
|
if( ($this->flags & self::NO_ACTION_LINK) || ($row->log_deleted & LogPage::DELETED_ACTION) ) {
|
|
|
|
|
// Action text is suppressed...
|
2008-12-16 19:20:35 +00:00
|
|
|
} else if( self::typeAction($row,'move','move','move') && !empty($paramArray[0]) ) {
|
2008-09-05 17:34:44 +00:00
|
|
|
$destTitle = Title::newFromText( $paramArray[0] );
|
|
|
|
|
if( $destTitle ) {
|
|
|
|
|
$revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ),
|
|
|
|
|
$this->message['revertmove'],
|
|
|
|
|
'wpOldTitle=' . urlencode( $destTitle->getPrefixedDBkey() ) .
|
|
|
|
|
'&wpNewTitle=' . urlencode( $title->getPrefixedDBkey() ) .
|
|
|
|
|
'&wpReason=' . urlencode( wfMsgForContent( 'revertmove' ) ) .
|
|
|
|
|
'&wpMovetalk=0' ) . ')';
|
|
|
|
|
}
|
|
|
|
|
// Show undelete link
|
2009-05-30 21:17:17 +00:00
|
|
|
} else if( self::typeAction($row,array('delete','suppress'),'delete','deletedhistory') ) {
|
|
|
|
|
if( !$wgUser->isAllowed( 'undelete' ) )
|
|
|
|
|
$viewdeleted = $this->message['undeleteviewlink'];
|
|
|
|
|
else
|
|
|
|
|
$viewdeleted = $this->message['undeletelink'];
|
2008-09-05 17:34:44 +00:00
|
|
|
$revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Undelete' ),
|
2009-05-30 21:17:17 +00:00
|
|
|
$viewdeleted, 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')';
|
2008-12-16 08:51:56 +00:00
|
|
|
// Show unblock/change block link
|
2008-12-16 19:20:35 +00:00
|
|
|
} else if( self::typeAction($row,array('block','suppress'),array('block','reblock'),'block') ) {
|
2008-12-16 08:51:56 +00:00
|
|
|
$revert = '(' .
|
|
|
|
|
$this->skin->link( SpecialPage::getTitleFor( 'Ipblocklist' ),
|
|
|
|
|
$this->message['unblocklink'],
|
|
|
|
|
array(),
|
2008-12-17 00:00:55 +00:00
|
|
|
array( 'action' => 'unblock', 'ip' => $row->log_title ),
|
2008-12-16 08:51:56 +00:00
|
|
|
'known' )
|
2009-02-09 09:13:30 +00:00
|
|
|
. $this->message['pipe-separator'] .
|
2008-12-17 00:00:55 +00:00
|
|
|
$this->skin->link( SpecialPage::getTitleFor( 'Blockip', $row->log_title ),
|
2008-12-16 08:51:56 +00:00
|
|
|
$this->message['change-blocklink'],
|
|
|
|
|
array(), array(), 'known' ) .
|
|
|
|
|
')';
|
2008-09-05 17:34:44 +00:00
|
|
|
// Show change protection link
|
2008-12-26 12:07:42 +00:00
|
|
|
} 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' ) ) {
|
2009-02-09 09:13:30 +00:00
|
|
|
$revert .= $this->message['pipe-separator'] .
|
2008-12-26 12:07:42 +00:00
|
|
|
$this->skin->link( $title,
|
|
|
|
|
$this->message['protect_change'],
|
|
|
|
|
array(),
|
|
|
|
|
array( 'action' => 'protect' ),
|
|
|
|
|
'known' );
|
2008-09-05 17:34:44 +00:00
|
|
|
}
|
2008-12-26 12:07:42 +00:00
|
|
|
$revert .= ')';
|
2008-09-05 17:34:44 +00:00
|
|
|
// Show unmerge link
|
2008-12-16 19:20:35 +00:00
|
|
|
} else if( self::typeAction($row,'merge','merge','mergehistory') ) {
|
2008-09-05 17:34:44 +00:00
|
|
|
$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
|
2008-12-16 19:20:35 +00:00
|
|
|
} else if( self::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
|
2009-04-10 20:01:10 +00:00
|
|
|
if( count($paramArray) >= 2 ) {
|
2008-09-05 17:34:44 +00:00
|
|
|
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
|
|
|
|
|
// Different revision types use different URL params...
|
|
|
|
|
$key = $paramArray[0];
|
2009-03-25 17:52:40 +00:00
|
|
|
// $paramArray[1] is a CVS of the IDs
|
2008-09-05 17:34:44 +00:00
|
|
|
$Ids = explode( ',', $paramArray[1] );
|
2009-03-25 17:52:40 +00:00
|
|
|
$query = urlencode($paramArray[1]);
|
2009-03-22 01:07:42 +00:00
|
|
|
$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" );
|
|
|
|
|
}
|
|
|
|
|
// View/modify link...
|
2009-03-27 10:20:53 +00:00
|
|
|
$revert[] = $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
|
|
|
|
|
'target='.$title->getPrefixedUrl()."&$key=$query" );
|
2009-03-25 17:52:40 +00:00
|
|
|
// Pipe links
|
2009-03-22 01:07:42 +00:00
|
|
|
$revert = '(' . implode(' | ',$revert) . ')';
|
2008-09-05 17:34:44 +00:00
|
|
|
}
|
|
|
|
|
// Hidden log items, give review link
|
2008-12-16 19:20:35 +00:00
|
|
|
} else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
|
2009-04-10 20:01:10 +00:00
|
|
|
if( count($paramArray) >= 1 ) {
|
2008-09-05 17:34:44 +00:00
|
|
|
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
|
2009-03-25 17:52:40 +00:00
|
|
|
// $paramArray[1] is a CVS of the IDs
|
2008-09-05 17:34:44 +00:00
|
|
|
$Ids = explode( ',', $paramArray[0] );
|
2009-03-25 17:52:40 +00:00
|
|
|
$query = urlencode($paramArray[0]);
|
2008-09-05 17:34:44 +00:00
|
|
|
// Link to each hidden object ID, $paramArray[1] is the url param
|
|
|
|
|
$revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
|
2009-03-25 17:52:40 +00:00
|
|
|
'target='.$title->getPrefixedUrl()."&logid=$query" ) . ')';
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-09-13 00:29:33 +00:00
|
|
|
// Self-created users
|
|
|
|
|
} else if( self::typeAction($row,'newusers','create2') ) {
|
|
|
|
|
if( isset( $paramArray[0] ) ) {
|
|
|
|
|
$revert = $this->skin->userToolLinks( $paramArray[0], $title->getDBkey(), true );
|
|
|
|
|
} else {
|
|
|
|
|
# Fall back to a blue contributions link
|
|
|
|
|
$revert = $this->skin->userToolLinks( 1, $title->getDBkey() );
|
|
|
|
|
}
|
|
|
|
|
if( $time < '20080129000000' ) {
|
2008-12-24 00:09:19 +00:00
|
|
|
# Suppress $comment from old entries (before 2008-01-29),
|
|
|
|
|
# not needed and can contain incorrect links
|
2008-09-13 00:29:33 +00:00
|
|
|
$comment = '';
|
|
|
|
|
}
|
|
|
|
|
// Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
|
2008-09-05 17:34:44 +00:00
|
|
|
} else {
|
|
|
|
|
wfRunHooks( 'LogLine', array( $row->log_type, $row->log_action, $title, $paramArray,
|
|
|
|
|
&$comment, &$revert, $row->log_timestamp ) );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
// Event description
|
2008-04-02 19:01:41 +00:00
|
|
|
if( self::isDeleted($row,LogPage::DELETED_ACTION) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
|
|
|
|
|
} else {
|
2008-12-24 00:09:19 +00:00
|
|
|
$action = LogPage::actionText( $row->log_type, $row->log_action, $title,
|
|
|
|
|
$this->skin, $paramArray, true );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-01-28 19:08:18 +00:00
|
|
|
// Any tags...
|
|
|
|
|
list($tagDisplay, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'logevent' );
|
|
|
|
|
$classes = array_merge( $classes, $newClasses );
|
|
|
|
|
|
2008-12-22 19:52:49 +00:00
|
|
|
if( $revert != '' ) {
|
|
|
|
|
$revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-22 09:35:48 +00:00
|
|
|
$time = htmlspecialchars( $time );
|
|
|
|
|
|
2009-01-28 19:08:18 +00:00
|
|
|
return Xml::tags( 'li', array( "class" => implode( ' ', $classes ) ),
|
|
|
|
|
$del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert . " $tagDisplay" ) . "\n";
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $row Row
|
2008-04-13 15:18:59 +00:00
|
|
|
* @return string
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-11-04 00:33:09 +00:00
|
|
|
private function getShowHideLinks( $row ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
|
|
|
|
|
// If event was hidden from sysops
|
2008-04-02 17:11:58 +00:00
|
|
|
if( !self::userCan( $row, LogPage::DELETED_RESTRICTED ) ) {
|
2009-03-27 20:34:16 +00:00
|
|
|
$del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
|
|
|
|
|
'('.$this->message['rev-delundel'].')' );
|
2008-04-02 05:48:16 +00:00
|
|
|
} else if( $row->log_type == 'suppress' ) {
|
2009-03-27 20:34:16 +00:00
|
|
|
$del = ''; // No one should be hiding from the oversight log
|
2008-04-02 05:48:16 +00:00
|
|
|
} else {
|
2008-04-16 18:44:15 +00:00
|
|
|
$target = SpecialPage::getTitleFor( 'Log', $row->log_type );
|
2009-04-03 12:58:39 +00:00
|
|
|
$page = Title::makeTitle( $row->log_namespace, $row->log_title );
|
|
|
|
|
$query = array( 'target' => $target->getPrefixedDBkey(),
|
|
|
|
|
'logid' => $row->log_id, 'page' => $page->getPrefixedDBkey() );
|
2009-03-27 20:34:16 +00:00
|
|
|
$del = $this->skin->revDeleteLink( $query,
|
|
|
|
|
self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2009-01-18 21:07:09 +00:00
|
|
|
return $del;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 15:18:59 +00:00
|
|
|
/**
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $row Row
|
|
|
|
|
* @param $type Mixed: string/array
|
|
|
|
|
* @param $action Mixed: string/array
|
2008-12-16 19:20:35 +00:00
|
|
|
* @param $right string
|
2008-04-13 15:18:59 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2008-12-16 19:20:35 +00:00
|
|
|
public static function typeAction( $row, $type, $action, $right='' ) {
|
2009-03-27 20:34:16 +00:00
|
|
|
$match = is_array($type) ?
|
|
|
|
|
in_array($row->log_type,$type) : $row->log_type == $type;
|
2008-09-05 17:34:44 +00:00
|
|
|
if( $match ) {
|
2008-12-16 19:20:35 +00:00
|
|
|
$match = is_array($action) ?
|
|
|
|
|
in_array($row->log_action,$action) : $row->log_action == $action;
|
|
|
|
|
if( $match && $right ) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
$match = $wgUser->isAllowed( $right );
|
|
|
|
|
}
|
2008-04-16 18:05:54 +00:00
|
|
|
}
|
2008-09-05 17:34:44 +00:00
|
|
|
return $match;
|
2008-04-13 15:18:59 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 17:11:58 +00:00
|
|
|
/**
|
|
|
|
|
* Determine if the current user is allowed to view a particular
|
|
|
|
|
* field of this log row, if it's marked as deleted.
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $row Row
|
|
|
|
|
* @param $field Integer
|
|
|
|
|
* @return Boolean
|
2008-04-02 17:11:58 +00:00
|
|
|
*/
|
|
|
|
|
public static function userCan( $row, $field ) {
|
|
|
|
|
if( ( $row->log_deleted & $field ) == $field ) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
$permission = ( $row->log_deleted & LogPage::DELETED_RESTRICTED ) == LogPage::DELETED_RESTRICTED
|
2008-05-25 00:31:28 +00:00
|
|
|
? 'suppressrevision'
|
2008-04-02 17:11:58 +00:00
|
|
|
: 'deleterevision';
|
|
|
|
|
wfDebug( "Checking for $permission due to $field match on $row->log_deleted\n" );
|
|
|
|
|
return $wgUser->isAllowed( $permission );
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $row Row
|
|
|
|
|
* @param $field Integer: one of DELETED_* bitfield constants
|
|
|
|
|
* @return Boolean
|
2008-04-02 17:11:58 +00:00
|
|
|
*/
|
|
|
|
|
public static function isDeleted( $row, $field ) {
|
|
|
|
|
return ($row->log_deleted & $field) == $field;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 19:01:41 +00:00
|
|
|
/**
|
2008-04-02 20:20:47 +00:00
|
|
|
* Quick function to show a short log extract
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $out OutputPage
|
2009-05-02 14:34:45 +00:00
|
|
|
* @param $types String or Array
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $page String
|
|
|
|
|
* @param $user String
|
|
|
|
|
* @param $lim Integer
|
|
|
|
|
* @param $conds Array
|
2008-04-02 20:20:47 +00:00
|
|
|
*/
|
2009-05-02 14:34:45 +00:00
|
|
|
public static function showLogExtract( $out, $types=array(), $page='', $user='', $lim=0, $conds=array() ) {
|
2008-04-02 20:20:47 +00:00
|
|
|
global $wgUser;
|
|
|
|
|
# Insert list of top 50 or so items
|
2008-04-12 06:11:09 +00:00
|
|
|
$loglist = new LogEventsList( $wgUser->getSkin(), $out, 0 );
|
2009-05-02 14:34:45 +00:00
|
|
|
$pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
|
2008-10-18 23:36:41 +00:00
|
|
|
if( $lim > 0 ) $pager->mLimit = $lim;
|
2008-04-02 20:20:47 +00:00
|
|
|
$logBody = $pager->getBody();
|
|
|
|
|
if( $logBody ) {
|
|
|
|
|
$out->addHTML(
|
|
|
|
|
$loglist->beginLogEventsList() .
|
|
|
|
|
$logBody .
|
|
|
|
|
$loglist->endLogEventsList()
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$out->addWikiMsg( 'logempty' );
|
|
|
|
|
}
|
2008-09-17 02:50:03 +00:00
|
|
|
return $pager->getNumRows();
|
2008-09-05 22:46:46 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-12-07 19:56:02 +00:00
|
|
|
/**
|
2008-04-02 19:01:41 +00:00
|
|
|
* SQL clause to skip forbidden log types for this user
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $db Database
|
2009-03-03 23:47:16 +00:00
|
|
|
* @param $audience string, public/user
|
2008-12-07 19:56:02 +00:00
|
|
|
* @return mixed (string or false)
|
2008-04-02 19:01:41 +00:00
|
|
|
*/
|
2009-03-03 23:47:16 +00:00
|
|
|
public static function getExcludeClause( $db, $audience = 'public' ) {
|
2008-04-02 19:01:41 +00:00
|
|
|
global $wgLogRestrictions, $wgUser;
|
|
|
|
|
// Reset the array, clears extra "where" clauses when $par is used
|
|
|
|
|
$hiddenLogs = array();
|
2008-04-08 13:58:33 +00:00
|
|
|
// Don't show private logs to unprivileged users
|
2008-11-04 00:33:09 +00:00
|
|
|
foreach( $wgLogRestrictions as $logType => $right ) {
|
2009-03-03 23:47:16 +00:00
|
|
|
if( $audience == 'public' || !$wgUser->isAllowed($right) ) {
|
2008-11-04 00:33:09 +00:00
|
|
|
$safeType = $db->strencode( $logType );
|
|
|
|
|
$hiddenLogs[] = $safeType;
|
2008-04-02 19:01:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-04-08 13:58:33 +00:00
|
|
|
if( count($hiddenLogs) == 1 ) {
|
|
|
|
|
return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
|
2008-11-04 00:33:09 +00:00
|
|
|
} elseif( $hiddenLogs ) {
|
2008-04-08 13:58:33 +00:00
|
|
|
return 'log_type NOT IN (' . $db->makeList($hiddenLogs) . ')';
|
2008-04-02 19:01:41 +00:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Pager
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-02 16:24:30 +00:00
|
|
|
class LogPager extends ReverseChronologicalPager {
|
2009-05-02 14:34:45 +00:00
|
|
|
private $types = array(), $user = '', $title = '', $pattern = '';
|
|
|
|
|
private $typeCGI = '';
|
2008-04-02 17:43:57 +00:00
|
|
|
public $mLogEventsList;
|
2008-12-07 19:56:02 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
2008-12-07 19:56:02 +00:00
|
|
|
* constructor
|
|
|
|
|
* @param $list LogEventsList
|
2009-05-02 14:34:45 +00:00
|
|
|
* @param $types String or Array
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $user String
|
|
|
|
|
* @param $title String
|
|
|
|
|
* @param $pattern String
|
|
|
|
|
* @param $conds Array
|
|
|
|
|
* @param $year Integer
|
|
|
|
|
* @param $month Integer
|
|
|
|
|
*/
|
2009-05-02 14:34:45 +00:00
|
|
|
public function __construct( $list, $types = array(), $user = '', $title = '', $pattern = '',
|
2009-01-28 19:08:18 +00:00
|
|
|
$conds = array(), $year = false, $month = false, $tagFilter = '' )
|
2008-11-04 00:33:09 +00:00
|
|
|
{
|
2008-04-02 16:24:30 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
$this->mConds = $conds;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->mLogEventsList = $list;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-05-02 14:34:45 +00:00
|
|
|
$this->limitType( $types ); // also excludes hidden types
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->limitUser( $user );
|
|
|
|
|
$this->limitTitle( $title, $pattern );
|
2008-11-04 00:33:09 +00:00
|
|
|
$this->getDateCond( $year, $month );
|
2009-01-28 19:08:18 +00:00
|
|
|
$this->mTagFilter = $tagFilter;
|
2008-04-08 20:51:19 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-10-27 14:03:05 +00:00
|
|
|
public function getDefaultQuery() {
|
2008-04-08 20:51:19 +00:00
|
|
|
$query = parent::getDefaultQuery();
|
2009-05-02 14:34:45 +00:00
|
|
|
$query['type'] = $this->typeCGI; // arrays won't work here
|
2009-02-18 04:49:25 +00:00
|
|
|
$query['user'] = $this->user;
|
|
|
|
|
$query['month'] = $this->mMonth;
|
|
|
|
|
$query['year'] = $this->mYear;
|
2008-04-08 20:51:19 +00:00
|
|
|
return $query;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-05-02 14:34:45 +00:00
|
|
|
// Call ONLY after calling $this->limitType() already!
|
2008-10-27 07:18:36 +00:00
|
|
|
public function getFilterParams() {
|
|
|
|
|
global $wgFilterLogTypes, $wgUser, $wgRequest;
|
|
|
|
|
$filters = array();
|
2009-05-02 14:34:45 +00:00
|
|
|
if( count($this->types) ) {
|
2008-10-27 07:25:11 +00:00
|
|
|
return $filters;
|
|
|
|
|
}
|
2008-10-27 07:18:36 +00:00
|
|
|
foreach( $wgFilterLogTypes as $type => $default ) {
|
|
|
|
|
// Avoid silly filtering
|
2008-10-27 07:25:11 +00:00
|
|
|
if( $type !== 'patrol' || $wgUser->useNPPatrol() ) {
|
2008-11-04 00:33:09 +00:00
|
|
|
$hide = $wgRequest->getInt( "hide_{$type}_log", $default );
|
2008-10-27 07:23:10 +00:00
|
|
|
$filters[$type] = $hide;
|
|
|
|
|
if( $hide )
|
2008-11-04 00:43:39 +00:00
|
|
|
$this->mConds[] = 'log_type != ' . $this->mDb->addQuotes( $type );
|
2008-10-27 07:18:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $filters;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
|
|
|
|
* Set the log reader to return only entries of the given type.
|
|
|
|
|
* Type restrictions enforced here
|
2009-05-04 13:30:57 +00:00
|
|
|
* @param $types String or array: Log types ('upload', 'delete', etc);
|
|
|
|
|
* empty string means no restriction
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2009-04-24 17:20:48 +00:00
|
|
|
private function limitType( $types ) {
|
2008-04-02 18:09:02 +00:00
|
|
|
global $wgLogRestrictions, $wgUser;
|
2009-04-24 17:20:48 +00:00
|
|
|
// If $types is not an array, make it an array
|
2009-05-02 13:42:51 +00:00
|
|
|
$types = ($types === '') ? array() : (array)$types;
|
2008-04-02 18:09:02 +00:00
|
|
|
// Don't even show header for private logs; don't recognize it...
|
2009-04-24 17:20:48 +00:00
|
|
|
foreach ( $types as $type ) {
|
|
|
|
|
if( isset( $wgLogRestrictions[$type] ) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
|
|
|
|
|
$types = array_diff( $types, array( $type ) );
|
|
|
|
|
}
|
2008-04-02 18:09:02 +00:00
|
|
|
}
|
2009-04-24 17:20:48 +00:00
|
|
|
// Don't show private logs to unprivileged users.
|
2009-03-03 23:47:16 +00:00
|
|
|
// Also, only show them upon specific request to avoid suprises.
|
2009-04-24 17:20:48 +00:00
|
|
|
$audience = $types ? 'user' : 'public';
|
2009-03-03 23:47:16 +00:00
|
|
|
$hideLogs = LogEventsList::getExcludeClause( $this->mDb, $audience );
|
2008-04-02 16:24:30 +00:00
|
|
|
if( $hideLogs !== false ) {
|
|
|
|
|
$this->mConds[] = $hideLogs;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2009-05-02 14:34:45 +00:00
|
|
|
if( count($types) ) {
|
|
|
|
|
$this->types = $types;
|
2009-04-24 17:20:48 +00:00
|
|
|
$this->mConds['log_type'] = $types;
|
2009-05-02 14:34:45 +00:00
|
|
|
// Set typeCGI; used in url param for paging
|
|
|
|
|
if( count($types) == 1 ) $this->typeCGI = $types[0];
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
|
|
|
|
* Set the log reader to return only entries by the given user.
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $name String: (In)valid user name
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-10-27 14:03:05 +00:00
|
|
|
private function limitUser( $name ) {
|
2008-04-02 16:24:30 +00:00
|
|
|
if( $name == '' ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
return false;
|
2008-04-02 16:24:30 +00:00
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
$usertitle = Title::makeTitleSafe( NS_USER, $name );
|
2008-04-02 16:24:30 +00:00
|
|
|
if( is_null($usertitle) ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
return false;
|
2008-04-02 16:24:30 +00:00
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
/* Fetch userid at first, if known, provides awesome query plan afterwards */
|
2008-04-08 23:30:36 +00:00
|
|
|
$userid = User::idFromName( $name );
|
2008-04-02 16:24:30 +00:00
|
|
|
if( !$userid ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
/* It should be nicer to abort query at all,
|
2008-04-02 05:48:16 +00:00
|
|
|
but for now it won't pass anywhere behind the optimizer */
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->mConds[] = "NULL";
|
|
|
|
|
} else {
|
2009-03-20 04:29:49 +00:00
|
|
|
global $wgUser;
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->mConds['log_user'] = $userid;
|
2009-02-04 18:54:59 +00:00
|
|
|
// Paranoia: avoid brute force searches (bug 17342)
|
2009-03-20 04:29:49 +00:00
|
|
|
if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
|
|
|
|
|
$this->mConds[] = 'log_deleted & ' . LogPage::DELETED_USER . ' = 0';
|
|
|
|
|
}
|
2008-04-08 22:54:15 +00:00
|
|
|
$this->user = $usertitle->getText();
|
2008-04-02 16:24:30 +00:00
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the log reader to return only entries affecting the given page.
|
|
|
|
|
* (For the block and rights logs, this is a user page.)
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $page String: Title name as text
|
|
|
|
|
* @param $pattern String
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-10-27 14:03:05 +00:00
|
|
|
private function limitTitle( $page, $pattern ) {
|
2009-03-20 04:29:49 +00:00
|
|
|
global $wgMiserMode, $wgUser;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
$title = Title::newFromText( $page );
|
2008-04-02 16:24:30 +00:00
|
|
|
if( strlen($page) == 0 || !$title instanceof Title )
|
2008-04-02 05:48:16 +00:00
|
|
|
return false;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->title = $title->getPrefixedText();
|
2008-04-02 05:48:16 +00:00
|
|
|
$ns = $title->getNamespace();
|
2008-07-10 18:05:52 +00:00
|
|
|
# Using the (log_namespace, log_title, log_timestamp) index with a
|
|
|
|
|
# range scan (LIKE) on the first two parts, instead of simple equality,
|
|
|
|
|
# makes it unusable for sorting. Sorted retrieval using another index
|
|
|
|
|
# would be possible, but then we might have to scan arbitrarily many
|
|
|
|
|
# nodes of that index. Therefore, we need to avoid this if $wgMiserMode
|
|
|
|
|
# is on.
|
|
|
|
|
#
|
|
|
|
|
# This is not a problem with simple title matches, because then we can
|
|
|
|
|
# use the page_time index. That should have no more than a few hundred
|
|
|
|
|
# log entries for even the busiest pages, so it can be safely scanned
|
|
|
|
|
# in full to satisfy an impossible condition on user or similar.
|
2008-04-02 16:24:30 +00:00
|
|
|
if( $pattern && !$wgMiserMode ) {
|
|
|
|
|
# use escapeLike to avoid expensive search patterns like 't%st%'
|
|
|
|
|
$safetitle = $this->mDb->escapeLike( $title->getDBkey() );
|
|
|
|
|
$this->mConds['log_namespace'] = $ns;
|
|
|
|
|
$this->mConds[] = "log_title LIKE '$safetitle%'";
|
2008-04-08 22:40:36 +00:00
|
|
|
$this->pattern = $pattern;
|
2008-04-02 05:48:16 +00:00
|
|
|
} else {
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->mConds['log_namespace'] = $ns;
|
|
|
|
|
$this->mConds['log_title'] = $title->getDBkey();
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2009-02-04 18:54:59 +00:00
|
|
|
// Paranoia: avoid brute force searches (bug 17342)
|
2009-03-20 04:29:49 +00:00
|
|
|
if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
|
|
|
|
|
$this->mConds[] = 'log_deleted & ' . LogPage::DELETED_ACTION . ' = 0';
|
|
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-10-27 14:03:05 +00:00
|
|
|
public function getQueryInfo() {
|
2009-05-13 22:03:32 +00:00
|
|
|
$tables = array( 'logging', 'user' );
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->mConds[] = 'user_id = log_user';
|
2009-05-14 19:49:33 +00:00
|
|
|
$groupBy = false;
|
2009-05-13 22:03:32 +00:00
|
|
|
# Add log_search table if there are conditions on it
|
|
|
|
|
if( array_key_exists('ls_field',$this->mConds) ) {
|
|
|
|
|
$tables[] = 'log_search';
|
|
|
|
|
$index = array( 'log_search' => 'PRIMARY', 'logging' => 'PRIMARY' );
|
2009-05-14 19:49:33 +00:00
|
|
|
$groupBy = 'ls_log_id';
|
2008-04-08 08:46:15 +00:00
|
|
|
# Don't use the wrong logging index
|
2009-05-13 22:03:32 +00:00
|
|
|
} else if( $this->title || $this->pattern || $this->user ) {
|
|
|
|
|
$index = array( 'logging' => array('page_time','user_time') );
|
2009-05-02 14:34:45 +00:00
|
|
|
} else if( $this->types ) {
|
2009-05-13 22:03:32 +00:00
|
|
|
$index = array( 'logging' => 'type_time' );
|
2008-04-08 08:46:15 +00:00
|
|
|
} else {
|
2009-05-13 22:03:32 +00:00
|
|
|
$index = array( 'logging' => 'times' );
|
2008-04-08 08:46:15 +00:00
|
|
|
}
|
2009-05-14 19:49:33 +00:00
|
|
|
$options = array( 'USE INDEX' => $index );
|
|
|
|
|
# Don't show duplicate rows when using log_search
|
|
|
|
|
if( $groupBy ) $options['GROUP BY'] = $groupBy;
|
2009-01-28 19:08:18 +00:00
|
|
|
$info = array(
|
2009-05-14 19:49:33 +00:00
|
|
|
'tables' => $tables,
|
|
|
|
|
'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' => $options,
|
|
|
|
|
'join_conds' => array(
|
|
|
|
|
'user' => array( 'INNER JOIN', 'user_id=log_user' ),
|
|
|
|
|
'log_search' => array( 'INNER JOIN', 'ls_log_id=log_id' )
|
|
|
|
|
)
|
2008-04-02 16:24:30 +00:00
|
|
|
);
|
2009-05-14 19:49:33 +00:00
|
|
|
# Add ChangeTags filter query
|
2009-03-20 04:29:49 +00:00
|
|
|
ChangeTags::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'],
|
2009-03-31 13:01:05 +00:00
|
|
|
$info['join_conds'], $info['options'], $this->mTagFilter );
|
2009-01-28 19:08:18 +00:00
|
|
|
|
|
|
|
|
return $info;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
function getIndexField() {
|
|
|
|
|
return 'log_timestamp';
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-10-27 14:03:05 +00:00
|
|
|
public function getStartBody() {
|
2008-04-08 15:50:16 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
|
|
|
|
# Do a link batch query
|
2008-04-08 23:30:36 +00:00
|
|
|
if( $this->getNumRows() > 0 ) {
|
|
|
|
|
$lb = new LinkBatch;
|
|
|
|
|
while( $row = $this->mResult->fetchObject() ) {
|
|
|
|
|
$lb->add( $row->log_namespace, $row->log_title );
|
|
|
|
|
$lb->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
|
|
|
|
|
$lb->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
|
|
|
|
|
}
|
|
|
|
|
$lb->execute();
|
|
|
|
|
$this->mResult->seek( 0 );
|
2008-04-08 15:50:16 +00:00
|
|
|
}
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
|
2008-10-27 14:03:05 +00:00
|
|
|
public function formatRow( $row ) {
|
2008-04-02 17:43:57 +00:00
|
|
|
return $this->mLogEventsList->logLine( $row );
|
2008-04-02 16:24:30 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
public function getType() {
|
2009-05-02 14:34:45 +00:00
|
|
|
return $this->types;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
public function getUser() {
|
2008-04-02 05:48:16 +00:00
|
|
|
return $this->user;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
public function getPage() {
|
|
|
|
|
return $this->title;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
public function getPattern() {
|
2008-04-02 05:48:16 +00:00
|
|
|
return $this->pattern;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
public function getYear() {
|
2008-08-01 22:56:17 +00:00
|
|
|
return $this->mYear;
|
2008-04-12 06:11:09 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-12 06:11:09 +00:00
|
|
|
public function getMonth() {
|
2008-08-01 22:56:17 +00:00
|
|
|
return $this->mMonth;
|
2008-04-12 06:11:09 +00:00
|
|
|
}
|
2009-01-28 19:08:18 +00:00
|
|
|
|
|
|
|
|
public function getTagFilter() {
|
|
|
|
|
return $this->mTagFilter;
|
|
|
|
|
}
|
2009-05-04 09:31:34 +00:00
|
|
|
|
|
|
|
|
public function doQuery() {
|
2009-05-27 06:10:48 +00:00
|
|
|
// Workaround MySQL optimizer bug
|
|
|
|
|
$this->mDb->setBigSelects();
|
|
|
|
|
parent::doQuery();
|
|
|
|
|
$this->mDb->setBigSelects( 'default' );
|
2009-05-04 09:31:34 +00:00
|
|
|
}
|
2008-04-02 16:24:30 +00:00
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
|
2008-04-02 16:24:30 +00:00
|
|
|
/**
|
2008-05-21 18:18:58 +00:00
|
|
|
* @deprecated
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2008-04-02 16:24:30 +00:00
|
|
|
*/
|
|
|
|
|
class LogReader {
|
2008-04-04 02:12:27 +00:00
|
|
|
var $pager;
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $request WebRequest: for internal use use a FauxRequest object to pass arbitrary parameters.
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-02 17:28:26 +00:00
|
|
|
function __construct( $request ) {
|
2008-04-12 06:11:09 +00:00
|
|
|
global $wgUser, $wgOut;
|
2008-12-30 18:53:56 +00:00
|
|
|
wfDeprecated(__METHOD__);
|
2008-04-02 16:24:30 +00:00
|
|
|
# Get parameters
|
|
|
|
|
$type = $request->getVal( 'type' );
|
|
|
|
|
$user = $request->getText( 'user' );
|
|
|
|
|
$title = $request->getText( 'page' );
|
|
|
|
|
$pattern = $request->getBool( 'pattern' );
|
2008-11-04 00:33:09 +00:00
|
|
|
$year = $request->getIntOrNull( 'year' );
|
|
|
|
|
$month = $request->getIntOrNull( 'month' );
|
2009-01-28 19:08:18 +00:00
|
|
|
$tagFilter = $request->getVal( 'tagfilter' );
|
2008-04-12 06:11:09 +00:00
|
|
|
# Don't let the user get stuck with a certain date
|
|
|
|
|
$skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
|
|
|
|
|
if( $skip ) {
|
2008-11-04 00:33:09 +00:00
|
|
|
$year = '';
|
|
|
|
|
$month = '';
|
2008-04-12 06:11:09 +00:00
|
|
|
}
|
|
|
|
|
# Use new list class to output results
|
|
|
|
|
$loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
|
2009-01-28 19:08:18 +00:00
|
|
|
$this->pager = new LogPager( $loglist, $type, $user, $title, $pattern, $year, $month, $tagFilter );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-02 17:28:26 +00:00
|
|
|
/**
|
|
|
|
|
* Is there at least one row?
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function hasRows() {
|
|
|
|
|
return isset($this->pager) ? ($this->pager->getNumRows() > 0) : false;
|
|
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-05-21 18:18:58 +00:00
|
|
|
* @deprecated
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
|
|
|
|
class LogViewer {
|
2008-04-02 06:03:00 +00:00
|
|
|
const NO_ACTION_LINK = 1;
|
2008-12-07 19:56:02 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
2008-12-07 19:56:02 +00:00
|
|
|
* LogReader object
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
|
|
|
|
var $reader;
|
2008-12-07 19:56:02 +00:00
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
/**
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param &$reader LogReader: where to get our data from
|
|
|
|
|
* @param $flags Integer: Bitwise combination of flags:
|
2008-04-02 17:43:57 +00:00
|
|
|
* LogEventsList::NO_ACTION_LINK Don't show restore/unblock/block links
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-02 17:28:26 +00:00
|
|
|
function __construct( &$reader, $flags = 0 ) {
|
2008-12-30 18:53:56 +00:00
|
|
|
wfDeprecated(__METHOD__);
|
2008-04-02 05:48:16 +00:00
|
|
|
$this->reader =& $reader;
|
2008-04-02 17:43:57 +00:00
|
|
|
$this->reader->pager->mLogEventsList->flags = $flags;
|
2008-04-02 16:24:30 +00:00
|
|
|
# Aliases for shorter code...
|
|
|
|
|
$this->pager =& $this->reader->pager;
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list =& $this->reader->pager->mLogEventsList;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Take over the whole output page in $wgOut with the log display.
|
|
|
|
|
*/
|
2008-04-02 17:28:26 +00:00
|
|
|
public function show() {
|
2008-04-02 16:24:30 +00:00
|
|
|
# Set title and add header
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list->showHeader( $pager->getType() );
|
2008-04-02 16:24:30 +00:00
|
|
|
# Show form options
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->list->showOptions( $this->pager->getType(), $this->pager->getUser(), $this->pager->getPage(),
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->pager->getPattern(), $this->pager->getYear(), $this->pager->getMonth() );
|
2008-04-02 16:24:30 +00:00
|
|
|
# Insert list
|
|
|
|
|
$logBody = $this->pager->getBody();
|
|
|
|
|
if( $logBody ) {
|
|
|
|
|
$wgOut->addHTML(
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->pager->getNavigationBar() .
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list->beginLogEventsList() .
|
2008-04-02 16:24:30 +00:00
|
|
|
$logBody .
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list->endLogEventsList() .
|
2008-04-02 16:24:30 +00:00
|
|
|
$this->pager->getNavigationBar()
|
|
|
|
|
);
|
2008-04-02 05:48:16 +00:00
|
|
|
} else {
|
2008-04-02 16:24:30 +00:00
|
|
|
$wgOut->addWikiMsg( 'logempty' );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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)
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $out OutputPage: where to send output
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-02 17:28:26 +00:00
|
|
|
public function showList( &$out ) {
|
2008-04-02 16:24:30 +00:00
|
|
|
$logBody = $this->pager->getBody();
|
|
|
|
|
if( $logBody ) {
|
|
|
|
|
$out->addHTML(
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list->beginLogEventsList() .
|
2008-04-02 16:24:30 +00:00
|
|
|
$logBody .
|
2008-04-12 06:11:09 +00:00
|
|
|
$this->list->endLogEventsList()
|
2008-04-02 16:24:30 +00:00
|
|
|
);
|
2008-04-02 05:48:16 +00:00
|
|
|
} else {
|
2008-04-02 16:59:16 +00:00
|
|
|
$out->addWikiMsg( 'logempty' );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|