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
|
2009-07-20 05:38:26 +00:00
|
|
|
* @param $type Array
|
2008-04-02 05:48:16 +00:00
|
|
|
*/
|
2008-04-12 06:11:09 +00:00
|
|
|
public function showHeader( $type ) {
|
2009-07-20 05:38:26 +00:00
|
|
|
// If only one log type is used, then show a special message...
|
|
|
|
|
$headerType = (count($type) == 1) ? $type[0] : '';
|
|
|
|
|
if( LogPage::isLogType( $headerType ) ) {
|
|
|
|
|
$this->out->setPageTitle( LogPage::logName( $headerType ) );
|
|
|
|
|
$this->out->addHTML( LogPage::logHeader( $headerType ) );
|
|
|
|
|
} else {
|
|
|
|
|
$this->out->addHTML( wfMsgExt('alllogstext',array('parseinline')) );
|
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;
|
2009-08-10 17:36:57 +00:00
|
|
|
|
|
|
|
|
$action = $wgScript;
|
2008-04-02 05:48:16 +00:00
|
|
|
$title = SpecialPage::getTitleFor( 'Log' );
|
2009-08-10 17:36:57 +00:00
|
|
|
$special = $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 );
|
2009-08-10 17:36:57 +00:00
|
|
|
|
|
|
|
|
$html = '';
|
|
|
|
|
$html .= Xml::hidden( 'title', $special );
|
|
|
|
|
|
|
|
|
|
// Basic selectors
|
|
|
|
|
$html .= $this->getTypeMenu( $types ) . "\n";
|
|
|
|
|
$html .= $this->getUserInput( $user ) . "\n";
|
|
|
|
|
$html .= $this->getTitleInput( $page ) . "\n";
|
2009-09-14 17:09:13 +00:00
|
|
|
$html .= $this->getExtraInputs( $types ) . "\n";
|
2009-01-30 23:24:29 +00:00
|
|
|
|
2009-08-10 17:36:57 +00:00
|
|
|
// Title pattern, if allowed
|
|
|
|
|
if (!$wgMiserMode) {
|
|
|
|
|
$html .= $this->getTitlePattern( $pattern ) . "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// date menu
|
|
|
|
|
$html .= Xml::tags( 'p', null, Xml::dateMenu( $year, $month ) );
|
|
|
|
|
|
|
|
|
|
// Tag filter
|
|
|
|
|
if ($tagSelector) {
|
|
|
|
|
$html .= Xml::tags( 'p', null, implode( ' ', $tagSelector ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Filter links
|
|
|
|
|
if ($filter) {
|
|
|
|
|
$html .= Xml::tags( 'p', null, $this->getFilterLinks( $filter ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Submit button
|
|
|
|
|
$html .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
|
|
|
|
|
|
|
|
|
|
// Fieldset
|
|
|
|
|
$html = Xml::fieldset( wfMsg( 'log' ), $html );
|
|
|
|
|
|
|
|
|
|
// Form wrapping
|
|
|
|
|
$html = Xml::tags( 'form', array( 'action' => $action, 'method' => 'get' ), $html );
|
|
|
|
|
|
|
|
|
|
$this->out->addHTML( $html );
|
2008-10-27 07:18:36 +00:00
|
|
|
}
|
|
|
|
|
|
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 ) {
|
2009-06-08 10:07:33 +00:00
|
|
|
// Should the below assignment be outside the foreach?
|
|
|
|
|
// Then it would have to be copied. Not certain what is more expensive.
|
|
|
|
|
$query = $this->getDefaultQuery();
|
|
|
|
|
$queryKey = "hide_{$type}_log";
|
|
|
|
|
|
2008-11-04 00:33:09 +00:00
|
|
|
$hideVal = 1 - intval($val);
|
2009-06-22 03:06:04 +00:00
|
|
|
$query[$queryKey] = $hideVal;
|
2009-06-08 10:07:33 +00:00
|
|
|
|
|
|
|
|
$link = $this->skin->link(
|
|
|
|
|
$wgTitle,
|
|
|
|
|
$messages[$hideVal],
|
|
|
|
|
array(),
|
|
|
|
|
$query,
|
|
|
|
|
array( 'known', 'noclasses' )
|
2008-10-27 07:18:36 +00:00
|
|
|
);
|
2009-06-08 10:07:33 +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
|
|
|
}
|
2009-09-14 17:09:13 +00:00
|
|
|
|
|
|
|
|
private function getExtraInputs( $types ) {
|
|
|
|
|
global $wgRequest;
|
|
|
|
|
if( count($types) == 1 && $types[0] == 'suppress' ) {
|
|
|
|
|
return Xml::inputLabel( wfMsg('revdelete-offender'), 'offender',
|
|
|
|
|
'mw-log-offender', 20, $wgRequest->getVal('offender') );
|
|
|
|
|
}
|
|
|
|
|
return '';
|
|
|
|
|
}
|
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 ) {
|
2009-06-07 15:02:12 +00:00
|
|
|
$revert = '(' . $this->skin->link(
|
|
|
|
|
SpecialPage::getTitleFor( 'Movepage' ),
|
2008-09-05 17:34:44 +00:00
|
|
|
$this->message['revertmove'],
|
2009-06-07 15:02:12 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'wpOldTitle' => $destTitle->getPrefixedDBkey(),
|
|
|
|
|
'wpNewTitle' => $title->getPrefixedDBkey(),
|
|
|
|
|
'wpReason' => wfMsgForContent( 'revertmove' ),
|
|
|
|
|
'wpMovetalk' => 0
|
|
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
) . ')';
|
2008-09-05 17:34:44 +00:00
|
|
|
}
|
|
|
|
|
// Show undelete link
|
2009-05-30 21:17:17 +00:00
|
|
|
} else if( self::typeAction($row,array('delete','suppress'),'delete','deletedhistory') ) {
|
2009-06-07 15:02:12 +00:00
|
|
|
if( !$wgUser->isAllowed( 'undelete' ) ) {
|
2009-05-30 21:17:17 +00:00
|
|
|
$viewdeleted = $this->message['undeleteviewlink'];
|
2009-06-07 15:02:12 +00:00
|
|
|
} else {
|
2009-05-30 21:17:17 +00:00
|
|
|
$viewdeleted = $this->message['undeletelink'];
|
2009-06-07 15:02:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$revert = '(' . $this->skin->link(
|
|
|
|
|
SpecialPage::getTitleFor( 'Undelete' ),
|
|
|
|
|
$viewdeleted,
|
|
|
|
|
array(),
|
|
|
|
|
array( 'target' => $title->getPrefixedDBkey() ),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
) . ')';
|
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 = '(' .
|
2009-06-07 15:02:12 +00:00
|
|
|
$this->skin->link(
|
|
|
|
|
SpecialPage::getTitleFor( 'Ipblocklist' ),
|
2008-12-16 08:51:56 +00:00
|
|
|
$this->message['unblocklink'],
|
|
|
|
|
array(),
|
2009-06-07 15:02:12 +00:00
|
|
|
array(
|
|
|
|
|
'action' => 'unblock',
|
|
|
|
|
'ip' => $row->log_title
|
|
|
|
|
),
|
|
|
|
|
'known'
|
|
|
|
|
) .
|
|
|
|
|
$this->message['pipe-separator'] .
|
|
|
|
|
$this->skin->link(
|
|
|
|
|
SpecialPage::getTitleFor( 'Blockip', $row->log_title ),
|
2008-12-16 08:51:56 +00:00
|
|
|
$this->message['change-blocklink'],
|
2009-06-07 15:02:12 +00:00
|
|
|
array(),
|
|
|
|
|
array(),
|
|
|
|
|
'known'
|
|
|
|
|
) .
|
2008-12-16 08:51:56 +00:00
|
|
|
')';
|
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(),
|
2009-06-07 15:02:12 +00:00
|
|
|
array(
|
|
|
|
|
'action' => 'history',
|
|
|
|
|
'offset' => $row->log_timestamp
|
|
|
|
|
)
|
|
|
|
|
);
|
2008-12-26 12:07:42 +00:00
|
|
|
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' );
|
2009-06-07 15:02:12 +00:00
|
|
|
$revert = '(' . $this->skin->link(
|
|
|
|
|
$merge,
|
|
|
|
|
$this->message['revertmerge'],
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'target' => $paramArray[0],
|
|
|
|
|
'dest' => $title->getPrefixedDBkey(),
|
|
|
|
|
'mergepoint' => $paramArray[1]
|
|
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
) . ')';
|
2008-09-05 17:34:44 +00:00
|
|
|
// 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
|
|
|
// Different revision types use different URL params...
|
|
|
|
|
$key = $paramArray[0];
|
In Special:RevisionDelete:
* Refactored to remove massive duplication
* Removed page parameter and associated contextPage member variable, doesn't seem to do anything.
* Put ID lists into a single ids parameter and member variable instead of having one for each type.
* Fixed inappropriate call of Title::newFromUrl(), always wrong
* Don't pretend to use the return value from functions that don't return anything, this reduces readability.
* Use the table names for deleteKey/typeName values, they look more like English
* Use protected not private
* Remove requirement for log type to be specified in the target
* Use POST for RevisionDelete entry forms, to avoid URL size limits and issues with non-PATH_INFO URLs
* Don't purge all pages that use the given file
* LocalFile::purgeCache() already calls purgeHistory,() no need to do it again. But do call purgeDescription().
* Removed token from unhide=1 links, unnecessary
* Tokens are necessary on file streaming links, added them
* Fixed private data leakage due to incorrect use of LocalRepo::newFromArchiveName(). Non-existent placeholder file was returned which meant that $oimage->userCan(File::DELETED_FILE) was always true. Pass the archive name to tryShowFile() instead of the storage key.
* Using ls_field='oi_timestamp' is not correct, oi_timestamp refers to the timestamp of the revision in question, whereas the key that is stored is the timestamp of the previous revision (i.e. the timestamp in oi_archive_name). oi_archive_name would be more correct, although only half the field is used.
Elsewhere:
* Added missing message filehist-missing
* Fixed double asterisk in Status::getWikiText()
* Fixed escaping of the target parameter to Special:RevisionDelete from ImagePage
* Deleted FileStore.php. Deprecated in filerepo refactor except for get()/export() but somehow resurrected by RevisionDelete. Hopefully this will be the end of it. New interfaces will be added for wfStreamFile() in a later commit.
* Added convenience function File::getStorageKey(), factored out of Special:Undelete
* Added convenience function Revision::newFromArchiveRow(), factored out of Special:Undelete and Special:RevisionDelete
* Fixed notice in Special:Upload, uninitialised $pageText
FIXME: current revision can be suppressed on undeletion causing an unauthenticated unsuppress. Comments indicate this is a known issue. I fixed the parser cache pollution in this case but not the rest.
2009-06-01 11:37:06 +00:00
|
|
|
// $paramArray[1] is a CSV of the IDs
|
2008-09-05 17:34:44 +00:00
|
|
|
$Ids = explode( ',', $paramArray[1] );
|
2009-06-07 15:02:12 +00:00
|
|
|
$query = $paramArray[1];
|
2009-03-22 01:07:42 +00:00
|
|
|
$revert = array();
|
|
|
|
|
// Diff link for single rev deletions
|
2009-07-26 10:05:50 +00:00
|
|
|
if( count($Ids) == 1 ) {
|
|
|
|
|
// Live revision diffs...
|
|
|
|
|
if( in_array($key, array('oldid','revision')) ) {
|
|
|
|
|
$revert[] = $this->skin->link(
|
|
|
|
|
$title,
|
|
|
|
|
$this->message['diff'],
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'diff' => intval( $Ids[0] ),
|
|
|
|
|
'unhide' => 1
|
|
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
|
|
|
|
// Deleted revision diffs...
|
|
|
|
|
} else if( in_array($key, array('artimestamp','archive')) ) {
|
|
|
|
|
$revert[] = $this->skin->link(
|
|
|
|
|
SpecialPage::getTitleFor( 'Undelete' ),
|
|
|
|
|
$this->message['diff'],
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'target' => $title->getPrefixedDBKey(),
|
|
|
|
|
'diff' => 'prev',
|
|
|
|
|
'timestamp' => $Ids[0]
|
|
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
|
|
|
|
}
|
2009-03-22 01:07:42 +00:00
|
|
|
}
|
|
|
|
|
// View/modify link...
|
2009-06-07 15:02:12 +00:00
|
|
|
$revert[] = $this->skin->link(
|
2009-07-26 10:05:50 +00:00
|
|
|
SpecialPage::getTitleFor( 'Revisiondelete' ),
|
2009-06-07 15:02:12 +00:00
|
|
|
$this->message['revdel-restore'],
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
2009-06-15 12:32:59 +00:00
|
|
|
'target' => $title->getPrefixedText(),
|
2009-06-07 15:02:12 +00:00
|
|
|
'type' => $key,
|
|
|
|
|
'ids' => $query
|
|
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
2009-03-25 17:52:40 +00:00
|
|
|
// Pipe links
|
2009-07-19 14:47:03 +00:00
|
|
|
$revert = wfMsg( 'parentheses', $wgLang->pipeList( $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' );
|
In Special:RevisionDelete:
* Refactored to remove massive duplication
* Removed page parameter and associated contextPage member variable, doesn't seem to do anything.
* Put ID lists into a single ids parameter and member variable instead of having one for each type.
* Fixed inappropriate call of Title::newFromUrl(), always wrong
* Don't pretend to use the return value from functions that don't return anything, this reduces readability.
* Use the table names for deleteKey/typeName values, they look more like English
* Use protected not private
* Remove requirement for log type to be specified in the target
* Use POST for RevisionDelete entry forms, to avoid URL size limits and issues with non-PATH_INFO URLs
* Don't purge all pages that use the given file
* LocalFile::purgeCache() already calls purgeHistory,() no need to do it again. But do call purgeDescription().
* Removed token from unhide=1 links, unnecessary
* Tokens are necessary on file streaming links, added them
* Fixed private data leakage due to incorrect use of LocalRepo::newFromArchiveName(). Non-existent placeholder file was returned which meant that $oimage->userCan(File::DELETED_FILE) was always true. Pass the archive name to tryShowFile() instead of the storage key.
* Using ls_field='oi_timestamp' is not correct, oi_timestamp refers to the timestamp of the revision in question, whereas the key that is stored is the timestamp of the previous revision (i.e. the timestamp in oi_archive_name). oi_archive_name would be more correct, although only half the field is used.
Elsewhere:
* Added missing message filehist-missing
* Fixed double asterisk in Status::getWikiText()
* Fixed escaping of the target parameter to Special:RevisionDelete from ImagePage
* Deleted FileStore.php. Deprecated in filerepo refactor except for get()/export() but somehow resurrected by RevisionDelete. Hopefully this will be the end of it. New interfaces will be added for wfStreamFile() in a later commit.
* Added convenience function File::getStorageKey(), factored out of Special:Undelete
* Added convenience function Revision::newFromArchiveRow(), factored out of Special:Undelete and Special:RevisionDelete
* Fixed notice in Special:Upload, uninitialised $pageText
FIXME: current revision can be suppressed on undeletion causing an unauthenticated unsuppress. Comments indicate this is a known issue. I fixed the parser cache pollution in this case but not the rest.
2009-06-01 11:37:06 +00:00
|
|
|
// $paramArray[1] is a CSV of the IDs
|
2008-09-05 17:34:44 +00:00
|
|
|
$Ids = explode( ',', $paramArray[0] );
|
2009-06-07 15:02:12 +00:00
|
|
|
$query = $paramArray[0];
|
2008-09-05 17:34:44 +00:00
|
|
|
// Link to each hidden object ID, $paramArray[1] is the url param
|
2009-06-07 15:02:12 +00:00
|
|
|
$revert = '(' . $this->skin->link(
|
|
|
|
|
$revdel,
|
|
|
|
|
$this->message['revdel-restore'],
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
2009-06-15 12:32:59 +00:00
|
|
|
'target' => $title->getPrefixedText(),
|
2009-06-07 15:02:12 +00:00
|
|
|
'type' => 'logging',
|
|
|
|
|
'ids' => $query
|
|
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
) . ')';
|
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
|
|
|
// 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 );
|
In Special:RevisionDelete:
* Refactored to remove massive duplication
* Removed page parameter and associated contextPage member variable, doesn't seem to do anything.
* Put ID lists into a single ids parameter and member variable instead of having one for each type.
* Fixed inappropriate call of Title::newFromUrl(), always wrong
* Don't pretend to use the return value from functions that don't return anything, this reduces readability.
* Use the table names for deleteKey/typeName values, they look more like English
* Use protected not private
* Remove requirement for log type to be specified in the target
* Use POST for RevisionDelete entry forms, to avoid URL size limits and issues with non-PATH_INFO URLs
* Don't purge all pages that use the given file
* LocalFile::purgeCache() already calls purgeHistory,() no need to do it again. But do call purgeDescription().
* Removed token from unhide=1 links, unnecessary
* Tokens are necessary on file streaming links, added them
* Fixed private data leakage due to incorrect use of LocalRepo::newFromArchiveName(). Non-existent placeholder file was returned which meant that $oimage->userCan(File::DELETED_FILE) was always true. Pass the archive name to tryShowFile() instead of the storage key.
* Using ls_field='oi_timestamp' is not correct, oi_timestamp refers to the timestamp of the revision in question, whereas the key that is stored is the timestamp of the previous revision (i.e. the timestamp in oi_archive_name). oi_archive_name would be more correct, although only half the field is used.
Elsewhere:
* Added missing message filehist-missing
* Fixed double asterisk in Status::getWikiText()
* Fixed escaping of the target parameter to Special:RevisionDelete from ImagePage
* Deleted FileStore.php. Deprecated in filerepo refactor except for get()/export() but somehow resurrected by RevisionDelete. Hopefully this will be the end of it. New interfaces will be added for wfStreamFile() in a later commit.
* Added convenience function File::getStorageKey(), factored out of Special:Undelete
* Added convenience function Revision::newFromArchiveRow(), factored out of Special:Undelete and Special:RevisionDelete
* Fixed notice in Special:Upload, uninitialised $pageText
FIXME: current revision can be suppressed on undeletion causing an unauthenticated unsuppress. Comments indicate this is a known issue. I fixed the parser cache pollution in this case but not the rest.
2009-06-01 11:37:06 +00:00
|
|
|
$query = array(
|
|
|
|
|
'target' => $target->getPrefixedDBkey(),
|
|
|
|
|
'type' => 'logging',
|
|
|
|
|
'ids' => $row->log_id,
|
|
|
|
|
);
|
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
|
|
|
/**
|
2009-09-13 22:21:11 +00:00
|
|
|
* Show log extract. Either with text and a box (set $msgKey) or without (don't set $msgKey)
|
2009-08-31 11:54:53 +00:00
|
|
|
* @param $out OutputPage or String-by-reference
|
2009-05-02 14:34:45 +00:00
|
|
|
* @param $types String or Array
|
2009-09-14 18:10:13 +00:00
|
|
|
* @param $page String The page title to show log entries for
|
|
|
|
|
* @param $user String The user who made the log entries
|
2009-09-13 22:21:11 +00:00
|
|
|
* @param $lim Integer Limit of items to show, default is 50
|
2009-09-14 18:10:13 +00:00
|
|
|
* @param $conds Array Extra conditions for the query
|
2009-09-13 22:21:11 +00:00
|
|
|
* @param $showIfEmpty boolean Set to false if you don't want any output in case the loglist is empty
|
|
|
|
|
* if set to true (default), "No matching items in log" is displayed if loglist is empty
|
|
|
|
|
* @param $msgKey String if you want a nice box with a message, set this to the key of the message
|
|
|
|
|
* @return Integer Number of total log items (not limited by $lim)
|
2008-04-02 20:20:47 +00:00
|
|
|
*/
|
2009-09-13 22:21:11 +00:00
|
|
|
public static function showLogExtract( &$out, $types=array(), $page='', $user='', $lim=0, $conds=array(), $showIfEmpty = true, $msgKey = '' ) {
|
2009-08-31 11:54:53 +00:00
|
|
|
global $wgUser, $wgOut;
|
2008-04-02 20:20:47 +00:00
|
|
|
# Insert list of top 50 or so items
|
2009-08-31 11:54:53 +00:00
|
|
|
$loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 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();
|
2009-09-14 02:17:31 +00:00
|
|
|
$s = '';
|
2008-04-02 20:20:47 +00:00
|
|
|
if( $logBody ) {
|
2009-09-13 22:21:11 +00:00
|
|
|
if ( $msgKey )
|
2009-09-14 02:17:31 +00:00
|
|
|
$s = '<div class="mw-warning-with-logexcerpt">' . wfMsgExt( $msgKey, array('parse') ) ;
|
2009-09-13 22:21:11 +00:00
|
|
|
$s .= $loglist->beginLogEventsList() .
|
2009-08-31 11:54:53 +00:00
|
|
|
$logBody .
|
|
|
|
|
$loglist->endLogEventsList();
|
|
|
|
|
} else {
|
2009-09-13 22:21:11 +00:00
|
|
|
if ( $showIfEmpty )
|
|
|
|
|
$s = wfMsgExt( 'logempty', array('parse') );
|
2009-08-31 11:54:53 +00:00
|
|
|
}
|
2009-09-13 22:21:11 +00:00
|
|
|
if( $pager->getNumRows() > $pager->mLimit ) { # Show "Full log" link
|
|
|
|
|
$urlParam = array();
|
|
|
|
|
if ( $page != '')
|
|
|
|
|
$urlParam['page'] = $page;
|
|
|
|
|
if ( $user != '')
|
|
|
|
|
$urlParam['user'] = $user;
|
|
|
|
|
if ( !is_array( $types ) ) # Make it an array, if it isn't
|
|
|
|
|
$types = array( $types );
|
|
|
|
|
# If there is exactly one log type, we can link to Special:Log?type=foo
|
|
|
|
|
if ( count( $types ) == 1 )
|
|
|
|
|
$urlParam['type'] = $types[0];
|
|
|
|
|
$s .= $wgUser->getSkin()->link(
|
|
|
|
|
SpecialPage::getTitleFor( 'Log' ),
|
|
|
|
|
wfMsgHtml( 'log-fulllog' ),
|
|
|
|
|
array(),
|
|
|
|
|
$urlParam
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if ( $logBody && $msgKey )
|
|
|
|
|
$s .= '</div>';
|
|
|
|
|
|
2009-08-31 11:54:53 +00:00
|
|
|
if( $out instanceof OutputPage ){
|
|
|
|
|
$out->addHTML( $s );
|
2008-04-02 20:20:47 +00:00
|
|
|
} else {
|
2009-08-31 11:54:53 +00:00
|
|
|
$out = $s;
|
2008-04-02 20:20:47 +00:00
|
|
|
}
|
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-09-14 18:10:13 +00:00
|
|
|
* @param $types String or Array log types to show
|
|
|
|
|
* @param $user String The user who made the log entries
|
|
|
|
|
* @param $title String The page title the log entries are for
|
|
|
|
|
* @param $pattern String Do a prefix search rather than an exact title match
|
|
|
|
|
* @param $conds Array Extra conditions for the query
|
|
|
|
|
* @param $year Integer The year to start from
|
|
|
|
|
* @param $month Integer The month to start from
|
2008-12-07 19:56:02 +00:00
|
|
|
*/
|
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-07-30 14:08:25 +00:00
|
|
|
if( !$wgUser->isAllowed( 'deleterevision' ) ) {
|
2009-06-13 06:31:38 +00:00
|
|
|
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_USER) . ' = 0';
|
2009-07-30 14:08:25 +00:00
|
|
|
} else if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
|
|
|
|
|
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::SUPPRESSED_USER) .
|
|
|
|
|
' != ' . LogPage::SUPPRESSED_USER;
|
2009-03-20 04:29:49 +00:00
|
|
|
}
|
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-07-30 14:08:25 +00:00
|
|
|
if( !$wgUser->isAllowed( 'deleterevision' ) ) {
|
2009-06-13 06:31:38 +00:00
|
|
|
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_ACTION) . ' = 0';
|
2009-07-30 14:08:25 +00:00
|
|
|
} else if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
|
|
|
|
|
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::SUPPRESSED_ACTION) .
|
|
|
|
|
' != ' . LogPage::SUPPRESSED_ACTION;
|
2009-03-20 04:29:49 +00:00
|
|
|
}
|
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';
|
2009-06-09 01:38:55 +00:00
|
|
|
$index = array( 'log_search' => 'ls_field_val', '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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|