* (bug 6638) List block flags in block log entries
authorRob Church <robchurch@users.mediawiki.org>
Tue, 9 Jan 2007 01:54:52 +0000 (01:54 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Tue, 9 Jan 2007 01:54:52 +0000 (01:54 +0000)
* 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
includes/LogPage.php
includes/SpecialBlockip.php
languages/messages/MessagesEn.php

index 2e4ca2d..825c8e8 100644 (file)
@@ -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 ==
 
index dd39512..4e50483 100644 (file)
@@ -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];
+       }
+       
 }
 
 ?>
index 626922b..b8512f6 100644 (file)
@@ -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 );
+       }
        
 }
 
index dbd4071..c286e77 100644 (file)
@@ -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',