2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Contain log classes
|
2010-08-08 14:28:01 +00:00
|
|
|
*
|
|
|
|
|
* Copyright © 2002, 2004 Brion Vibber <brion@pobox.com>
|
|
|
|
|
* 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
|
|
|
|
|
*
|
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;
|
2009-11-14 21:27:13 +00:00
|
|
|
const DELETED_RESTRICTED = 8;
|
2009-07-30 14:08:25 +00:00
|
|
|
// Convenience fields
|
|
|
|
|
const SUPPRESSED_USER = 12;
|
|
|
|
|
const SUPPRESSED_ACTION = 9;
|
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
|
|
|
/**
|
2010-08-21 12:00:28 +00:00
|
|
|
* Constructor
|
|
|
|
|
*
|
|
|
|
|
* @param $type String: one of '', 'block', 'protect', 'rights', 'delete',
|
|
|
|
|
* 'upload', 'move'
|
|
|
|
|
* @param $rc Boolean: whether to update recent changes as well as the logging table
|
|
|
|
|
* @param $udp String: pass 'UDP' to send to the UDP feed if NOT sent to RC
|
|
|
|
|
*/
|
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;
|
2010-08-21 12:00:28 +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 );
|
2009-10-28 16:17:16 +00:00
|
|
|
$log_id = $dbw->nextSequenceValue( 'logging_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(),
|
2009-06-27 10:17:01 +00:00
|
|
|
'log_user_text' => $this->doer->getName(),
|
2007-05-07 13:41:49 +00:00
|
|
|
'log_namespace' => $this->target->getNamespace(),
|
|
|
|
|
'log_title' => $this->target->getDBkey(),
|
2009-09-16 13:28:01 +00:00
|
|
|
'log_page' => $this->target->getArticleId(),
|
2007-05-07 13:41:49 +00:00
|
|
|
'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__ );
|
2010-08-21 12:00:28 +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 );
|
2010-08-21 12:00:28 +00:00
|
|
|
RecentChange::notifyLog(
|
|
|
|
|
$now, $titleObj, $this->doer, $this->getRcComment(), '',
|
|
|
|
|
$this->type, $this->action, $this->target, $this->comment,
|
|
|
|
|
$this->params, $newId
|
|
|
|
|
);
|
|
|
|
|
} elseif( $this->sendToUDP ) {
|
2009-01-09 18:44:52 +00:00
|
|
|
# Don't send private logs to UDP
|
2010-08-21 12:00:28 +00:00
|
|
|
if( isset( $wgLogRestrictions[$this->type] ) && $wgLogRestrictions[$this->type] != '*' ) {
|
2009-01-09 18:44:52 +00:00
|
|
|
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 );
|
2010-08-21 12:00:28 +00:00
|
|
|
$rc = RecentChange::newLogEntry(
|
|
|
|
|
$now, $titleObj, $this->doer, $this->getRcComment(), '',
|
|
|
|
|
$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;
|
2010-01-06 19:59:42 +00:00
|
|
|
if( $this->comment != '' ) {
|
2010-08-21 12:00:28 +00:00
|
|
|
if ( $rcComment == '' ) {
|
2007-06-16 02:55:25 +00:00
|
|
|
$rcComment = $this->comment;
|
2010-08-21 12:00:28 +00:00
|
|
|
} else {
|
2009-01-07 22:49:54 +00:00
|
|
|
$rcComment .= wfMsgForContent( 'colon-separator' ) . $this->comment;
|
2010-08-21 12:00:28 +00:00
|
|
|
}
|
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
|
|
|
/**
|
2010-05-18 20:59:14 +00:00
|
|
|
* Get the list of valid log types
|
|
|
|
|
*
|
|
|
|
|
* @return Array of strings
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
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
|
|
|
/**
|
2010-05-18 20:59:14 +00:00
|
|
|
* Is $type a valid log type
|
|
|
|
|
*
|
|
|
|
|
* @param $type String: log type to check
|
|
|
|
|
* @return Boolean
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
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
|
|
|
/**
|
2010-05-18 20:59:14 +00:00
|
|
|
* Get the name for the given log type
|
|
|
|
|
*
|
|
|
|
|
* @param $type String: logtype
|
|
|
|
|
* @return String: log name
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-29 05:45:03 +00:00
|
|
|
public static function logName( $type ) {
|
2010-08-03 19:15:43 +00:00
|
|
|
global $wgLogNames;
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-05-25 07:37:20 +00:00
|
|
|
if( isset( $wgLogNames[$type] ) ) {
|
|
|
|
|
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
|
|
|
/**
|
2010-05-18 20:59:14 +00:00
|
|
|
* Get the log header for the given log type
|
|
|
|
|
*
|
2007-04-04 05:22:37 +00:00
|
|
|
* @todo handle missing log types
|
2010-05-18 20:59:14 +00:00
|
|
|
* @param $type String: 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 ) {
|
2010-08-03 19:15:43 +00:00
|
|
|
global $wgLogHeaders;
|
2010-08-21 12:00:28 +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
|
|
|
/**
|
2010-05-18 20:59:14 +00:00
|
|
|
* Generate text for a log entry
|
|
|
|
|
*
|
|
|
|
|
* @param $type String: log type
|
|
|
|
|
* @param $action String: log action
|
|
|
|
|
* @param $title Mixed: Title object or null
|
|
|
|
|
* @param $skin Mixed: Skin object or null. If null, we want to use the wiki
|
2010-08-21 12:00:28 +00:00
|
|
|
* content language, since that will go to the IRC feed.
|
2010-05-18 20:59:14 +00:00
|
|
|
* @param $params Array: parameters
|
|
|
|
|
* @param $filterWikilinks Boolean: whether to filter wiki links
|
2008-07-06 20:19:04 +00:00
|
|
|
* @return HTML string
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2010-05-18 20:59:14 +00:00
|
|
|
public static function actionText( $type, $action, $title = null, $skin = null,
|
2010-08-21 12:00:28 +00:00
|
|
|
$params = array(), $filterWikilinks = false )
|
2008-09-16 05:21:10 +00:00
|
|
|
{
|
2010-08-03 19:15:43 +00:00
|
|
|
global $wgLang, $wgContLang, $wgLogActions;
|
2005-09-30 15:03:48 +00:00
|
|
|
|
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 ) ) {
|
2009-05-22 09:35:48 +00:00
|
|
|
$rv = wfMsgHtml( $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 ) );
|
2010-04-08 10:15:04 +00:00
|
|
|
$groupArray = array_map( array( 'User', 'getGroupMember' ), $groupArray );
|
2008-07-11 17:37:45 +00:00
|
|
|
$param = $wgLang->listToText( $groupArray );
|
|
|
|
|
}
|
2006-11-08 07:12:03 +00:00
|
|
|
} else {
|
|
|
|
|
$rightsnone = wfMsgForContent( 'rightsnone' );
|
2006-06-20 09:09:20 +00:00
|
|
|
}
|
2010-08-21 12:00:28 +00:00
|
|
|
if( !isset( $params[0] ) || trim( $params[0] ) == '' ) {
|
2006-06-20 09:09:20 +00:00
|
|
|
$params[0] = $rightsnone;
|
2010-08-21 12:00:28 +00:00
|
|
|
}
|
|
|
|
|
if( !isset( $params[1] ) || trim( $params[1] ) == '' ) {
|
2006-06-20 09:09:20 +00:00
|
|
|
$params[1] = $rightsnone;
|
2010-08-21 12:00:28 +00:00
|
|
|
}
|
2006-06-20 09:09:20 +00:00
|
|
|
}
|
2005-06-19 20:25:09 +00:00
|
|
|
if( count( $params ) == 0 ) {
|
2006-11-08 07:12:03 +00:00
|
|
|
if ( $skin ) {
|
2009-05-22 09:35:48 +00:00
|
|
|
$rv = wfMsgHtml( $wgLogActions[$key], $titleLink );
|
2006-11-08 07:12:03 +00:00
|
|
|
} else {
|
2009-05-22 09:35:48 +00:00
|
|
|
$rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'content' ), $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 ) {
|
2010-11-08 15:23:42 +00:00
|
|
|
$params[1] = '<span class="blockExpiry" dir="ltr" title="' . htmlspecialchars( $params[1] ). '">' .
|
2008-09-10 22:06:41 +00:00
|
|
|
$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
|
|
|
}
|
2010-08-21 12:00:28 +00:00
|
|
|
$params[2] = isset( $params[2] ) ?
|
2008-09-10 22:06:41 +00:00
|
|
|
self::formatBlockFlags( $params[2], is_null( $skin ) ) : '';
|
2010-03-22 22:28:15 +00:00
|
|
|
|
2009-04-10 20:01:10 +00:00
|
|
|
// Page protections
|
2010-08-21 12:00:28 +00:00
|
|
|
} elseif ( $type == 'protect' && count($params) == 3 ) {
|
2009-09-17 20:20:45 +00:00
|
|
|
// Restrictions and expiries
|
|
|
|
|
if( $skin ) {
|
|
|
|
|
$details .= htmlspecialchars( " {$params[1]}" );
|
|
|
|
|
} else {
|
|
|
|
|
$details .= " {$params[1]}";
|
|
|
|
|
}
|
|
|
|
|
// Cascading flag...
|
2008-09-13 05:33:24 +00:00
|
|
|
if( $params[2] ) {
|
2009-01-25 18:45:42 +00:00
|
|
|
if ( $skin ) {
|
2010-08-21 12:00:28 +00:00
|
|
|
$details .= ' [' . wfMsg( 'protect-summary-cascade' ) . ']';
|
2009-01-25 18:45:42 +00:00
|
|
|
} else {
|
2010-08-21 12:00:28 +00:00
|
|
|
$details .= ' [' . wfMsgForContent( 'protect-summary-cascade' ) . ']';
|
2009-01-25 18:45:42 +00:00
|
|
|
}
|
2008-09-10 22:06:41 +00:00
|
|
|
}
|
2010-03-22 22:28:15 +00:00
|
|
|
|
2009-04-10 20:01:10 +00:00
|
|
|
// Page moves
|
2011-04-15 23:28:13 +00:00
|
|
|
} elseif ( $type == 'move' && count( $params ) == 3 ) {
|
2008-12-30 17:52:43 +00:00
|
|
|
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
|
|
|
}
|
2010-03-22 22:28:15 +00:00
|
|
|
|
2009-04-10 20:01:10 +00:00
|
|
|
// Revision deletion
|
2010-08-21 12:00:28 +00:00
|
|
|
} elseif ( 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>
|
2010-08-21 12:00:28 +00:00
|
|
|
$details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false, is_null( $skin ) );
|
2010-03-22 22:28:15 +00:00
|
|
|
|
2009-04-10 20:01:10 +00:00
|
|
|
// Log deletion
|
2010-08-21 12:00:28 +00:00
|
|
|
} elseif ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) {
|
2009-04-10 20:01:10 +00:00
|
|
|
$count = substr_count( $params[1], ',' ) + 1; // log items
|
|
|
|
|
$ofield = intval( substr( $params[2], 7 ) ); // <ofield=x>
|
|
|
|
|
$nfield = intval( substr( $params[3], 7 ) ); // <nfield=x>
|
2010-08-21 12:00:28 +00:00
|
|
|
$details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true, is_null( $skin ) );
|
2005-08-27 16:35:10 +00:00
|
|
|
}
|
2010-03-22 22:28:15 +00:00
|
|
|
|
2009-05-22 09:35:48 +00:00
|
|
|
if ( $skin ) {
|
2009-07-20 12:07:07 +00:00
|
|
|
$rv = wfMsgHtml( $wgLogActions[$key], $params ) . $details;
|
2009-05-22 09:35:48 +00:00
|
|
|
} else {
|
|
|
|
|
$rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'content' ), $params ) . $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
|
|
|
}
|
2010-08-21 12:00:28 +00:00
|
|
|
|
2009-03-04 01:28:05 +00:00
|
|
|
// For the perplexed, this feature was added in r7855 by Erik.
|
2010-08-21 12:00:28 +00:00
|
|
|
// 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.
|
|
|
|
|
// 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 ) {
|
2010-08-21 12:00:28 +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
|
|
|
}
|
2010-08-21 12:00:28 +00:00
|
|
|
|
2011-04-16 23:23:28 +00:00
|
|
|
/**
|
|
|
|
|
* TODO document
|
|
|
|
|
* @param $type String
|
|
|
|
|
* @param $skin Skin
|
|
|
|
|
* @param $title Title
|
|
|
|
|
* @param $params Array
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
2008-09-10 22:29:24 +00:00
|
|
|
protected static function getTitleLink( $type, $skin, $title, &$params ) {
|
2010-01-09 15:23:27 +00:00
|
|
|
global $wgLang, $wgContLang, $wgUserrightsInterwikiDelimiter;
|
2008-09-10 22:29:24 +00:00
|
|
|
if( !$skin ) {
|
|
|
|
|
return $title->getPrefixedText();
|
|
|
|
|
}
|
|
|
|
|
switch( $type ) {
|
|
|
|
|
case 'move':
|
2011-04-16 23:23:28 +00:00
|
|
|
$titleLink = Linker::link(
|
2010-08-21 12:00:28 +00:00
|
|
|
$title,
|
2009-05-08 23:24:31 +00:00
|
|
|
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 {
|
2011-04-16 23:23:28 +00:00
|
|
|
$params[0] = Linker::link(
|
2009-05-08 23:24:31 +00:00
|
|
|
$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() );
|
2011-04-16 23:23:28 +00:00
|
|
|
$titleLink = Linker::userLink( $id, $title->getText() )
|
|
|
|
|
. Linker::userToolLinks( $id, $title->getText(), false, Linker::TOOL_LINKS_NOBLOCK );
|
2008-09-10 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'rights':
|
|
|
|
|
$text = $wgContLang->ucfirst( $title->getText() );
|
2010-01-09 15:23:27 +00:00
|
|
|
$parts = explode( $wgUserrightsInterwikiDelimiter, $text, 2 );
|
|
|
|
|
if ( count( $parts ) == 2 ) {
|
|
|
|
|
$titleLink = WikiMap::foreignUserLink( $parts[1], $parts[0],
|
|
|
|
|
htmlspecialchars( $title->getPrefixedText() ) );
|
2010-08-21 12:00:28 +00:00
|
|
|
if ( $titleLink !== false ) {
|
2010-01-09 15:23:27 +00:00
|
|
|
break;
|
2010-08-21 12:00:28 +00:00
|
|
|
}
|
2010-01-09 15:23:27 +00:00
|
|
|
}
|
2011-04-16 23:23:28 +00:00
|
|
|
$titleLink = Linker::link( Title::makeTitle( NS_USER, $text ) );
|
2008-09-10 22:29:24 +00:00
|
|
|
break;
|
|
|
|
|
case 'merge':
|
2011-04-16 23:23:28 +00:00
|
|
|
$titleLink = Linker::link(
|
2009-05-08 23:24:31 +00:00
|
|
|
$title,
|
|
|
|
|
$title->getPrefixedText(),
|
|
|
|
|
array(),
|
|
|
|
|
array( 'redirect' => 'no' )
|
|
|
|
|
);
|
2011-04-16 23:23:28 +00:00
|
|
|
$params[0] = Linker::link(
|
2009-05-08 23:24:31 +00:00
|
|
|
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 ) {
|
2011-04-16 23:23:28 +00:00
|
|
|
list( $name, $par ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
|
2008-09-10 22:29:24 +00:00
|
|
|
# Use the language name for log titles, rather than Log/X
|
|
|
|
|
if( $name == 'Log' ) {
|
2011-04-16 23:23:28 +00:00
|
|
|
$titleLink = '(' . Linker::link( $title, LogPage::logName( $par ) ) . ')';
|
2008-09-10 22:29:24 +00:00
|
|
|
} else {
|
2011-04-16 23:23:28 +00:00
|
|
|
$titleLink = Linker::link( $title );
|
2008-09-10 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2011-04-16 23:23:28 +00:00
|
|
|
$titleLink = Linker::link( $title );
|
2008-09-10 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $titleLink;
|
|
|
|
|
}
|
2004-10-24 19:14:48 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a log entry
|
2010-05-18 20:59:14 +00:00
|
|
|
*
|
|
|
|
|
* @param $action String: one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir'
|
|
|
|
|
* @param $target Title object
|
|
|
|
|
* @param $comment String: description associated
|
|
|
|
|
* @param $params Array: parameters passed later to wfMsg.* functions
|
|
|
|
|
* @param $doer User object: 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
|
|
|
|
2010-08-21 12:00:28 +00:00
|
|
|
if ( $comment === null ) {
|
|
|
|
|
$comment = '';
|
|
|
|
|
}
|
2010-02-22 02:15:30 +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 );
|
2010-08-21 12:00:28 +00:00
|
|
|
|
|
|
|
|
if ( $doer === null ) {
|
2008-07-09 06:44:31 +00:00
|
|
|
global $wgUser;
|
2008-07-09 08:21:51 +00:00
|
|
|
$doer = $wgUser;
|
2010-08-21 12:00:28 +00:00
|
|
|
} elseif ( !is_object( $doer ) ) {
|
2008-07-09 06:44:31 +00:00
|
|
|
$doer = User::newFromId( $doer );
|
|
|
|
|
}
|
2010-08-21 12:00:28 +00:00
|
|
|
|
2008-07-09 06:44:31 +00:00
|
|
|
$this->doer = $doer;
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2009-12-11 21:07:27 +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
|
|
|
}
|
2010-08-21 12:00:28 +00:00
|
|
|
|
2009-05-13 22:03:32 +00:00
|
|
|
/**
|
|
|
|
|
* Add relations to log_search table
|
2010-05-18 20:59:14 +00:00
|
|
|
*
|
|
|
|
|
* @param $field String
|
|
|
|
|
* @param $values Array
|
|
|
|
|
* @param $logid Integer
|
|
|
|
|
* @return Boolean
|
2009-05-13 22:03:32 +00:00
|
|
|
*/
|
|
|
|
|
public function addRelations( $field, $values, $logid ) {
|
2010-08-21 12:00:28 +00:00
|
|
|
if( !strlen( $field ) || empty( $values ) ) {
|
2009-05-13 22:03:32 +00:00
|
|
|
return false; // nothing
|
2010-08-21 12:00:28 +00:00
|
|
|
}
|
2009-05-13 22:03:32 +00:00
|
|
|
$data = array();
|
|
|
|
|
foreach( $values as $value ) {
|
2010-08-21 12:00:28 +00:00
|
|
|
$data[] = array(
|
|
|
|
|
'ls_field' => $field,
|
|
|
|
|
'ls_value' => $value,
|
|
|
|
|
'ls_log_id' => $logid
|
|
|
|
|
);
|
2009-05-13 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
$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
|
2010-05-18 20:59:14 +00:00
|
|
|
*
|
|
|
|
|
* @param $params Array
|
|
|
|
|
* @return String
|
2005-01-14 13:47:19 +00:00
|
|
|
*/
|
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
|
2010-05-18 20:59:14 +00:00
|
|
|
*
|
|
|
|
|
* @param $blob String
|
|
|
|
|
* @return Array
|
2005-01-14 13:47:19 +00:00
|
|
|
*/
|
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
|
2010-05-18 20:59:14 +00:00
|
|
|
* @return String
|
2007-01-09 01:54:52 +00:00
|
|
|
*/
|
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 ) {
|
2010-08-21 12:00:28 +00:00
|
|
|
for( $i = 0; $i < count( $flags ); $i++ ) {
|
2008-03-06 14:45:27 +00:00
|
|
|
$flags[$i] = self::formatBlockFlag( $flags[$i], $forContent );
|
2010-08-21 12:00:28 +00:00
|
|
|
}
|
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
|
2010-05-18 20:59:14 +00:00
|
|
|
* @return String
|
2007-01-09 01:54:52 +00:00
|
|
|
*/
|
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] ) ) {
|
2011-01-15 12:46:37 +00:00
|
|
|
$messages[$flag] = htmlspecialchars( $flag ); // Fallback
|
|
|
|
|
|
2011-01-14 10:51:05 +00:00
|
|
|
$msg = wfMessage( 'block-log-flags-' . $flag );
|
|
|
|
|
if ( $forContent ) {
|
2011-01-15 12:46:37 +00:00
|
|
|
$msg->inContentLanguage();
|
|
|
|
|
}
|
|
|
|
|
if ( $msg->exists() ) {
|
|
|
|
|
$messages[$flag] = $msg->escaped();
|
2010-08-21 12:00:28 +00:00
|
|
|
}
|
2007-01-09 01:54:52 +00:00
|
|
|
}
|
|
|
|
|
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 );
|