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 */
|
2006-05-11 22:40:38 +00:00
|
|
|
var $updateRecentChanges;
|
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
|
2005-07-07 13:44:33 +00:00
|
|
|
*/
|
2007-01-20 13:34:31 +00:00
|
|
|
function __construct( $type, $rc = true ) {
|
2004-08-24 08:11:46 +00:00
|
|
|
$this->type = $type;
|
2005-09-09 19:26:56 +00:00
|
|
|
$this->updateRecentChanges = $rc;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-22 22:36:00 +00:00
|
|
|
protected function saveContent() {
|
2008-04-02 05:48:16 +00:00
|
|
|
global $wgUser, $wgLogRestrictions;
|
2004-08-22 17:24:50 +00:00
|
|
|
$fname = 'LogPage::saveContent';
|
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
|
|
|
);
|
2007-05-07 13:41:49 +00:00
|
|
|
$dbw->insert( 'logging', $data, $fname );
|
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
|
|
|
|
2008-04-28 01:31:44 +00:00
|
|
|
if( !($dbw->affectedRows() > 0) ) {
|
|
|
|
|
wfDebugLog( "logging", "LogPage::saveContent failed to insert row - Error {$dbw->lastErrno()}: {$dbw->lastError()}" );
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
# And update recentchanges
|
2008-04-27 23:45:31 +00:00
|
|
|
if( $this->updateRecentChanges ) {
|
2008-04-02 05:48:16 +00:00
|
|
|
# Don't add private logs to RC!
|
|
|
|
|
if( !isset($wgLogRestrictions[$this->type]) || $wgLogRestrictions[$this->type]=='*' ) {
|
|
|
|
|
$titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
|
|
|
|
|
$rcComment = $this->getRcComment();
|
2008-07-09 06:44:31 +00:00
|
|
|
RecentChange::notifyLog( $now, $titleObj, $this->doer, $rcComment, '',
|
2008-04-02 05:48:16 +00:00
|
|
|
$this->type, $this->action, $this->target, $this->comment, $this->params, $newId );
|
|
|
|
|
}
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2008-04-27 23:45:31 +00:00
|
|
|
return true;
|
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
|
|
|
|
|
$rcComment .= ': ' . $this->comment;
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2007-05-02 20:37:13 +00:00
|
|
|
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
|
|
|
*/
|
2008-09-16 05:21:10 +00:00
|
|
|
static function actionText( $type, $action, $title = NULL, $skin = NULL,
|
|
|
|
|
$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 );
|
2008-10-30 21:45:16 +00:00
|
|
|
if ( $key == 'block/block' || $key == 'suppress/block' || $key == 'block/reblock' ) {
|
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 ) ) : '';
|
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] ) {
|
2008-09-10 22:06:41 +00:00
|
|
|
$details .= ' ['.wfMsg('protect-summary-cascade').']';
|
|
|
|
|
}
|
2008-12-30 17:52:43 +00:00
|
|
|
} else if ( $type == 'move' && count( $params ) == 3 ) {
|
|
|
|
|
if( $params[2] ) {
|
|
|
|
|
$details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']';
|
|
|
|
|
}
|
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
|
|
|
}
|
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':
|
|
|
|
|
$titleLink = $skin->makeLinkObj( $title,
|
|
|
|
|
htmlspecialchars( $title->getPrefixedText() ), 'redirect=no' );
|
|
|
|
|
$targetTitle = Title::newFromText( $params[0] );
|
|
|
|
|
if ( !$targetTitle ) {
|
|
|
|
|
# Workaround for broken database
|
|
|
|
|
$params[0] = htmlspecialchars( $params[0] );
|
|
|
|
|
} else {
|
|
|
|
|
$params[0] = $skin->makeLinkObj( $targetTitle, htmlspecialchars( $params[0] ) );
|
|
|
|
|
}
|
|
|
|
|
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() );
|
|
|
|
|
$titleLink = $skin->makeLinkObj( Title::makeTitle( NS_USER, $text ) );
|
|
|
|
|
break;
|
|
|
|
|
case 'merge':
|
|
|
|
|
$titleLink = $skin->makeLinkObj( $title, $title->getPrefixedText(), 'redirect=no' );
|
|
|
|
|
$params[0] = $skin->makeLinkObj( Title::newFromText( $params[0] ), htmlspecialchars( $params[0] ) );
|
|
|
|
|
$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' ) {
|
|
|
|
|
$titleLink = '('.$skin->makeLinkObj( $title, LogPage::logName( $par ) ).')';
|
|
|
|
|
} else {
|
|
|
|
|
$titleLink = $skin->makeLinkObj( $title );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$titleLink = $skin->makeLinkObj( $title );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2008-07-09 06:44:31 +00:00
|
|
|
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
|
|
|
}
|
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
|
|
|
|
|
*/
|
2007-05-02 20:37:13 +00:00
|
|
|
static function makeParamBlob( $params ) {
|
2005-01-14 13:47:19 +00:00
|
|
|
return implode( "\n", $params );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Extract a parameter array from a blob
|
|
|
|
|
* @static
|
|
|
|
|
*/
|
2007-05-02 20:37:13 +00:00
|
|
|
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 ) {
|
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 );
|
2007-01-09 01:54:52 +00:00
|
|
|
return '(' . implode( ', ', $flags ) . ')';
|
|
|
|
|
} 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 );
|