Added OutputPage::setPageTitleMsg() and OutputPage::setHTMLTitleMsg() as modified...
[lhc/web/wiklou.git] / includes / specials / SpecialUnblock.php
index cef5c2b..e9a59cd 100644 (file)
@@ -35,31 +35,26 @@ class SpecialUnblock extends SpecialPage {
        }
 
        public function execute( $par ){
-               global $wgUser, $wgOut, $wgRequest;
-
                # Check permissions
-               if( !$wgUser->isAllowed( 'block' ) ) {
-                       $wgOut->permissionRequired( 'block' );
+               if( !$this->userCanExecute( $this->getUser() ) ) {
+                       $this->displayRestrictionError();
                        return;
                }
+
                # Check for database lock
                if( wfReadOnly() ) {
-                       $wgOut->readOnlyPage();
-                       return;
+                       throw new ReadOnlyError;
                }
 
-               list( $this->target, $this->type ) = SpecialBlock::getTargetAndType( $par, $wgRequest );
+               list( $this->target, $this->type ) = SpecialBlock::getTargetAndType( $par, $this->getRequest() );
                $this->block = Block::newFromTarget( $this->target );
 
-               # bug 15810: blocked admins should have limited access here.  This won't allow sysops
-               # to remove autoblocks on themselves, but they should have ipblock-exempt anyway
-               $status = SpecialBlock::checkUnblockSelf( $this->target );
-               if ( $status !== true ) {
-                       throw new ErrorPageError( 'badaccess', $status );
-               }
+               $this->setHeaders();
+               $this->outputHeader();
 
-               $wgOut->setPageTitle( wfMsg( 'unblockip' ) );
-               $wgOut->addModules( 'mediawiki.special' );
+               $out = $this->getOutput();
+               $out->setPageTitleMsg( 'unblockip' );
+               $out->addModules( 'mediawiki.special' );
 
                $form = new HTMLForm( $this->getFields(), $this->getContext() );
                $form->setWrapperLegend( wfMsg( 'unblockip' ) );
@@ -71,14 +66,14 @@ class SpecialUnblock extends SpecialPage {
                        switch( $this->type ){
                                case Block::TYPE_USER:
                                case Block::TYPE_IP:
-                                       $wgOut->addWikiMsg( 'unblocked',  $this->target );
+                                       $out->addWikiMsg( 'unblocked',  $this->target );
                                        break;
                                case Block::TYPE_RANGE:
-                                       $wgOut->addWikiMsg( 'unblocked-range', $this->target );
+                                       $out->addWikiMsg( 'unblocked-range', $this->target );
                                        break;
                                case Block::TYPE_ID:
                                case Block::TYPE_AUTO:
-                                       $wgOut->addWikiMsg( 'unblocked-id', $this->target );
+                                       $out->addWikiMsg( 'unblocked-id', $this->target );
                                        break;
                        }
                }
@@ -115,15 +110,12 @@ class SpecialUnblock extends SpecialPage {
                                unset( $fields['Name'] );
 
                        } else {
-                               global $wgUser;
-
                                $fields['Target']['default'] = $target;
                                $fields['Target']['type'] = 'hidden';
                                switch( $type ){
                                        case Block::TYPE_USER:
                                        case Block::TYPE_IP:
-                                               $skin = $wgUser->getSkin();
-                                               $fields['Name']['default'] = $skin->link(
+                                               $fields['Name']['default'] = Linker::link(
                                                        $target->getUserPage(),
                                                        $target->getName()
                                                );
@@ -164,6 +156,14 @@ class SpecialUnblock extends SpecialPage {
                        return array( array( 'ipb_cant_unblock', $target ) );
                }
 
+               # bug 15810: blocked admins should have limited access here.  This
+               # won't allow sysops to remove autoblocks on themselves, but they
+               # should have ipblock-exempt anyway
+               $status = SpecialBlock::checkUnblockSelf( $target );
+               if ( $status !== true ) {
+                       throw new ErrorPageError( 'badaccess', $status );
+               }
+
                # If the specified IP is a single address, and the block is a range block, don't
                # unblock the whole range.
                list( $target, $type ) = SpecialBlock::getTargetAndType( $target );
@@ -193,11 +193,17 @@ class SpecialUnblock extends SpecialPage {
                        RevisionDeleteUser::unsuppressUserName( $block->getTarget(), $id );
                }
 
+               # Redact the name (IP address) for autoblocks
+               if ( $block->getType() == Block::TYPE_AUTO ) {
+                       $page = Title::makeTitle( NS_USER, '#' . $block->getId() );
+               } else {
+                       $page = $block->getTarget() instanceof User
+                               ? $block->getTarget()->getUserpage()
+                               : Title::makeTitle( NS_USER, $block->getTarget() );
+               }
+
                # Make log entry
                $log = new LogPage( 'block' );
-               $page = $block->getTarget() instanceof User
-                       ? $block->getTarget()->getUserpage()
-                       : Title::makeTitle( NS_USER, $block->getTarget() );
                $log->addEntry( 'unblock', $page, $data['Reason'] );
 
                return true;