From 95bf9cee9a935037e24c8c685e5f82ade401825e Mon Sep 17 00:00:00 2001 From: Rob Church Date: Tue, 9 Jan 2007 01:54:52 +0000 Subject: [PATCH] * (bug 6638) List block flags in block log entries * New log parameter value for blocks * LogPage::formatBlockFlag() and LogPage::formatBlockFlags() introduced [this should all be subclassed better] * Support formatted lists of block flags in block log entries, where these are available [new blocks only] --- RELEASE-NOTES | 1 + includes/LogPage.php | 41 ++++++++++++++++++++++++++++++- includes/SpecialBlockip.php | 24 +++++++++++++++++- languages/messages/MessagesEn.php | 5 +++- 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2e4ca2d363..825c8e8e35 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -27,6 +27,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 7292) Fix site statistics when moving pages in/out of content namespaces * (bug 6937) Introduce "statistics-footer" message, appended to Special:Statistics * (bug 8531) Correct local name of Lingála (patch by Raymond) +* (bug 6638) List block flags in block log entries == Languages updated == diff --git a/includes/LogPage.php b/includes/LogPage.php index dd39512624..4e50483462 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -184,7 +184,10 @@ class LogPage { } else { array_unshift( $params, $titleLink ); if ( $translate && $key == 'block/block' ) { - $params[1] = $wgLang->translateBlockExpiry($params[1]); + $params[1] = $wgLang->translateBlockExpiry( $params[1] ); + $params[2] = isset( $params[2] ) + ? self::formatBlockFlags( $params[2] ) + : ''; } $rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ); } @@ -241,6 +244,42 @@ class LogPage { return explode( "\n", $blob ); } } + + /** + * Convert a comma-delimited list of block log flags + * into a more readable (and translated) form + * + * @param $flags Flags to format + * @return string + */ + public static function formatBlockFlags( $flags ) { + static $messages = false; + $flags = explode( ',', trim( $flags ) ); + if( count( $flags ) > 0 ) { + for( $i = 0; $i < count( $flags ); $i++ ) + $flags[$i] = self::formatBlockFlag( $flags[$i] ); + return '(' . implode( ', ', $flags ) . ')'; + } else { + return ''; + } + } + + /** + * Translate a block log flag if possible + * + * @param $flag Flag to translate + * @return string + */ + public static function formatBlockFlag( $flag ) { + static $messages = array(); + if( !isset( $messages[$flag] ) ) { + $k = 'block-log-flags-' . $flag; + $msg = wfMsg( $k ); + $messages[$flag] = htmlspecialchars( wfEmptyMsg( $k, $msg ) ? $flag : $msg ); + } + return $messages[$flag]; + } + } ?> diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index 626922bbd5..b8512f688f 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -260,10 +260,15 @@ class IPBlockForm { wfRunHooks('BlockIpComplete', array($block, $wgUser)); + # Prepare log parameters + $logParams = array(); + $logParams[] = $expirestr; + $logParams[] = $this->blockLogFlags(); + # Make log entry $log = new LogPage( 'block' ); $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ), - $this->BlockReason, $expirestr ); + $this->BlockReason, $logParams ); # Report to the user $titleObj = SpecialPage::getTitleFor( 'Blockip' ); @@ -287,6 +292,23 @@ class IPBlockForm { $viewer = new LogViewer( new LogReader( $request ) ); $viewer->showList( $out ); } + + /** + * Return a comma-delimited list of "flags" to be passed to the log + * reader for this block, to provide more information in the logs + * + * @return array + */ + private function blockLogFlags() { + $flags = array(); + if( $this->BlockAnonOnly ) + $flags[] = 'anononly'; + if( $this->BlockCreateAccount ) + $flags[] = 'nocreate'; + if( $this->BlockEnableAutoblock ) + $flags[] = 'autoblock'; + return implode( ',', $flags ); + } } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index dbd4071f4a..c286e778d7 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1866,11 +1866,14 @@ to a previously blocked IP address or username.', 'contribslink' => 'contribs', 'autoblocker' => 'Autoblocked because your IP address has been recently used by "[[User:$1|$1]]". The reason given for $1\'s block is: "\'\'\'$2\'\'\'"', 'blocklogpage' => 'Block log', -'blocklogentry' => 'blocked "[[$1]]" with an expiry time of $2', +'blocklogentry' => 'blocked "[[$1]]" with an expiry time of $2 $3', 'blocklogtext' => 'This is a log of user blocking and unblocking actions. Automatically blocked IP addresses are not listed. See the [[Special:Ipblocklist|IP block list]] for the list of currently operational bans and blocks.', 'unblocklogentry' => 'unblocked $1', +'block-log-flags-anononly' => 'anonymous users only', +'block-log-flags-nocreate' => 'account creation disabled', +'block-log-flags-autoblock' => 'autoblocker enabled', 'range_block_disabled' => 'The sysop ability to create range blocks is disabled.', 'ipb_expiry_invalid' => 'Expiry time invalid.', 'ipb_already_blocked' => '"$1" is already blocked', -- 2.20.1