Use local context instead of global variables
[lhc/web/wiklou.git] / includes / specials / SpecialUnblock.php
index 8974c5d..65f9bb1 100644 (file)
@@ -38,26 +38,19 @@ class SpecialUnblock extends SpecialPage {
                global $wgUser, $wgOut, $wgRequest;
 
                # Check permissions
-               if( !$wgUser->isAllowed( 'block' ) ) {
-                       $wgOut->permissionRequired( 'block' );
+               if( !$this->userCanExecute( $wgUser ) ) {
+                       $this->displayRestrictionError();
                        return;
                }
+
                # Check for database lock
                if( wfReadOnly() ) {
-                       $wgOut->readOnlyPage();
-                       return;
+                       throw new ReadOnlyError;
                }
 
                list( $this->target, $this->type ) = SpecialBlock::getTargetAndType( $par, $wgRequest );
                $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 );
-               }
-
                $wgOut->setPageTitle( wfMsg( 'unblockip' ) );
                $wgOut->addModules( 'mediawiki.special' );
 
@@ -162,6 +155,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 );