summaryrefslogtreecommitdiff
path: root/includes/LogPage.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/LogPage.php')
-rw-r--r--includes/LogPage.php74
1 files changed, 50 insertions, 24 deletions
diff --git a/includes/LogPage.php b/includes/LogPage.php
index 50a9a232..0d572385 100644
--- a/includes/LogPage.php
+++ b/includes/LogPage.php
@@ -37,7 +37,7 @@ class LogPage {
/* @access private */
var $type, $action, $comment, $params, $target, $doer;
/* @acess public */
- var $updateRecentChanges;
+ var $updateRecentChanges, $sendToUDP;
/**
* Constructor
@@ -45,15 +45,16 @@ class LogPage {
* @param string $type One of '', 'block', 'protect', 'rights', 'delete',
* 'upload', 'move'
* @param bool $rc Whether to update recent changes as well as the logging table
+ * @param bool $udp Whether to send to the UDP feed if NOT sent to RC
*/
- function __construct( $type, $rc = true ) {
+ public function __construct( $type, $rc = true, $udp = 'skipUDP' ) {
$this->type = $type;
$this->updateRecentChanges = $rc;
+ $this->sendToUDP = ($udp == 'UDP');
}
protected function saveContent() {
- global $wgUser, $wgLogRestrictions;
- $fname = 'LogPage::saveContent';
+ global $wgLogRestrictions;
$dbw = wfGetDB( DB_MASTER );
$log_id = $dbw->nextSequenceValue( 'log_log_id_seq' );
@@ -70,21 +71,25 @@ class LogPage {
'log_comment' => $this->comment,
'log_params' => $this->params
);
- $dbw->insert( 'logging', $data, $fname );
+ $dbw->insert( 'logging', $data, __METHOD__ );
$newId = !is_null($log_id) ? $log_id : $dbw->insertId();
- if( !($dbw->affectedRows() > 0) ) {
- wfDebugLog( "logging", "LogPage::saveContent failed to insert row - Error {$dbw->lastErrno()}: {$dbw->lastError()}" );
- }
# And update recentchanges
if( $this->updateRecentChanges ) {
- # Don't add private logs to RC!
- if( !isset($wgLogRestrictions[$this->type]) || $wgLogRestrictions[$this->type]=='*' ) {
- $titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
- $rcComment = $this->getRcComment();
- RecentChange::notifyLog( $now, $titleObj, $this->doer, $rcComment, '',
- $this->type, $this->action, $this->target, $this->comment, $this->params, $newId );
+ $titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
+ RecentChange::notifyLog( $now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type,
+ $this->action, $this->target, $this->comment, $this->params, $newId );
+ } else if( $this->sendToUDP ) {
+ # Don't send private logs to UDP
+ if( isset($wgLogRestrictions[$this->type]) && $wgLogRestrictions[$this->type] !='*' ) {
+ return true;
}
+ # 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 );
+ $rc = RecentChange::newLogEntry( $now, $titleObj, $this->doer, $this->getRcComment(), '',
+ $this->type, $this->action, $this->target, $this->comment, $this->params, $newId );
+ $rc->notifyRC2UDP();
}
return true;
}
@@ -98,7 +103,7 @@ class LogPage {
if ($rcComment == '')
$rcComment = $this->comment;
else
- $rcComment .= ': ' . $this->comment;
+ $rcComment .= wfMsgForContent( 'colon-separator' ) . $this->comment;
}
return $rcComment;
}
@@ -145,7 +150,7 @@ class LogPage {
* @param string $type logtype
* @return string Headertext of this logtype
*/
- static function logHeader( $type ) {
+ public static function logHeader( $type ) {
global $wgLogHeaders, $wgMessageCache;
$wgMessageCache->loadAllMessages();
return wfMsgExt($wgLogHeaders[$type],array('parseinline'));
@@ -155,7 +160,7 @@ class LogPage {
* @static
* @return HTML string
*/
- static function actionText( $type, $action, $title = NULL, $skin = NULL,
+ public static function actionText( $type, $action, $title = NULL, $skin = NULL,
$params = array(), $filterWikilinks = false )
{
global $wgLang, $wgContLang, $wgLogActions, $wgMessageCache;
@@ -196,7 +201,7 @@ class LogPage {
} else {
$details = '';
array_unshift( $params, $titleLink );
- if ( $key == 'block/block' || $key == 'suppress/block' || $key == 'block/reblock' ) {
+ if ( preg_match( '/^(block|suppress)\/(block|reblock)$/', $key ) ) {
if ( $skin ) {
$params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' .
$wgLang->translateBlockExpiry( $params[1] ) . '</span>';
@@ -208,11 +213,19 @@ class LogPage {
} else if ( $type == 'protect' && count($params) == 3 ) {
$details .= " {$params[1]}"; // restrictions and expiries
if( $params[2] ) {
- $details .= ' ['.wfMsg('protect-summary-cascade').']';
+ if ( $skin ) {
+ $details .= ' ['.wfMsg('protect-summary-cascade').']';
+ } else {
+ $details .= ' ['.wfMsgForContent('protect-summary-cascade').']';
+ }
}
} else if ( $type == 'move' && count( $params ) == 3 ) {
if( $params[2] ) {
- $details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']';
+ if ( $skin ) {
+ $details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']';
+ } else {
+ $details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']';
+ }
}
}
$rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ) . $details;
@@ -228,6 +241,17 @@ class LogPage {
$rv = "$action";
}
}
+
+ // 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.
+ // 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.
if( $filterWikilinks ) {
$rv = str_replace( "[[", "", $rv );
$rv = str_replace( "]]", "", $rv );
@@ -296,7 +320,7 @@ class LogPage {
* @param array $params Parameters passed later to wfMsg.* functions
* @param User $doer The user doing the action
*/
- function addEntry( $action, $target, $comment, $params = array(), $doer = null ) {
+ public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) {
if ( !is_array( $params ) ) {
$params = array( $params );
}
@@ -324,7 +348,7 @@ class LogPage {
* Create a blob from a parameter array
* @static
*/
- static function makeParamBlob( $params ) {
+ public static function makeParamBlob( $params ) {
return implode( "\n", $params );
}
@@ -332,7 +356,7 @@ class LogPage {
* Extract a parameter array from a blob
* @static
*/
- static function extractParams( $blob ) {
+ public static function extractParams( $blob ) {
if ( $blob === '' ) {
return array();
} else {
@@ -350,11 +374,13 @@ class LogPage {
* @return string
*/
public static function formatBlockFlags( $flags, $forContent = false ) {
+ global $wgLang;
+
$flags = explode( ',', trim( $flags ) );
if( count( $flags ) > 0 ) {
for( $i = 0; $i < count( $flags ); $i++ )
$flags[$i] = self::formatBlockFlag( $flags[$i], $forContent );
- return '(' . implode( ', ', $flags ) . ')';
+ return '(' . $wgLang->commaList( $flags ) . ')';
} else {
return '';
}