2008-04-02 05:48:16 +00:00
|
|
|
<?php
|
2010-08-08 14:28:01 +00:00
|
|
|
/**
|
|
|
|
|
* Contain classes to list log entries
|
|
|
|
|
*
|
|
|
|
|
* Copyright © 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
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
2008-04-02 05:48:16 +00:00
|
|
|
|
2008-04-02 17:43:57 +00:00
|
|
|
class LogEventsList {
|
2008-04-02 05:48:16 +00:00
|
|
|
const NO_ACTION_LINK = 1;
|
2010-03-01 22:47:12 +00:00
|
|
|
const NO_EXTRA_USER_LINKS = 2;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-03-13 21:17:37 +00:00
|
|
|
/**
|
|
|
|
|
* @var Skin
|
|
|
|
|
*/
|
2008-04-02 16:24:30 +00:00
|
|
|
private $skin;
|
2011-03-13 21:17:37 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var OutputPage
|
|
|
|
|
*/
|
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
|
|
|
|
2011-03-13 21:17:37 +00:00
|
|
|
/**
|
|
|
|
|
* @var Array
|
|
|
|
|
*/
|
|
|
|
|
protected $message;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Array
|
|
|
|
|
*/
|
|
|
|
|
protected $mDefaultQuery;
|
|
|
|
|
|
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-10-30 02:14:22 +00:00
|
|
|
'revertmove', 'undeletelink', 'undeleteviewlink', 'revdel-restore', 'hist', 'diff',
|
2010-05-23 14:19:20 +00:00
|
|
|
'pipe-separator', 'revdel-restore-deleted', 'revdel-restore-visible' );
|
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
|
2010-06-03 21:00:51 +00:00
|
|
|
*
|
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
|
|
|
*/
|
2011-06-17 16:03:52 +00:00
|
|
|
public function showOptions( $types=array(), $user='', $page='', $pattern='', $year='',
|
2011-03-13 21:17:37 +00:00
|
|
|
$month = '', $filter = null, $tagFilter='' ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
global $wgScript, $wgMiserMode;
|
2009-10-11 19:55:56 +00:00
|
|
|
|
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-10-11 19:55:56 +00:00
|
|
|
|
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-10-11 19:55:56 +00:00
|
|
|
|
2010-10-31 16:20:48 +00:00
|
|
|
$html = Html::hidden( 'title', $special );
|
2009-10-11 19:55:56 +00:00
|
|
|
|
2009-08-10 17:36:57 +00:00
|
|
|
// 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";
|
|
|
|
|
}
|
2009-10-11 19:55:56 +00:00
|
|
|
|
2009-08-10 17:36:57 +00:00
|
|
|
// date menu
|
|
|
|
|
$html .= Xml::tags( 'p', null, Xml::dateMenu( $year, $month ) );
|
2009-10-11 19:55:56 +00:00
|
|
|
|
2009-08-10 17:36:57 +00:00
|
|
|
// Tag filter
|
|
|
|
|
if ($tagSelector) {
|
2010-05-30 17:33:59 +00:00
|
|
|
$html .= Xml::tags( 'p', null, implode( ' ', $tagSelector ) );
|
2009-08-10 17:36:57 +00:00
|
|
|
}
|
2009-10-11 19:55:56 +00:00
|
|
|
|
2009-08-10 17:36:57 +00:00
|
|
|
// Filter links
|
|
|
|
|
if ($filter) {
|
|
|
|
|
$html .= Xml::tags( 'p', null, $this->getFilterLinks( $filter ) );
|
|
|
|
|
}
|
2009-10-11 19:55:56 +00:00
|
|
|
|
2009-08-10 17:36:57 +00:00
|
|
|
// Submit button
|
|
|
|
|
$html .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
|
2009-10-11 19:55:56 +00:00
|
|
|
|
2009-08-10 17:36:57 +00:00
|
|
|
// Fieldset
|
|
|
|
|
$html = Xml::fieldset( wfMsg( 'log' ), $html );
|
2009-10-11 19:55:56 +00:00
|
|
|
|
2009-08-10 17:36:57 +00:00
|
|
|
// 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-10-11 19:55:56 +00:00
|
|
|
|
2009-05-02 14:34:45 +00:00
|
|
|
/**
|
|
|
|
|
* @param $filter Array
|
|
|
|
|
* @return String: Formatted HTML
|
|
|
|
|
*/
|
|
|
|
|
private function getFilterLinks( $filter ) {
|
2011-02-19 12:31:50 +00:00
|
|
|
global $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
|
|
|
|
2011-07-10 18:12:11 +00:00
|
|
|
$link = Linker::link(
|
2011-07-06 14:10:24 +00:00
|
|
|
$this->getDisplayTitle(),
|
2009-06-08 10:07:33 +00:00
|
|
|
$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 );
|
2010-10-31 16:20:48 +00:00
|
|
|
$hiddens .= Html::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
|
|
|
}
|
2009-10-11 19:55:56 +00:00
|
|
|
|
2008-10-27 07:18:36 +00:00
|
|
|
private function getDefaultQuery() {
|
2011-05-26 16:18:35 +00:00
|
|
|
global $wgRequest;
|
|
|
|
|
|
2008-10-27 07:18:36 +00:00
|
|
|
if ( !isset( $this->mDefaultQuery ) ) {
|
2011-05-26 16:18:35 +00:00
|
|
|
$this->mDefaultQuery = $wgRequest->getQueryValues();
|
2008-10-27 07:18:36 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2011-07-06 14:10:24 +00:00
|
|
|
/**
|
|
|
|
|
* Get the Title object of the page the links should point to.
|
|
|
|
|
* This is NOT the Title of the page the entries should be restricted to.
|
|
|
|
|
*
|
|
|
|
|
* @return Title object
|
|
|
|
|
*/
|
|
|
|
|
public function getDisplayTitle() {
|
|
|
|
|
return $this->out->getTitle();
|
|
|
|
|
}
|
|
|
|
|
|
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 );
|
2010-01-01 19:49:37 +00:00
|
|
|
$typesByName[$type] = $text;
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Second pass to sort by name
|
2010-01-01 19:49:37 +00:00
|
|
|
asort($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] : '';
|
2010-04-07 12:16:56 +00:00
|
|
|
|
|
|
|
|
// Always put "All public logs" on top
|
|
|
|
|
if ( isset( $typesByName[''] ) ) {
|
|
|
|
|
$all = $typesByName[''];
|
|
|
|
|
unset( $typesByName[''] );
|
|
|
|
|
$typesByName = array( '' => $all ) + $typesByName;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-02 05:48:16 +00:00
|
|
|
// Third pass generates sorted XHTML content
|
2010-01-01 19:49:37 +00:00
|
|
|
foreach( $typesByName as $type => $text ) {
|
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-10-17 08:29:15 +00:00
|
|
|
return '<span style="white-space: nowrap">' .
|
|
|
|
|
Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'mw-log-user', 15, $user ) .
|
|
|
|
|
'</span>';
|
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-10-17 08:29:15 +00:00
|
|
|
return '<span style="white-space: nowrap">' .
|
|
|
|
|
Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'mw-log-page', 20, $title ) .
|
|
|
|
|
'</span>';
|
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-10-11 19:55:56 +00:00
|
|
|
|
2009-09-14 17:09:13 +00:00
|
|
|
private function getExtraInputs( $types ) {
|
|
|
|
|
global $wgRequest;
|
2009-10-10 02:48:19 +00:00
|
|
|
$offender = $wgRequest->getVal('offender');
|
|
|
|
|
$user = User::newFromName( $offender, false );
|
|
|
|
|
if( !$user || ($user->getId() == 0 && !IP::isIPAddress($offender) ) ) {
|
|
|
|
|
$offender = ''; // Blank field if invalid
|
|
|
|
|
}
|
2009-09-14 17:09:13 +00:00
|
|
|
if( count($types) == 1 && $types[0] == 'suppress' ) {
|
|
|
|
|
return Xml::inputLabel( wfMsg('revdelete-offender'), 'offender',
|
2009-10-10 02:48:19 +00:00
|
|
|
'mw-log-offender', 20, $offender );
|
2009-09-14 17:09:13 +00:00
|
|
|
}
|
|
|
|
|
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 ) {
|
2010-03-01 22:47:12 +00:00
|
|
|
$classes = array( 'mw-logline-' . $row->log_type );
|
2008-04-02 05:48:16 +00:00
|
|
|
$title = Title::makeTitle( $row->log_namespace, $row->log_title );
|
2010-03-01 22:47:12 +00:00
|
|
|
// Log time
|
|
|
|
|
$time = $this->logTimestamp( $row );
|
2008-04-02 05:48:16 +00:00
|
|
|
// User links
|
2010-03-01 22:47:12 +00:00
|
|
|
$userLink = $this->logUserLinks( $row );
|
|
|
|
|
// Extract extra parameters
|
|
|
|
|
$paramArray = LogPage::extractParams( $row->log_params );
|
|
|
|
|
// Event description
|
|
|
|
|
$action = $this->logAction( $row, $title, $paramArray );
|
|
|
|
|
// Log comment
|
|
|
|
|
$comment = $this->logComment( $row );
|
|
|
|
|
// Add review/revert links and such...
|
|
|
|
|
$revert = $this->logActionLinks( $row, $title, $paramArray, $comment );
|
|
|
|
|
|
|
|
|
|
// Some user can hide log items and have review links
|
|
|
|
|
$del = $this->getShowHideLinks( $row );
|
|
|
|
|
if( $del != '' ) $del .= ' ';
|
|
|
|
|
|
|
|
|
|
// Any tags...
|
|
|
|
|
list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'logevent' );
|
|
|
|
|
$classes = array_merge( $classes, $newClasses );
|
|
|
|
|
|
|
|
|
|
return Xml::tags( 'li', array( "class" => implode( ' ', $classes ) ),
|
|
|
|
|
$del . "$time $userLink $action $comment $revert $tagDisplay" ) . "\n";
|
|
|
|
|
}
|
2011-06-17 16:03:52 +00:00
|
|
|
|
2010-03-01 22:47:12 +00:00
|
|
|
private function logTimestamp( $row ) {
|
|
|
|
|
global $wgLang;
|
|
|
|
|
$time = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->log_timestamp ), true );
|
|
|
|
|
return htmlspecialchars( $time );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function logUserLinks( $row ) {
|
2009-10-11 19:55:56 +00:00
|
|
|
if( self::isDeleted( $row, LogPage::DELETED_USER ) ) {
|
2010-03-01 22:47:12 +00:00
|
|
|
$userLinks = '<span class="history-deleted">' .
|
|
|
|
|
wfMsgHtml( 'rev-deleted-user' ) . '</span>';
|
2008-04-02 05:48:16 +00:00
|
|
|
} else {
|
2011-07-10 18:12:11 +00:00
|
|
|
$userLinks = Linker::userLink( $row->log_user, $row->user_name );
|
2010-03-01 22:47:12 +00:00
|
|
|
// Talk|Contribs links...
|
|
|
|
|
if( !( $this->flags & self::NO_EXTRA_USER_LINKS ) ) {
|
2011-07-10 18:12:11 +00:00
|
|
|
$userLinks .= Linker::userToolLinks(
|
2010-03-01 22:47:12 +00:00
|
|
|
$row->log_user, $row->user_name, true, 0, $row->user_editcount );
|
|
|
|
|
}
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2010-03-01 22:47:12 +00:00
|
|
|
return $userLinks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function logAction( $row, $title, $paramArray ) {
|
|
|
|
|
if( self::isDeleted( $row, LogPage::DELETED_ACTION ) ) {
|
|
|
|
|
$action = '<span class="history-deleted">' .
|
|
|
|
|
wfMsgHtml( 'rev-deleted-event' ) . '</span>';
|
|
|
|
|
} else {
|
|
|
|
|
$action = LogPage::actionText(
|
|
|
|
|
$row->log_type, $row->log_action, $title, $this->skin, $paramArray, true );
|
|
|
|
|
}
|
|
|
|
|
return $action;
|
|
|
|
|
}
|
2011-06-17 16:03:52 +00:00
|
|
|
|
2010-03-01 22:47:12 +00:00
|
|
|
private function logComment( $row ) {
|
2009-10-11 19:55:56 +00:00
|
|
|
if( self::isDeleted( $row, LogPage::DELETED_COMMENT ) ) {
|
2010-03-01 22:47:12 +00:00
|
|
|
$comment = '<span class="history-deleted">' .
|
|
|
|
|
wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
|
2008-04-02 05:48:16 +00:00
|
|
|
} else {
|
2011-07-06 02:26:06 +00:00
|
|
|
global $wgLang;
|
|
|
|
|
$comment = $wgLang->getDirMark() .
|
2011-07-10 18:12:11 +00:00
|
|
|
Linker::commentBlock( $row->log_comment );
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2010-03-01 22:47:12 +00:00
|
|
|
return $comment;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-13 21:17:37 +00:00
|
|
|
/**
|
|
|
|
|
* @TODO: split up!
|
|
|
|
|
*
|
|
|
|
|
* @param $row
|
|
|
|
|
* @param Title $title
|
|
|
|
|
* @param Array $paramArray
|
|
|
|
|
* @param $comment
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
2010-03-01 22:47:12 +00:00
|
|
|
private function logActionLinks( $row, $title, $paramArray, &$comment ) {
|
2010-07-24 19:11:52 +00:00
|
|
|
global $wgUser;
|
2010-03-01 22:47:12 +00:00
|
|
|
if( ( $this->flags & self::NO_ACTION_LINK ) // we don't want to see the action
|
|
|
|
|
|| self::isDeleted( $row, LogPage::DELETED_ACTION ) ) // action is hidden
|
|
|
|
|
{
|
|
|
|
|
return '';
|
2008-04-02 05:48:16 +00:00
|
|
|
}
|
2010-03-01 22:47:12 +00:00
|
|
|
$revert = '';
|
|
|
|
|
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 ) {
|
2011-07-10 18:12:11 +00:00
|
|
|
$revert = '(' . Linker::link(
|
2009-06-07 15:02:12 +00:00
|
|
|
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(),
|
2010-03-01 22:47:12 +00:00
|
|
|
'wpReason' => wfMsgForContent( 'revertmove' ),
|
2009-06-07 15:02:12 +00:00
|
|
|
'wpMovetalk' => 0
|
|
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
) . ')';
|
2008-09-05 17:34:44 +00:00
|
|
|
}
|
|
|
|
|
// Show undelete link
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif( 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
|
|
|
}
|
2011-07-10 18:12:11 +00:00
|
|
|
$revert = '(' . Linker::link(
|
2009-06-07 15:02:12 +00:00
|
|
|
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
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif( self::typeAction( $row, array( 'block', 'suppress' ), array( 'block', 'reblock' ), 'block' ) ) {
|
2008-12-16 08:51:56 +00:00
|
|
|
$revert = '(' .
|
2011-07-10 18:12:11 +00:00
|
|
|
Linker::link(
|
2011-03-13 21:33:52 +00:00
|
|
|
SpecialPage::getTitleFor( 'Unblock', $row->log_title ),
|
2008-12-16 08:51:56 +00:00
|
|
|
$this->message['unblocklink'],
|
|
|
|
|
array(),
|
2011-03-13 21:33:52 +00:00
|
|
|
array(),
|
2009-06-07 15:02:12 +00:00
|
|
|
'known'
|
|
|
|
|
) .
|
|
|
|
|
$this->message['pipe-separator'] .
|
2011-07-10 18:12:11 +00:00
|
|
|
Linker::link(
|
2011-03-12 23:22:34 +00:00
|
|
|
SpecialPage::getTitleFor( 'Block', $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
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif( self::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) {
|
2009-10-11 19:55:56 +00:00
|
|
|
$revert .= ' (' .
|
2011-07-10 18:12:11 +00:00
|
|
|
Linker::link( $title,
|
2008-12-26 12:07:42 +00:00
|
|
|
$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'] .
|
2011-07-10 18:12:11 +00:00
|
|
|
Linker::link( $title,
|
2008-12-26 12:07:42 +00:00
|
|
|
$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
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif( self::typeAction( $row, 'merge', 'merge', 'mergehistory' ) ) {
|
2011-07-10 18:12:11 +00:00
|
|
|
$revert = '(' . Linker::link(
|
2010-03-18 17:36:43 +00:00
|
|
|
SpecialPage::getTitleFor( 'MergeHistory' ),
|
2009-06-07 15:02:12 +00:00
|
|
|
$this->message['revertmerge'],
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'target' => $paramArray[0],
|
2009-10-11 19:55:56 +00:00
|
|
|
'dest' => $title->getPrefixedDBkey(),
|
2009-06-07 15:02:12 +00:00
|
|
|
'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
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif( self::typeAction( $row, array( 'delete', 'suppress' ), 'revision', 'deletedhistory' ) ) {
|
2010-05-23 14:19:20 +00:00
|
|
|
$revert = RevisionDeleter::getLogLinks( $title, $paramArray,
|
|
|
|
|
$this->skin, $this->message );
|
2008-09-05 17:34:44 +00:00
|
|
|
// Hidden log items, give review link
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif( self::typeAction( $row, array( 'delete', 'suppress' ), 'event', 'deletedhistory' ) ) {
|
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
|
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
|
2011-07-10 18:12:11 +00:00
|
|
|
$revert = '(' . Linker::link(
|
2009-06-07 15:02:12 +00:00
|
|
|
$revdel,
|
2011-06-17 16:03:52 +00:00
|
|
|
$this->message['revdel-restore'],
|
2009-06-07 15:02:12 +00:00
|
|
|
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
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif( self::typeAction( $row, 'newusers', 'create2' ) ) {
|
2008-09-13 00:29:33 +00:00
|
|
|
if( isset( $paramArray[0] ) ) {
|
2011-07-10 18:12:11 +00:00
|
|
|
$revert = Linker::userToolLinks( $paramArray[0], $title->getDBkey(), true );
|
2008-09-13 00:29:33 +00:00
|
|
|
} else {
|
|
|
|
|
# Fall back to a blue contributions link
|
2011-07-10 18:12:11 +00:00
|
|
|
$revert = Linker::userToolLinks( 1, $title->getDBkey() );
|
2008-09-13 00:29:33 +00:00
|
|
|
}
|
2011-05-29 19:18:53 +00:00
|
|
|
if( wfTimestamp( TS_MW, $row->log_timestamp ) < '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
|
|
|
}
|
2008-12-22 19:52:49 +00:00
|
|
|
if( $revert != '' ) {
|
|
|
|
|
$revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
|
|
|
|
|
}
|
2010-03-01 22:47:12 +00:00
|
|
|
return $revert;
|
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 ) {
|
2009-10-30 02:14:22 +00:00
|
|
|
global $wgUser;
|
2010-03-01 22:47:12 +00:00
|
|
|
if( ( $this->flags & self::NO_ACTION_LINK ) // we don't want to see the links
|
2011-03-13 21:17:37 +00:00
|
|
|
|| $row->log_type == 'suppress' ) { // no one can hide items from the suppress log
|
2010-03-01 22:47:12 +00:00
|
|
|
return '';
|
2009-10-30 02:14:22 +00:00
|
|
|
}
|
2010-03-01 22:47:12 +00:00
|
|
|
$del = '';
|
|
|
|
|
// Don't show useless link to people who cannot hide revisions
|
2011-07-26 20:54:41 +00:00
|
|
|
if( $wgUser->isAllowed( 'deletedhistory' ) && !$wgUser->isBlocked() ) {
|
2010-03-01 22:47:12 +00:00
|
|
|
if( $row->log_deleted || $wgUser->isAllowed( 'deleterevision' ) ) {
|
|
|
|
|
$canHide = $wgUser->isAllowed( 'deleterevision' );
|
|
|
|
|
// If event was hidden from sysops
|
|
|
|
|
if( !self::userCan( $row, LogPage::DELETED_RESTRICTED ) ) {
|
2011-07-10 18:12:11 +00:00
|
|
|
$del = Linker::revDeleteLinkDisabled( $canHide );
|
2010-03-01 22:47:12 +00:00
|
|
|
} else {
|
|
|
|
|
$target = SpecialPage::getTitleFor( 'Log', $row->log_type );
|
|
|
|
|
$query = array(
|
|
|
|
|
'target' => $target->getPrefixedDBkey(),
|
|
|
|
|
'type' => 'logging',
|
|
|
|
|
'ids' => $row->log_id,
|
|
|
|
|
);
|
2011-07-10 18:12:11 +00:00
|
|
|
$del = Linker::revDeleteLink( $query,
|
2010-03-01 22:47:12 +00:00
|
|
|
self::isDeleted( $row, LogPage::DELETED_RESTRICTED ), $canHide );
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
2010-06-03 21:00:51 +00:00
|
|
|
* @return Boolean
|
2008-04-13 15:18:59 +00:00
|
|
|
*/
|
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) ?
|
2009-10-11 19:55:56 +00:00
|
|
|
in_array( $row->log_type, $type ) : $row->log_type == $type;
|
2008-09-05 17:34:44 +00:00
|
|
|
if( $match ) {
|
2009-10-11 19:55:56 +00:00
|
|
|
$match = is_array( $action ) ?
|
|
|
|
|
in_array( $row->log_action, $action ) : $row->log_action == $action;
|
2008-12-16 19:20:35 +00:00
|
|
|
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.
|
2010-06-03 21:00:51 +00:00
|
|
|
*
|
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 ) {
|
2009-10-15 11:31:33 +00:00
|
|
|
return self::userCanBitfield( $row->log_deleted, $field );
|
|
|
|
|
}
|
2010-06-03 21:00:51 +00:00
|
|
|
|
2009-10-15 11:31:33 +00:00
|
|
|
/**
|
|
|
|
|
* Determine if the current user is allowed to view a particular
|
|
|
|
|
* field of this log row, if it's marked as deleted.
|
2010-06-03 21:00:51 +00:00
|
|
|
*
|
2009-10-15 11:31:33 +00:00
|
|
|
* @param $bitfield Integer (current field)
|
|
|
|
|
* @param $field Integer
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public static function userCanBitfield( $bitfield, $field ) {
|
|
|
|
|
if( $bitfield & $field ) {
|
2008-04-02 17:11:58 +00:00
|
|
|
global $wgUser;
|
2010-10-14 20:53:04 +00:00
|
|
|
|
2009-10-15 11:31:33 +00:00
|
|
|
if ( $bitfield & LogPage::DELETED_RESTRICTED ) {
|
2009-10-09 19:01:39 +00:00
|
|
|
$permission = 'suppressrevision';
|
|
|
|
|
} else {
|
|
|
|
|
$permission = 'deletedhistory';
|
|
|
|
|
}
|
2009-10-15 11:31:33 +00:00
|
|
|
wfDebug( "Checking for $permission due to $field match on $bitfield\n" );
|
2008-04-02 17:11:58 +00:00
|
|
|
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 ) {
|
2009-10-11 19:55:56 +00:00
|
|
|
return ( $row->log_deleted & $field ) == $field;
|
2008-04-02 17:11:58 +00:00
|
|
|
}
|
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)
|
2010-06-03 21:00:51 +00:00
|
|
|
*
|
2011-03-11 23:33:36 +00:00
|
|
|
* @param $out OutputPage|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-16 17:17:16 +00:00
|
|
|
* @param $param Associative Array with the following additional options:
|
2009-10-11 19:55:56 +00:00
|
|
|
* - lim Integer Limit of items to show, default is 50
|
|
|
|
|
* - conds Array Extra conditions for the query (e.g. "log_action != 'revision'")
|
|
|
|
|
* - 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
|
|
|
|
|
* - msgKey Array If you want a nice box with a message, set this to the key of the message.
|
|
|
|
|
* First element is the message key, additional optional elements are parameters for the key
|
|
|
|
|
* that are processed with wgMsgExt and option 'parse'
|
|
|
|
|
* - offset Set to overwrite offset parameter in $wgRequest
|
|
|
|
|
* set to '' to unset offset
|
2010-03-01 22:47:12 +00:00
|
|
|
* - wrap String Wrap the message in html (usually something like "<div ...>$1</div>").
|
|
|
|
|
* - flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
|
2009-09-13 22:21:11 +00:00
|
|
|
* @return Integer Number of total log items (not limited by $lim)
|
2008-04-02 20:20:47 +00:00
|
|
|
*/
|
2010-03-01 22:47:12 +00:00
|
|
|
public static function showLogExtract(
|
|
|
|
|
&$out, $types=array(), $page='', $user='', $param = array()
|
|
|
|
|
) {
|
|
|
|
|
global $wgUser, $wgOut;
|
2009-09-18 13:57:13 +00:00
|
|
|
$defaultParameters = array(
|
2009-10-02 18:04:58 +00:00
|
|
|
'lim' => 25,
|
2009-09-18 13:57:13 +00:00
|
|
|
'conds' => array(),
|
|
|
|
|
'showIfEmpty' => true,
|
2010-01-16 11:24:23 +00:00
|
|
|
'msgKey' => array(''),
|
2010-03-01 22:47:12 +00:00
|
|
|
'wrap' => "$1",
|
|
|
|
|
'flags' => 0
|
2009-09-18 13:57:13 +00:00
|
|
|
);
|
|
|
|
|
# The + operator appends elements of remaining keys from the right
|
|
|
|
|
# handed array to the left handed, whereas duplicated keys are NOT overwritten.
|
|
|
|
|
$param += $defaultParameters;
|
2009-09-16 17:17:16 +00:00
|
|
|
# Convert $param array to individual variables
|
|
|
|
|
$lim = $param['lim'];
|
|
|
|
|
$conds = $param['conds'];
|
|
|
|
|
$showIfEmpty = $param['showIfEmpty'];
|
|
|
|
|
$msgKey = $param['msgKey'];
|
2010-01-16 11:24:23 +00:00
|
|
|
$wrap = $param['wrap'];
|
2010-03-01 22:47:12 +00:00
|
|
|
$flags = $param['flags'];
|
|
|
|
|
if ( !is_array( $msgKey ) ) {
|
2009-09-16 17:17:16 +00:00
|
|
|
$msgKey = array( $msgKey );
|
2010-03-01 22:47:12 +00:00
|
|
|
}
|
2009-09-16 17:17:16 +00:00
|
|
|
# Insert list of top 50 (or top $lim) items
|
2010-03-01 22:47:12 +00:00
|
|
|
$loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, $flags );
|
2009-05-02 14:34:45 +00:00
|
|
|
$pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
|
2010-03-01 22:47:12 +00:00
|
|
|
if ( isset( $param['offset'] ) ) { # Tell pager to ignore $wgRequest offset
|
2009-09-20 22:07:44 +00:00
|
|
|
$pager->setOffset( $param['offset'] );
|
2010-03-01 22:47:12 +00:00
|
|
|
}
|
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-16 17:17:16 +00:00
|
|
|
if ( $msgKey[0] ) {
|
2009-09-14 18:58:25 +00:00
|
|
|
$s = '<div class="mw-warning-with-logexcerpt">';
|
|
|
|
|
|
2009-09-14 19:56:22 +00:00
|
|
|
if ( count( $msgKey ) == 1 ) {
|
2009-10-11 19:55:56 +00:00
|
|
|
$s .= wfMsgExt( $msgKey[0], array( 'parse' ) );
|
2009-09-14 18:58:25 +00:00
|
|
|
} else { // Process additional arguments
|
|
|
|
|
$args = $msgKey;
|
2009-09-14 19:56:22 +00:00
|
|
|
array_shift( $args );
|
2009-10-11 19:55:56 +00:00
|
|
|
$s .= wfMsgExt( $msgKey[0], array( 'parse' ), $args );
|
2009-09-14 18:58:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
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 )
|
2009-12-04 18:37:54 +00:00
|
|
|
$s = Html::rawElement( 'div', array( 'class' => 'mw-warning-logempty' ),
|
|
|
|
|
wfMsgExt( 'logempty', array( 'parseinline' ) ) );
|
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];
|
2011-07-10 18:12:11 +00:00
|
|
|
$s .= Linker::link(
|
2009-09-13 22:21:11 +00:00
|
|
|
SpecialPage::getTitleFor( 'Log' ),
|
|
|
|
|
wfMsgHtml( 'log-fulllog' ),
|
|
|
|
|
array(),
|
|
|
|
|
$urlParam
|
|
|
|
|
);
|
|
|
|
|
}
|
2010-03-01 22:47:12 +00:00
|
|
|
if ( $logBody && $msgKey[0] ) {
|
2009-09-13 22:21:11 +00:00
|
|
|
$s .= '</div>';
|
2010-03-01 22:47:12 +00:00
|
|
|
}
|
2009-09-13 22:21:11 +00:00
|
|
|
|
2010-01-16 11:24:23 +00:00
|
|
|
if ( $wrap!='' ) { // Wrap message in html
|
|
|
|
|
$s = str_replace( '$1', $s, $wrap );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// $out can be either an OutputPage object or a String-by-reference
|
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
|
2010-06-03 21:00:51 +00:00
|
|
|
*
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $db Database
|
2009-03-03 23:47:16 +00:00
|
|
|
* @param $audience string, public/user
|
2010-06-03 21:00:51 +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
|
|
|
/**
|
2010-06-03 21:00:51 +00:00
|
|
|
* Constructor
|
|
|
|
|
*
|
2008-12-07 19:56:02 +00:00
|
|
|
* @param $list LogEventsList
|
2010-06-03 21:00:51 +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
|
|
|
|
|
* @param $tagFilter String: tag
|
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 = '',
|
2011-03-13 21:17:37 +00:00
|
|
|
$conds = array(), $year = false, $month = false, $tagFilter = '' ) {
|
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
|
|
|
|
2011-07-06 14:10:24 +00:00
|
|
|
function getTitle() {
|
|
|
|
|
return $this->mLogEventsList->getDisplayTitle();
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2010-06-03 21:00:51 +00:00
|
|
|
*
|
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 ) {
|
2009-11-29 16:39:47 +00:00
|
|
|
if( isset( $wgLogRestrictions[$type] )
|
|
|
|
|
&& !$wgUser->isAllowed($wgLogRestrictions[$type])
|
|
|
|
|
) {
|
2009-04-24 17:20:48 +00:00
|
|
|
$types = array_diff( $types, array( $type ) );
|
|
|
|
|
}
|
2008-04-02 18:09:02 +00:00
|
|
|
}
|
2009-11-29 16:39:47 +00:00
|
|
|
$this->types = $types;
|
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) ) {
|
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.
|
2010-06-03 21:00:51 +00:00
|
|
|
*
|
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)
|
2011-07-26 20:54:41 +00:00
|
|
|
if( !$wgUser->isAllowed( 'deletedhistory' ) || $wgUser->isBlocked() ) {
|
2009-06-13 06:31:38 +00:00
|
|
|
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_USER) . ' = 0';
|
2011-07-26 20:54:41 +00:00
|
|
|
} elseif( !$wgUser->isAllowed( 'suppressrevision' ) || $wgUser->isBlocked() ) {
|
2009-07-30 14:08:25 +00:00
|
|
|
$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.)
|
2010-06-03 21:00:51 +00:00
|
|
|
*
|
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 );
|
2011-03-13 21:17:37 +00:00
|
|
|
if( strlen( $page ) == 0 || !$title instanceof Title ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
return false;
|
2011-03-13 21:17:37 +00:00
|
|
|
}
|
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();
|
2009-10-21 19:53:03 +00:00
|
|
|
$db = $this->mDb;
|
|
|
|
|
|
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 ) {
|
|
|
|
|
$this->mConds['log_namespace'] = $ns;
|
2009-10-21 19:53:03 +00:00
|
|
|
$this->mConds[] = 'log_title ' . $db->buildLike( $title->getDBkey(), $db->anyString() );
|
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)
|
2011-07-26 20:54:41 +00:00
|
|
|
if( !$wgUser->isAllowed( 'deletedhistory' ) || $wgUser->isBlocked() ) {
|
2009-10-21 19:53:03 +00:00
|
|
|
$this->mConds[] = $db->bitAnd('log_deleted', LogPage::DELETED_ACTION) . ' = 0';
|
2011-07-26 20:54:41 +00:00
|
|
|
} elseif( !$wgUser->isAllowed( 'suppressrevision' ) || $wgUser->isBlocked() ) {
|
2009-10-21 19:53:03 +00:00
|
|
|
$this->mConds[] = $db->bitAnd('log_deleted', LogPage::SUPPRESSED_ACTION) .
|
2009-07-30 14:08:25 +00:00
|
|
|
' != ' . 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-11-29 16:39:47 +00:00
|
|
|
$index = array();
|
2009-12-03 02:37:49 +00:00
|
|
|
$options = array();
|
2011-03-22 13:11:28 +00:00
|
|
|
# Add log_search table if there are conditions on it.
|
|
|
|
|
# This filters the results to only include log rows that have
|
|
|
|
|
# log_search records with the specified ls_field and ls_value values.
|
|
|
|
|
if( array_key_exists( 'ls_field', $this->mConds ) ) {
|
2009-05-13 22:03:32 +00:00
|
|
|
$tables[] = 'log_search';
|
2009-11-29 16:39:47 +00:00
|
|
|
$index['log_search'] = 'ls_field_val';
|
|
|
|
|
$index['logging'] = 'PRIMARY';
|
2011-03-22 13:11:28 +00:00
|
|
|
if ( !$this->hasEqualsClause( 'ls_field' )
|
|
|
|
|
|| !$this->hasEqualsClause( 'ls_value' ) )
|
|
|
|
|
{
|
|
|
|
|
# Since (ls_field,ls_value,ls_logid) is unique, if the condition is
|
|
|
|
|
# to match a specific (ls_field,ls_value) tuple, then there will be
|
|
|
|
|
# no duplicate log rows. Otherwise, we need to remove the duplicates.
|
|
|
|
|
$options[] = 'DISTINCT';
|
|
|
|
|
}
|
2009-11-29 16:39:47 +00:00
|
|
|
# Avoid usage of the wrong index by limiting
|
|
|
|
|
# the choices of available indexes. This mainly
|
|
|
|
|
# avoids site-breaking filesorts.
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif( $this->title || $this->pattern || $this->user ) {
|
2009-11-29 16:39:47 +00:00
|
|
|
$index['logging'] = array( 'page_time', 'user_time' );
|
|
|
|
|
if( count($this->types) == 1 ) {
|
|
|
|
|
$index['logging'][] = 'log_user_type_time';
|
|
|
|
|
}
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif( count($this->types) == 1 ) {
|
2009-11-29 16:39:47 +00:00
|
|
|
$index['logging'] = 'type_time';
|
2008-04-08 08:46:15 +00:00
|
|
|
} else {
|
2009-11-29 16:39:47 +00:00
|
|
|
$index['logging'] = 'times';
|
2008-04-08 08:46:15 +00:00
|
|
|
}
|
2009-12-03 02:37:49 +00:00
|
|
|
$options['USE INDEX'] = $index;
|
2009-05-14 19:49:33 +00:00
|
|
|
# Don't show duplicate rows when using log_search
|
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,
|
2009-10-11 19:55:56 +00:00
|
|
|
'join_conds' => array(
|
2011-03-22 13:11:28 +00:00
|
|
|
'user' => array( 'INNER JOIN', 'user_id=log_user' ),
|
2009-05-14 19:49:33 +00:00
|
|
|
'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
|
|
|
}
|
|
|
|
|
|
2011-03-22 13:11:28 +00:00
|
|
|
// Checks if $this->mConds has $field matched to a *single* value
|
|
|
|
|
protected function hasEqualsClause( $field ) {
|
|
|
|
|
return (
|
|
|
|
|
array_key_exists( $field, $this->mConds ) &&
|
|
|
|
|
( !is_array( $this->mConds[$field] ) || count( $this->mConds[$field] ) == 1 )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2010-10-13 23:11:40 +00:00
|
|
|
foreach ( $this->mResult as $row ) {
|
2008-04-08 23:30:36 +00:00
|
|
|
$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
|
|
|
|