diff options
Diffstat (limited to 'includes/logging')
-rw-r--r-- | includes/logging/ContentModelLogFormatter.php | 34 | ||||
-rw-r--r-- | includes/logging/LogEntry.php | 34 | ||||
-rw-r--r-- | includes/logging/LogEventsList.php | 8 | ||||
-rw-r--r-- | includes/logging/LogFormatter.php | 10 | ||||
-rw-r--r-- | includes/logging/LogPager.php | 5 | ||||
-rw-r--r-- | includes/logging/PatrolLogFormatter.php | 6 | ||||
-rw-r--r-- | includes/logging/ProtectLogFormatter.php | 70 |
7 files changed, 152 insertions, 15 deletions
diff --git a/includes/logging/ContentModelLogFormatter.php b/includes/logging/ContentModelLogFormatter.php new file mode 100644 index 00000000..982fcc30 --- /dev/null +++ b/includes/logging/ContentModelLogFormatter.php @@ -0,0 +1,34 @@ +<?php + +class ContentModelLogFormatter extends LogFormatter { + protected function getMessageParameters() { + $lang = $this->context->getLanguage(); + $params = parent::getMessageParameters(); + $params[3] = ContentHandler::getLocalizedName( $params[3], $lang ); + $params[4] = ContentHandler::getLocalizedName( $params[4], $lang ); + return $params; + } + + public function getActionLinks() { + if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden + || $this->entry->getSubtype() !== 'change' + || !$this->context->getUser()->isAllowed( 'editcontentmodel' ) + ) { + return ''; + } + + $params = $this->extractParameters(); + $revert = Linker::linkKnown( + SpecialPage::getTitleFor( 'ChangeContentModel' ), + $this->msg( 'logentry-contentmodel-change-revertlink' )->escaped(), + array(), + array( + 'pagetitle' => $this->entry->getTarget()->getPrefixedText(), + 'model' => $params[3], + 'reason' => $this->msg( 'logentry-contentmodel-change-revert' )->inContentLanguage()->text(), + ) + ); + + return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); + } +} diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index 66c2bde1..8427adbb 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -115,6 +115,28 @@ abstract class LogEntryBase implements LogEntry { public function isLegacy() { return false; } + + /** + * Create a blob from a parameter array + * + * @param array $params + * @return string + * @since 1.26 + */ + public static function makeParamBlob( $params ) { + return serialize( (array)$params ); + } + + /** + * Extract a parameter array from a blob + * + * @param string $blob + * @return array + * @since 1.26 + */ + public static function extractParams( $blob ) { + return unserialize( $blob ); + } } /** @@ -224,14 +246,14 @@ class DatabaseLogEntry extends LogEntryBase { public function getParameters() { if ( !isset( $this->params ) ) { $blob = $this->getRawParameters(); - wfSuppressWarnings(); - $params = unserialize( $blob ); - wfRestoreWarnings(); + MediaWiki\suppressWarnings(); + $params = LogEntryBase::extractParams( $blob ); + MediaWiki\restoreWarnings(); if ( $params !== false ) { $this->params = $params; $this->legacy = false; } else { - $this->params = $blob === '' ? array() : explode( "\n", $blob ); + $this->params = LogPage::extractParams( $blob ); $this->legacy = true; } } @@ -516,7 +538,7 @@ class ManualLogEntry extends LogEntryBase { 'log_title' => $this->getTarget()->getDBkey(), 'log_page' => $this->getTarget()->getArticleID(), 'log_comment' => $comment, - 'log_params' => serialize( (array)$this->getParameters() ), + 'log_params' => LogEntryBase::makeParamBlob( $this->getParameters() ), ); if ( isset( $this->deleted ) ) { $data['log_deleted'] = $this->deleted; @@ -584,7 +606,7 @@ class ManualLogEntry extends LogEntryBase { $this->getSubtype(), $this->getTarget(), $this->getComment(), - serialize( (array)$this->getParameters() ), + LogEntryBase::makeParamBlob( $this->getParameters() ), $newId, $formatter->getIRCActionComment() // Used for IRC feeds ); diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index dfe31365..1b56584f 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -36,6 +36,11 @@ class LogEventsList extends ContextSource { protected $mDefaultQuery; /** + * @var bool + */ + protected $showTagEditUI; + + /** * Constructor. * The first two parameters used to be $skin and $out, but now only a context * is needed, that's why there's a second unused parameter. @@ -55,6 +60,7 @@ class LogEventsList extends ContextSource { } $this->flags = $flags; + $this->showTagEditUI = ChangeTags::showTagEditingUI( $this->getUser() ); } /** @@ -348,7 +354,7 @@ class LogEventsList extends ContextSource { $user = $this->getUser(); // If change tag editing is available to this user, return the checkbox - if ( $this->flags & self::USE_CHECKBOXES && ChangeTags::showTagEditingUI( $user ) ) { + if ( $this->flags & self::USE_CHECKBOXES && $this->showTagEditUI ) { return Xml::check( 'showhiderevisions', false, diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index 9c2fdd35..f31a42aa 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -193,6 +193,8 @@ class LogFormatter { * @return string Text */ public function getIRCActionText() { + global $wgContLang; + $this->plaintext = true; $this->irctext = true; @@ -271,6 +273,10 @@ class LogFormatter { $text = wfMessage( 'modifiedarticleprotection' ) ->rawParams( $target . ' ' . $parameters[0] )->inContentLanguage()->escaped(); break; + case 'move_prot': + $text = wfMessage( 'movedarticleprotection' ) + ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped(); + break; } break; @@ -338,7 +344,6 @@ class LogFormatter { case 'block': switch ( $entry->getSubtype() ) { case 'block': - global $wgContLang; // Keep compatibility with extensions by checking for // new key (5::duration/6::flags) or old key (0/optional 1) if ( $entry->isLegacy() ) { @@ -358,7 +363,6 @@ class LogFormatter { ->rawParams( $target )->inContentLanguage()->escaped(); break; case 'reblock': - global $wgContLang; $duration = $wgContLang->translateBlockExpiry( $parameters['5::duration'] ); $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'], $wgContLang ); $text = wfMessage( 'reblock-logentry' ) @@ -790,7 +794,7 @@ class LogFormatter { break; case 'number': - if ( ctype_digit( $value ) ) { + if ( ctype_digit( $value ) || is_int( $value ) ) { $value = (int)$value; } else { $value = (float)$value; diff --git a/includes/logging/LogPager.php b/includes/logging/LogPager.php index bf489ab9..598a45f0 100644 --- a/includes/logging/LogPager.php +++ b/includes/logging/LogPager.php @@ -192,7 +192,7 @@ class LogPager extends ReverseChronologicalPager { * @return void */ private function limitTitle( $page, $pattern ) { - global $wgMiserMode; + global $wgMiserMode, $wgUserrightsInterwikiDelimiter; if ( $page instanceof Title ) { $title = $page; @@ -209,7 +209,6 @@ class LogPager extends ReverseChronologicalPager { $doUserRightsLogLike = false; if ( $this->types == array( 'rights' ) ) { - global $wgUserrightsInterwikiDelimiter; $parts = explode( $wgUserrightsInterwikiDelimiter, $title->getDBKey() ); if ( count( $parts ) == 2 ) { list( $name, $database ) = array_map( 'trim', $parts ); @@ -249,7 +248,7 @@ class LogPager extends ReverseChronologicalPager { $user = $this->getUser(); if ( !$user->isAllowed( 'deletedhistory' ) ) { $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::DELETED_ACTION ) . ' = 0'; - } elseif ( !$user->isAllowed( 'suppressrevision' ) ) { + } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) { $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::SUPPRESSED_ACTION ) . ' != ' . LogPage::SUPPRESSED_ACTION; } diff --git a/includes/logging/PatrolLogFormatter.php b/includes/logging/PatrolLogFormatter.php index 00337432..7fe0143f 100644 --- a/includes/logging/PatrolLogFormatter.php +++ b/includes/logging/PatrolLogFormatter.php @@ -68,9 +68,11 @@ class PatrolLogFormatter extends LogFormatter { $params = $entry->getParameters(); static $map = array( - '4::curid', - '5::previd', + '4:number:curid', + '5:number:previd', '6:bool:auto', + '4::curid' => '4:number:curid', + '5::previd' => '5:number:previd', '6::auto' => '6:bool:auto', ); foreach ( $map as $index => $key ) { diff --git a/includes/logging/ProtectLogFormatter.php b/includes/logging/ProtectLogFormatter.php new file mode 100644 index 00000000..5327e072 --- /dev/null +++ b/includes/logging/ProtectLogFormatter.php @@ -0,0 +1,70 @@ +<?php +/** + * Formatter for protect log entries. + * + * 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 + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + * @since 1.26 + */ + +/** + * This class formats protect log entries. + * + * @since 1.26 + */ +class ProtectLogFormatter extends LogFormatter { + public function getPreloadTitles() { + $subtype = $this->entry->getSubtype(); + if ( $subtype === 'move_prot' ) { + $params = $this->extractParameters(); + return array( Title::newFromText( $params[3] ) ); + } + return array(); + } + + protected function getMessageParameters() { + $params = parent::getMessageParameters(); + + $subtype = $this->entry->getSubtype(); + if ( $subtype === 'move_prot' ) { + $oldname = $this->makePageLink( Title::newFromText( $params[3] ), array( 'redirect' => 'no' ) ); + $params[3] = Message::rawParam( $oldname ); + } + + return $params; + } + + protected function getParametersForApi() { + $entry = $this->entry; + $params = $entry->getParameters(); + + static $map = array( + // param keys for move_prot sub type + '4:title:oldtitle', + '4::oldtitle' => '4:title:oldtitle', + ); + foreach ( $map as $index => $key ) { + if ( isset( $params[$index] ) ) { + $params[$key] = $params[$index]; + unset( $params[$index] ); + } + } + + return $params; + } +} |