Follow-up r83825: fix Block::parseTarget to recognise autoblocks separately, and...
authorHappy-melon <happy-melon@users.mediawiki.org>
Sun, 13 Mar 2011 15:14:33 +0000 (15:14 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sun, 13 Mar 2011 15:14:33 +0000 (15:14 +0000)
includes/Block.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 6541284..a58789b 100644 (file)
@@ -758,13 +758,17 @@ class Block {
 
        /**
         * Get the block name, but with autoblocked IPs hidden as per standard privacy policy
-        * @return String
+        * @return String, text is escaped
         */
        public function getRedactedName() {
                if ( $this->mAuto ) {
-                       return '#' . $this->mId;
+                       return HTML::rawElement(
+                               'span',
+                               array( 'class' => 'mw-autoblockid' ),
+                               wfMessage( 'autoblockid', $this->mId )
+                       );
                } else {
-                       return $this->mAddress;
+                       return htmlspecialchars( $this->mAddress );
                }
        }
 
@@ -989,10 +993,20 @@ class Block {
        }
 
        /**
-        * Get the target and target type for this particular Block
+        * Get the target and target type for this particular Block.  Note that for autoblocks,
+        * this returns the unredacted name; frontend functions need to call $block->getRedactedName()
+        * in this situation.
         * @return array( User|String, Block::TYPE_ constant )
+        * FIXME: this should be an integral part of the Block member variables
         */
        public function getTargetAndType(){
-               return self::parseTarget( $this->mAddress );
+               list( $target, $type ) = self::parseTarget( $this->mAddress );
+
+               # Check whether it's an autoblock
+               if( $type == self::TYPE_ID && $this->mAuto ){
+                       $type = self::TYPE_AUTO;
+               }
+
+               return array( $target, $type );
        }
 }
index d716570..49e9a81 100644 (file)
@@ -3021,6 +3021,7 @@ The latest block log entry is provided below for reference:',
 'whatlinkshere-filters'    => 'Filters',
 
 # Block/unblock
+'autoblockid'                     => 'Autoblock #$1',
 'blockip'                         => 'Block user',
 'blockip-title'                   => 'Block user',
 'blockip-legend'                  => 'Block user',
index 73471d8..20a7692 100644 (file)
@@ -2045,6 +2045,7 @@ $wgMessageStructure = array(
                'whatlinkshere-filters',
        ),
        'block' => array(
+               'autoblockid',
                'blockip',
                'blockip-title',
                'blockip-legend',