Use local context to get message instead of relying on global variables
[lhc/web/wiklou.git] / includes / specials / SpecialBlock.php
index fab295a..7d93cc7 100644 (file)
@@ -143,7 +143,7 @@ class SpecialBlock extends FormSpecialPage {
                                'required' => true,
                                'tabindex' => '2',
                                'options' => self::getSuggestedDurations(),
-                               'other' => wfMsg( 'ipbother' ),
+                               'other' => $this->msg( 'ipbother' )->text(),
                        ),
                        'Reason' => array(
                                'type' => 'selectandother',
@@ -310,7 +310,7 @@ class SpecialBlock extends FormSpecialPage {
                                $s = Html::rawElement(
                                        'h2',
                                        array(),
-                                       wfMsgExt( 'ipb-otherblocks-header', 'parseinline', count( $otherBlockMessages ) )
+                                       $this->msg( 'ipb-otherblocks-header', count( $otherBlockMessages ) )->parse()
                                ) . "\n";
 
                                $list = '';
@@ -334,7 +334,7 @@ class SpecialBlock extends FormSpecialPage {
 
        /**
         * Add footer elements to the form
-        * @return void
+        * @return string
         */
        protected function postText(){
                # Link to the user's contributions, if applicable
@@ -342,16 +342,16 @@ class SpecialBlock extends FormSpecialPage {
                        $contribsPage = SpecialPage::getTitleFor( 'Contributions', $this->target->getName() );
                        $links[] = Linker::link(
                                $contribsPage,
-                               wfMsgExt( 'ipb-blocklist-contribs', 'escape', $this->target->getName() )
+                               $this->msg( 'ipb-blocklist-contribs', $this->target->getName() )->escaped()
                        );
                }
 
                # Link to unblock the specified user, or to a blank unblock form
                if( $this->target instanceof User ) {
-                       $message = wfMsgExt( 'ipb-unblock-addr', array( 'parseinline' ), $this->target->getName() );
+                       $message = $this->msg( 'ipb-unblock-addr', $this->target->getName() )->parse();
                        $list = SpecialPage::getTitleFor( 'Unblock', $this->target->getName() );
                } else {
-                       $message = wfMsgExt( 'ipb-unblock', array( 'parseinline' ) );
+                       $message = $this->msg( 'ipb-unblock' )->parse();
                        $list = SpecialPage::getTitleFor( 'Unblock' );
                }
                $links[] = Linker::linkKnown( $list, $message, array() );
@@ -359,7 +359,7 @@ class SpecialBlock extends FormSpecialPage {
                # Link to the block list
                $links[] = Linker::linkKnown(
                        SpecialPage::getTitleFor( 'BlockList' ),
-                       wfMsg( 'ipb-blocklist' )
+                       $this->msg( 'ipb-blocklist' )->escaped()
                );
 
                $user = $this->getUser();
@@ -368,7 +368,7 @@ class SpecialBlock extends FormSpecialPage {
                if ( $user->isAllowed( 'editinterface' ) ) {
                        $links[] = Linker::link(
                                Title::makeTitle( NS_MEDIAWIKI, 'Ipbreason-dropdown' ),
-                               wfMsgHtml( 'ipb-edit-dropdown' ),
+                               $this->msg( 'ipb-edit-dropdown' )->escaped(),
                                array(),
                                array( 'action' => 'edit' )
                        );
@@ -565,9 +565,13 @@ class SpecialBlock extends FormSpecialPage {
 
                        # Give admins a heads-up before they go and block themselves.  Much messier
                        # to do this for IPs, but it's pretty unlikely they'd ever get the 'block'
-                       # permission anyway, although the code does allow for it
+                       # permission anyway, although the code does allow for it.
+                       # Note: Important to use $target instead of $data['Target']
+                       # since both $data['PreviousTarget'] and $target are normalized
+                       # but $data['target'] gets overriden by (non-normalized) request variable
+                       # from previous request.
                        if( $target === $performer->getName() &&
-                               ( $data['PreviousTarget'] !== $data['Target'] || !$data['Confirm'] ) )
+                               ( $data['PreviousTarget'] !== $target || !$data['Confirm'] ) )
                        {
                                return array( 'ipb-blockingself' );
                        }