2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-08-20 13:43:45 +00:00
|
|
|
#
|
2004-08-24 08:11:46 +00:00
|
|
|
# Copyright (C) 2002, 2004 Brion Vibber <brion@pobox.com>
|
|
|
|
|
# http://www.mediawiki.org/
|
2005-08-02 13:35:19 +00:00
|
|
|
#
|
2004-08-24 08:11:46 +00:00
|
|
|
# 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
|
2005-08-02 13:35:19 +00:00
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
2004-08-24 08:11:46 +00:00
|
|
|
# (at your option) any later version.
|
2005-08-02 13:35:19 +00:00
|
|
|
#
|
2004-08-24 08:11:46 +00:00
|
|
|
# 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.
|
2005-08-02 13:35:19 +00:00
|
|
|
#
|
2004-08-24 08:11:46 +00:00
|
|
|
# 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.,
|
2006-04-05 07:43:17 +00:00
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-08-24 08:11:46 +00:00
|
|
|
# http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Contain log classes
|
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
|
|
|
* @file
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Class to simplify the use of log pages.
|
|
|
|
|
* The logs are now kept in a table which is easier to manage and trim
|
|
|
|
|
* than ever-growing wiki pages.
|
2004-09-03 23:00:01 +00:00
|
|
|
*
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-04-14 23:10:40 +00:00
|
|
|
class LogPage {
|
2008-03-12 22:27:25 +00:00
|
|
|
const DELETED_ACTION = 1;
|
|
|
|
|
const DELETED_COMMENT = 2;
|
|
|
|
|
const DELETED_USER = 4;
|
|
|
|
|
const DELETED_RESTRICTED = 8;
|
2005-09-09 19:26:56 +00:00
|
|
|
/* @access private */
|
2008-07-09 06:44:31 +00:00
|
|
|
var $type, $action, $comment, $params, $target, $doer;
|
2005-09-09 19:26:56 +00:00
|
|
|
/* @acess public */
|
2009-01-09 18:30:47 +00:00
|
|
|
var $updateRecentChanges, $sendToUDP;
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2005-07-07 13:44:33 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*
|
2005-07-07 14:10:00 +00:00
|
|
|
* @param string $type One of '', 'block', 'protect', 'rights', 'delete',
|
2005-07-07 13:44:33 +00:00
|
|
|
* 'upload', 'move'
|
2005-09-09 19:26:56 +00:00
|
|
|
* @param bool $rc Whether to update recent changes as well as the logging table
|
2009-01-29 04:15:47 +00:00
|
|
|
* @param bool $udp Whether to send to the UDP feed if NOT sent to RC
|
2005-07-07 13:44:33 +00:00
|
|
|
*/
|
2009-01-29 04:15:47 +00:00
|
|
|
public function __construct( $type, $rc = true, $udp = 'skipUDP' ) {
|
2004-08-24 08:11:46 +00:00
|
|
|
$this->type = $type;
|
2005-09-09 19:26:56 +00:00
|
|
|
$this->updateRecentChanges = $rc;
|
2009-01-14 18:10:03 +00:00
|
|
|
$this->sendToUDP = ($udp == 'UDP');
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-22 22:36:00 +00:00
|
|
|
protected function saveContent() {
|
2009-01-09 23:18:47 +00:00
|
|
|
global $wgLogRestrictions;
|
2004-07-10 03:09:26 +00:00
|
|
|
|
2008-04-16 17:34:52 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2007-05-07 13:41:49 +00:00
|
|
|
$log_id = $dbw->nextSequenceValue( 'log_log_id_seq' );
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-08-24 08:11:46 +00:00
|
|
|
$this->timestamp = $now = wfTimestampNow();
|
2007-05-07 13:41:49 +00:00
|
|
|
$data = array(
|
2008-04-28 02:10:31 +00:00
|
|
|
'log_id' => $log_id,
|
2007-05-07 13:41:49 +00:00
|
|
|
'log_type' => $this->type,
|
|
|
|
|
'log_action' => $this->action,
|
|
|
|
|
'log_timestamp' => $dbw->timestamp( $now ),
|
2008-07-09 06:44:31 +00:00
|
|
|
'log_user' => $this->doer->getId(),
|
2007-05-07 13:41:49 +00:00
|
|
|
'log_namespace' => $this->target->getNamespace(),
|
|
|
|
|
'log_title' => $this->target->getDBkey(),
|
|
|
|
|
'log_comment' => $this->comment,
|
|
|
|
|
'log_params' => $this->params
|
2004-08-24 08:11:46 +00:00
|
|
|
);
|
2009-01-09 23:18:47 +00:00
|
|
|
$dbw->insert( 'logging', $data, __METHOD__ );
|
2008-04-28 02:10:31 +00:00
|
|
|
$newId = !is_null($log_id) ? $log_id : $dbw->insertId();
|
2007-05-07 13:41:49 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
# And update recentchanges
|
2008-04-27 23:45:31 +00:00
|
|
|
if( $this->updateRecentChanges ) {
|
2009-01-09 18:38:10 +00:00
|
|
|
$titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
|
2009-01-09 18:44:52 +00:00
|
|
|
RecentChange::notifyLog( $now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type,
|
2009-01-09 18:38:10 +00:00
|
|
|
$this->action, $this->target, $this->comment, $this->params, $newId );
|
2009-01-09 18:30:47 +00:00
|
|
|
} else if( $this->sendToUDP ) {
|
2009-01-09 18:44:52 +00:00
|
|
|
# Don't send private logs to UDP
|
|
|
|
|
if( isset($wgLogRestrictions[$this->type]) && $wgLogRestrictions[$this->type] !='*' ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2009-01-09 18:30:47 +00:00
|
|
|
# Notify external application via UDP.
|
|
|
|
|
# We send this to IRC but do not want to add it the RC table.
|
|
|
|
|
$titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
|
2009-01-09 18:44:52 +00:00
|
|
|
$rc = RecentChange::newLogEntry( $now, $titleObj, $this->doer, $this->getRcComment(), '',
|
2009-01-09 18:30:47 +00:00
|
|
|
$this->type, $this->action, $this->target, $this->comment, $this->params, $newId );
|
2009-01-15 01:42:11 +00:00
|
|
|
$rc->notifyRC2UDP();
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2009-05-13 22:03:32 +00:00
|
|
|
return $newId;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2008-08-25 03:08:56 +00:00
|
|
|
/**
|
|
|
|
|
* Get the RC comment from the last addEntry() call
|
|
|
|
|
*/
|
2007-06-16 02:55:25 +00:00
|
|
|
public function getRcComment() {
|
|
|
|
|
$rcComment = $this->actionText;
|
|
|
|
|
if( '' != $this->comment ) {
|
|
|
|
|
if ($rcComment == '')
|
|
|
|
|
$rcComment = $this->comment;
|
|
|
|
|
else
|
2009-01-07 22:49:54 +00:00
|
|
|
$rcComment .= wfMsgForContent( 'colon-separator' ) . $this->comment;
|
2007-06-16 02:55:25 +00:00
|
|
|
}
|
|
|
|
|
return $rcComment;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-25 03:08:56 +00:00
|
|
|
/**
|
|
|
|
|
* Get the comment from the last addEntry() call
|
|
|
|
|
*/
|
|
|
|
|
public function getComment() {
|
|
|
|
|
return $this->comment;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* @static
|
|
|
|
|
*/
|
2007-05-02 20:37:13 +00:00
|
|
|
public static function validTypes() {
|
2006-05-25 07:37:20 +00:00
|
|
|
global $wgLogTypes;
|
|
|
|
|
return $wgLogTypes;
|
2004-08-25 02:13:32 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* @static
|
|
|
|
|
*/
|
2007-05-02 20:37:13 +00:00
|
|
|
public static function isLogType( $type ) {
|
2004-08-25 02:13:32 +00:00
|
|
|
return in_array( $type, LogPage::validTypes() );
|
|
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* @static
|
|
|
|
|
*/
|
2006-11-29 05:45:03 +00:00
|
|
|
public static function logName( $type ) {
|
2007-09-28 09:01:32 +00:00
|
|
|
global $wgLogNames, $wgMessageCache;
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-05-25 07:37:20 +00:00
|
|
|
if( isset( $wgLogNames[$type] ) ) {
|
2007-09-28 09:01:32 +00:00
|
|
|
$wgMessageCache->loadAllMessages();
|
2006-05-25 07:37:20 +00:00
|
|
|
return str_replace( '_', ' ', wfMsg( $wgLogNames[$type] ) );
|
2006-02-14 21:24:48 +00:00
|
|
|
} else {
|
|
|
|
|
// Bogus log types? Perhaps an extension was removed.
|
|
|
|
|
return $type;
|
|
|
|
|
}
|
2004-08-25 02:13:32 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2007-04-04 05:22:37 +00:00
|
|
|
* @todo handle missing log types
|
2008-04-08 19:34:43 +00:00
|
|
|
* @param string $type logtype
|
|
|
|
|
* @return string Headertext of this logtype
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2009-01-09 23:18:47 +00:00
|
|
|
public static function logHeader( $type ) {
|
2008-08-20 09:43:46 +00:00
|
|
|
global $wgLogHeaders, $wgMessageCache;
|
|
|
|
|
$wgMessageCache->loadAllMessages();
|
2008-04-08 22:50:56 +00:00
|
|
|
return wfMsgExt($wgLogHeaders[$type],array('parseinline'));
|
2004-08-25 02:13:32 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* @static
|
2008-07-06 20:19:04 +00:00
|
|
|
* @return HTML string
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2009-01-09 23:18:47 +00:00
|
|
|
public static function actionText( $type, $action, $title = NULL, $skin = NULL,
|
2008-09-16 05:21:10 +00:00
|
|
|
$params = array(), $filterWikilinks = false )
|
|
|
|
|
{
|
2008-08-20 09:43:46 +00:00
|
|
|
global $wgLang, $wgContLang, $wgLogActions, $wgMessageCache;
|
2005-09-30 15:03:48 +00:00
|
|
|
|
2008-08-20 09:43:46 +00:00
|
|
|
$wgMessageCache->loadAllMessages();
|
2004-08-24 08:11:46 +00:00
|
|
|
$key = "$type/$action";
|
2008-09-10 22:29:24 +00:00
|
|
|
# Defer patrol log to PatrolLog class
|
|
|
|
|
if( $key == 'patrol/patrol' ) {
|
2007-01-16 17:05:30 +00:00
|
|
|
return PatrolLog::makeActionText( $title, $params, $skin );
|
2008-09-10 22:29:24 +00:00
|
|
|
}
|
2006-05-25 07:37:20 +00:00
|
|
|
if( isset( $wgLogActions[$key] ) ) {
|
2005-04-03 07:36:50 +00:00
|
|
|
if( is_null( $title ) ) {
|
2008-09-05 04:53:49 +00:00
|
|
|
$rv = wfMsg( $wgLogActions[$key] );
|
2005-06-19 20:25:09 +00:00
|
|
|
} else {
|
2008-09-10 22:29:24 +00:00
|
|
|
$titleLink = self::getTitleLink( $type, $skin, $title, $params );
|
2006-06-20 09:09:20 +00:00
|
|
|
if( $key == 'rights/rights' ) {
|
2008-09-05 04:53:49 +00:00
|
|
|
if( $skin ) {
|
2006-11-08 05:21:15 +00:00
|
|
|
$rightsnone = wfMsg( 'rightsnone' );
|
2008-07-11 17:37:45 +00:00
|
|
|
foreach ( $params as &$param ) {
|
|
|
|
|
$groupArray = array_map( 'trim', explode( ',', $param ) );
|
|
|
|
|
$groupArray = array_map( array( 'User', 'getGroupName' ), $groupArray );
|
|
|
|
|
$param = $wgLang->listToText( $groupArray );
|
|
|
|
|
}
|
2006-11-08 07:12:03 +00:00
|
|
|
} else {
|
|
|
|
|
$rightsnone = wfMsgForContent( 'rightsnone' );
|
2006-06-20 09:09:20 +00:00
|
|
|
}
|
|
|
|
|
if( !isset( $params[0] ) || trim( $params[0] ) == '' )
|
|
|
|
|
$params[0] = $rightsnone;
|
|
|
|
|
if( !isset( $params[1] ) || trim( $params[1] ) == '' )
|
|
|
|
|
$params[1] = $rightsnone;
|
|
|
|
|
}
|
2005-06-19 20:25:09 +00:00
|
|
|
if( count( $params ) == 0 ) {
|
2006-11-08 07:12:03 +00:00
|
|
|
if ( $skin ) {
|
2006-11-08 05:21:15 +00:00
|
|
|
$rv = wfMsg( $wgLogActions[$key], $titleLink );
|
2006-11-08 07:12:03 +00:00
|
|
|
} else {
|
|
|
|
|
$rv = wfMsgForContent( $wgLogActions[$key], $titleLink );
|
2006-04-18 18:05:13 +00:00
|
|
|
}
|
2005-04-03 07:36:50 +00:00
|
|
|
} else {
|
2008-09-10 22:06:41 +00:00
|
|
|
$details = '';
|
2005-04-03 07:36:50 +00:00
|
|
|
array_unshift( $params, $titleLink );
|
2009-04-10 20:01:10 +00:00
|
|
|
// User suppression
|
2009-03-14 10:02:17 +00:00
|
|
|
if ( preg_match( '/^(block|suppress)\/(block|reblock)$/', $key ) ) {
|
2007-09-10 01:53:24 +00:00
|
|
|
if ( $skin ) {
|
2008-09-10 22:06:41 +00:00
|
|
|
$params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' .
|
|
|
|
|
$wgLang->translateBlockExpiry( $params[1] ) . '</span>';
|
2007-09-10 01:53:24 +00:00
|
|
|
} else {
|
|
|
|
|
$params[1] = $wgContLang->translateBlockExpiry( $params[1] );
|
2007-03-21 17:04:01 +00:00
|
|
|
}
|
2008-09-10 22:06:41 +00:00
|
|
|
$params[2] = isset( $params[2] ) ?
|
|
|
|
|
self::formatBlockFlags( $params[2], is_null( $skin ) ) : '';
|
2009-04-10 20:01:10 +00:00
|
|
|
// Page protections
|
2008-09-13 05:33:24 +00:00
|
|
|
} else if ( $type == 'protect' && count($params) == 3 ) {
|
2008-09-15 18:50:54 +00:00
|
|
|
$details .= " {$params[1]}"; // restrictions and expiries
|
2008-09-13 05:33:24 +00:00
|
|
|
if( $params[2] ) {
|
2009-01-25 18:45:42 +00:00
|
|
|
if ( $skin ) {
|
|
|
|
|
$details .= ' ['.wfMsg('protect-summary-cascade').']';
|
|
|
|
|
} else {
|
|
|
|
|
$details .= ' ['.wfMsgForContent('protect-summary-cascade').']';
|
|
|
|
|
}
|
2008-09-10 22:06:41 +00:00
|
|
|
}
|
2009-04-10 20:01:10 +00:00
|
|
|
// Page moves
|
2008-12-30 17:52:43 +00:00
|
|
|
} else if ( $type == 'move' && count( $params ) == 3 ) {
|
|
|
|
|
if( $params[2] ) {
|
2009-01-25 18:45:42 +00:00
|
|
|
if ( $skin ) {
|
|
|
|
|
$details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']';
|
|
|
|
|
} else {
|
|
|
|
|
$details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']';
|
|
|
|
|
}
|
2008-12-30 17:52:43 +00:00
|
|
|
}
|
2009-04-10 20:01:10 +00:00
|
|
|
// Revision deletion
|
|
|
|
|
} else if ( preg_match( '/^(delete|suppress)\/revision$/', $key ) && count( $params ) == 5 ) {
|
2009-04-11 17:46:55 +00:00
|
|
|
$count = substr_count( $params[2], ',' ) + 1; // revisions
|
2009-04-10 20:01:10 +00:00
|
|
|
$ofield = intval( substr( $params[3], 7 ) ); // <ofield=x>
|
|
|
|
|
$nfield = intval( substr( $params[4], 7 ) ); // <nfield=x>
|
|
|
|
|
$details .= ': '.RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false );
|
|
|
|
|
// Log deletion
|
|
|
|
|
} else if ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) {
|
|
|
|
|
$count = substr_count( $params[1], ',' ) + 1; // log items
|
|
|
|
|
$ofield = intval( substr( $params[2], 7 ) ); // <ofield=x>
|
|
|
|
|
$nfield = intval( substr( $params[3], 7 ) ); // <nfield=x>
|
|
|
|
|
$details .= ': '.RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true );
|
2005-08-27 16:35:10 +00:00
|
|
|
}
|
2008-09-10 22:06:41 +00:00
|
|
|
$rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ) . $details;
|
2005-04-03 07:36:50 +00:00
|
|
|
}
|
2004-08-25 17:24:31 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
} else {
|
2008-05-14 19:12:00 +00:00
|
|
|
global $wgLogActionsHandlers;
|
|
|
|
|
if( isset( $wgLogActionsHandlers[$key] ) ) {
|
|
|
|
|
$args = func_get_args();
|
|
|
|
|
$rv = call_user_func_array( $wgLogActionsHandlers[$key], $args );
|
|
|
|
|
} else {
|
|
|
|
|
wfDebug( "LogPage::actionText - unknown action $key\n" );
|
|
|
|
|
$rv = "$action";
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2009-03-04 01:28:05 +00:00
|
|
|
|
|
|
|
|
// For the perplexed, this feature was added in r7855 by Erik.
|
|
|
|
|
// The feature was added because we liked adding [[$1]] in our log entries
|
|
|
|
|
// but the log entries are parsed as Wikitext on RecentChanges but as HTML
|
|
|
|
|
// on Special:Log. The hack is essentially that [[$1]] represented a link
|
|
|
|
|
// to the title in question. The first parameter to the HTML version (Special:Log)
|
|
|
|
|
// is that link in HTML form, and so this just gets rid of the ugly [[]].
|
|
|
|
|
// However, this is a horrible hack and it doesn't work like you expect if, say,
|
|
|
|
|
// you want to link to something OTHER than the title of the log entry.
|
2009-03-04 01:44:02 +00:00
|
|
|
// The real problem, which Erik was trying to fix (and it sort-of works now) is
|
|
|
|
|
// that the same messages are being treated as both wikitext *and* HTML.
|
2005-06-19 20:25:09 +00:00
|
|
|
if( $filterWikilinks ) {
|
2006-11-08 07:12:03 +00:00
|
|
|
$rv = str_replace( "[[", "", $rv );
|
|
|
|
|
$rv = str_replace( "]]", "", $rv );
|
2005-03-24 13:13:08 +00:00
|
|
|
}
|
|
|
|
|
return $rv;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-09-10 22:29:24 +00:00
|
|
|
|
|
|
|
|
protected static function getTitleLink( $type, $skin, $title, &$params ) {
|
|
|
|
|
global $wgLang, $wgContLang;
|
|
|
|
|
if( !$skin ) {
|
|
|
|
|
return $title->getPrefixedText();
|
|
|
|
|
}
|
|
|
|
|
switch( $type ) {
|
|
|
|
|
case 'move':
|
2009-05-08 23:24:31 +00:00
|
|
|
$titleLink = $skin->link(
|
|
|
|
|
$title,
|
|
|
|
|
htmlspecialchars( $title->getPrefixedText() ),
|
|
|
|
|
array(),
|
|
|
|
|
array( 'redirect' => 'no' )
|
|
|
|
|
);
|
2008-09-10 22:29:24 +00:00
|
|
|
$targetTitle = Title::newFromText( $params[0] );
|
|
|
|
|
if ( !$targetTitle ) {
|
|
|
|
|
# Workaround for broken database
|
|
|
|
|
$params[0] = htmlspecialchars( $params[0] );
|
|
|
|
|
} else {
|
2009-05-08 23:24:31 +00:00
|
|
|
$params[0] = $skin->link(
|
|
|
|
|
$targetTitle,
|
|
|
|
|
htmlspecialchars( $params[0] )
|
|
|
|
|
);
|
2008-09-10 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'block':
|
|
|
|
|
if( substr( $title->getText(), 0, 1 ) == '#' ) {
|
|
|
|
|
$titleLink = $title->getText();
|
|
|
|
|
} else {
|
|
|
|
|
// TODO: Store the user identifier in the parameters
|
|
|
|
|
// to make this faster for future log entries
|
|
|
|
|
$id = User::idFromName( $title->getText() );
|
|
|
|
|
$titleLink = $skin->userLink( $id, $title->getText() )
|
|
|
|
|
. $skin->userToolLinks( $id, $title->getText(), false, Linker::TOOL_LINKS_NOBLOCK );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'rights':
|
|
|
|
|
$text = $wgContLang->ucfirst( $title->getText() );
|
2009-05-08 23:24:31 +00:00
|
|
|
$titleLink = $skin->link( Title::makeTitle( NS_USER, $text ) );
|
2008-09-10 22:29:24 +00:00
|
|
|
break;
|
|
|
|
|
case 'merge':
|
2009-05-08 23:24:31 +00:00
|
|
|
$titleLink = $skin->link(
|
|
|
|
|
$title,
|
|
|
|
|
$title->getPrefixedText(),
|
|
|
|
|
array(),
|
|
|
|
|
array( 'redirect' => 'no' )
|
|
|
|
|
);
|
|
|
|
|
$params[0] = $skin->link(
|
|
|
|
|
Title::newFromText( $params[0] ),
|
|
|
|
|
htmlspecialchars( $params[0] )
|
|
|
|
|
);
|
2008-09-10 22:29:24 +00:00
|
|
|
$params[1] = $wgLang->timeanddate( $params[1] );
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if( $title->getNamespace() == NS_SPECIAL ) {
|
|
|
|
|
list( $name, $par ) = SpecialPage::resolveAliasWithSubpage( $title->getDBKey() );
|
|
|
|
|
# Use the language name for log titles, rather than Log/X
|
|
|
|
|
if( $name == 'Log' ) {
|
2009-05-08 23:24:31 +00:00
|
|
|
$titleLink = '('.$skin->link( $title, LogPage::logName( $par ) ).')';
|
2008-09-10 22:29:24 +00:00
|
|
|
} else {
|
2009-05-08 23:24:31 +00:00
|
|
|
$titleLink = $skin->link( $title );
|
2008-09-10 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2009-05-08 23:24:31 +00:00
|
|
|
$titleLink = $skin->link( $title );
|
2008-09-10 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $titleLink;
|
|
|
|
|
}
|
2004-10-24 19:14:48 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a log entry
|
2005-07-07 14:10:00 +00:00
|
|
|
* @param string $action one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir'
|
2005-01-31 04:07:56 +00:00
|
|
|
* @param object &$target A title object.
|
2004-10-24 19:14:48 +00:00
|
|
|
* @param string $comment Description associated
|
2005-01-31 04:07:56 +00:00
|
|
|
* @param array $params Parameters passed later to wfMsg.* functions
|
2008-07-09 06:44:31 +00:00
|
|
|
* @param User $doer The user doing the action
|
2004-10-24 19:14:48 +00:00
|
|
|
*/
|
2009-01-09 23:18:47 +00:00
|
|
|
public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) {
|
2005-01-14 13:47:19 +00:00
|
|
|
if ( !is_array( $params ) ) {
|
|
|
|
|
$params = array( $params );
|
|
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2004-08-24 08:11:46 +00:00
|
|
|
$this->action = $action;
|
2006-07-14 04:13:49 +00:00
|
|
|
$this->target = $target;
|
2004-08-24 08:11:46 +00:00
|
|
|
$this->comment = $comment;
|
2006-11-08 07:12:03 +00:00
|
|
|
$this->params = LogPage::makeParamBlob( $params );
|
2008-07-09 06:44:31 +00:00
|
|
|
|
|
|
|
|
if ($doer === null) {
|
|
|
|
|
global $wgUser;
|
2008-07-09 08:21:51 +00:00
|
|
|
$doer = $wgUser;
|
2008-07-09 06:44:31 +00:00
|
|
|
} elseif (!is_object( $doer ) ) {
|
|
|
|
|
$doer = User::newFromId( $doer );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->doer = $doer;
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2007-03-16 16:01:07 +00:00
|
|
|
$this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params );
|
2005-04-03 07:36:50 +00:00
|
|
|
|
2008-04-16 17:34:52 +00:00
|
|
|
return $this->saveContent();
|
2003-05-16 11:19:06 +00:00
|
|
|
}
|
2009-05-13 22:03:32 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add relations to log_search table
|
|
|
|
|
* @static
|
|
|
|
|
*/
|
|
|
|
|
public function addRelations( $field, $values, $logid ) {
|
|
|
|
|
if( empty($values) )
|
|
|
|
|
return false; // nothing
|
|
|
|
|
$data = array();
|
|
|
|
|
foreach( $values as $value ) {
|
|
|
|
|
$data[] = array('ls_field' => $field,'ls_value' => $value,'ls_log_id' => $logid);
|
|
|
|
|
}
|
|
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
|
|
|
|
$dbw->insert( 'log_search', $data, __METHOD__, 'IGNORE' );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2005-01-14 13:47:19 +00:00
|
|
|
|
2005-08-02 13:35:19 +00:00
|
|
|
/**
|
2005-01-14 13:47:19 +00:00
|
|
|
* Create a blob from a parameter array
|
|
|
|
|
* @static
|
|
|
|
|
*/
|
2009-01-09 23:18:47 +00:00
|
|
|
public static function makeParamBlob( $params ) {
|
2005-01-14 13:47:19 +00:00
|
|
|
return implode( "\n", $params );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Extract a parameter array from a blob
|
|
|
|
|
* @static
|
|
|
|
|
*/
|
2009-01-09 23:18:47 +00:00
|
|
|
public static function extractParams( $blob ) {
|
2005-01-14 13:47:19 +00:00
|
|
|
if ( $blob === '' ) {
|
|
|
|
|
return array();
|
|
|
|
|
} else {
|
|
|
|
|
return explode( "\n", $blob );
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-01-09 01:54:52 +00:00
|
|
|
/**
|
|
|
|
|
* Convert a comma-delimited list of block log flags
|
|
|
|
|
* into a more readable (and translated) form
|
|
|
|
|
*
|
|
|
|
|
* @param $flags Flags to format
|
2008-03-06 15:01:45 +00:00
|
|
|
* @param $forContent Whether to localize the message depending of the user
|
2008-03-06 14:45:27 +00:00
|
|
|
* language
|
2007-01-09 01:54:52 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2008-03-06 14:45:27 +00:00
|
|
|
public static function formatBlockFlags( $flags, $forContent = false ) {
|
2009-03-08 19:40:09 +00:00
|
|
|
global $wgLang;
|
|
|
|
|
|
2007-01-09 01:54:52 +00:00
|
|
|
$flags = explode( ',', trim( $flags ) );
|
|
|
|
|
if( count( $flags ) > 0 ) {
|
|
|
|
|
for( $i = 0; $i < count( $flags ); $i++ )
|
2008-03-06 14:45:27 +00:00
|
|
|
$flags[$i] = self::formatBlockFlag( $flags[$i], $forContent );
|
2009-03-08 19:40:09 +00:00
|
|
|
return '(' . $wgLang->commaList( $flags ) . ')';
|
2007-01-09 01:54:52 +00:00
|
|
|
} else {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-01-09 01:54:52 +00:00
|
|
|
/**
|
|
|
|
|
* Translate a block log flag if possible
|
|
|
|
|
*
|
|
|
|
|
* @param $flag Flag to translate
|
2008-03-06 15:01:45 +00:00
|
|
|
* @param $forContent Whether to localize the message depending of the user
|
2008-03-06 14:45:27 +00:00
|
|
|
* language
|
2007-01-09 01:54:52 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2008-03-06 14:45:27 +00:00
|
|
|
public static function formatBlockFlag( $flag, $forContent = false ) {
|
2007-01-09 01:54:52 +00:00
|
|
|
static $messages = array();
|
|
|
|
|
if( !isset( $messages[$flag] ) ) {
|
|
|
|
|
$k = 'block-log-flags-' . $flag;
|
2008-03-06 14:45:27 +00:00
|
|
|
if( $forContent )
|
|
|
|
|
$msg = wfMsgForContent( $k );
|
|
|
|
|
else
|
|
|
|
|
$msg = wfMsg( $k );
|
2007-01-09 01:54:52 +00:00
|
|
|
$messages[$flag] = htmlspecialchars( wfEmptyMsg( $k, $msg ) ? $flag : $msg );
|
|
|
|
|
}
|
|
|
|
|
return $messages[$flag];
|
|
|
|
|
}
|
2008-03-12 22:27:25 +00:00
|
|
|
}
|
2007-06-29 01:19:14 +00:00
|
|
|
|
2008-03-12 22:27:25 +00:00
|
|
|
/**
|
|
|
|
|
* Aliases for backwards compatibility with 1.6
|
|
|
|
|
*/
|
|
|
|
|
define( 'MW_LOG_DELETED_ACTION', LogPage::DELETED_ACTION );
|
|
|
|
|
define( 'MW_LOG_DELETED_USER', LogPage::DELETED_USER );
|
|
|
|
|
define( 'MW_LOG_DELETED_COMMENT', LogPage::DELETED_COMMENT );
|
|
|
|
|
define( 'MW_LOG_DELETED_RESTRICTED', LogPage::DELETED_RESTRICTED );
|