"else if" to "elseif"
[lhc/web/wiklou.git] / includes / specials / SpecialUnblock.php
index 3ecbdbd..4794430 100644 (file)
@@ -35,16 +35,8 @@ class SpecialUnblock extends SpecialPage {
        }
 
        public function execute( $par ){
-               # Check permissions
-               if( !$this->userCanExecute( $this->getUser() ) ) {
-                       $this->displayRestrictionError();
-                       return;
-               }
-
-               # Check for database lock
-               if( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkPermissions();
+               $this->checkReadOnly();
 
                list( $this->target, $this->type ) = SpecialBlock::getTargetAndType( $par, $this->getRequest() );
                $this->block = Block::newFromTarget( $this->target );
@@ -58,7 +50,7 @@ class SpecialUnblock extends SpecialPage {
 
                $form = new HTMLForm( $this->getFields(), $this->getContext() );
                $form->setWrapperLegend( wfMsg( 'unblockip' ) );
-               $form->setSubmitCallback( array( __CLASS__, 'processUnblock' ) );
+               $form->setSubmitCallback( array( __CLASS__, 'processUIUnblock' ) );
                $form->setSubmitText( wfMsg( 'ipusubmit' ) );
                $form->addPreText( wfMsgExt( 'unblockiptext', 'parse' ) );
 
@@ -142,13 +134,22 @@ class SpecialUnblock extends SpecialPage {
                return $fields;
        }
 
+       /**
+        * Submit callback for an HTMLForm object
+        */
+       public static function processUIUnblock( array $data, HTMLForm $form ) {
+               return self::processUnblock( $data, $form->getContext() );
+       }
+
        /**
         * Process the form
+        *
+        * @param $data Array
+        * @param $context IContextSource
         * @return Array( Array(message key, parameters) ) on failure, True on success
         */
-       public static function processUnblock( array $data ){
-               global $wgUser;
-
+       public static function processUnblock( array $data, IContextSource $context ){
+               $performer = $context->getUser();
                $target = $data['Target'];
                $block = Block::newFromTarget( $data['Target'] );
 
@@ -159,7 +160,7 @@ class SpecialUnblock extends SpecialPage {
                # 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 );
+               $status = SpecialBlock::checkUnblockSelf( $target, $performer );
                if ( $status !== true ) {
                        throw new ErrorPageError( 'badaccess', $status );
                }
@@ -174,7 +175,7 @@ class SpecialUnblock extends SpecialPage {
 
                # If the name was hidden and the blocking user cannot hide
                # names, then don't allow any block removals...
-               if( !$wgUser->isAllowed( 'hideuser' ) && $block->mHideName ) {
+               if( !$performer->isAllowed( 'hideuser' ) && $block->mHideName ) {
                        return array( 'unblock-hideuser' );
                }