HTML 2???
[lhc/web/wiklou.git] / includes / api / ApiUnblock.php
index 6fd9816..db94fd5 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( "ApiBase.php" );
-}
-
 /**
  * API module that facilitates the unblocking of users. Requires API write mode
  * to be enabled.
@@ -45,11 +40,11 @@ class ApiUnblock extends ApiBase {
         * Unblocks the specified user or provides the reason the unblock failed.
         */
        public function execute() {
-               global $wgUser;
+               $user = $this->getUser();
                $params = $this->extractRequestParams();
 
                if ( $params['gettoken'] ) {
-                       $res['unblocktoken'] = $wgUser->editToken( '', $this->getMain()->getRequest() );
+                       $res['unblocktoken'] = $user->getEditToken( '', $this->getMain()->getRequest() );
                        $this->getResult()->addValue( null, $this->getModuleName(), $res );
                        return;
                }
@@ -61,12 +56,12 @@ class ApiUnblock extends ApiBase {
                        $this->dieUsageMsg( 'unblock-idanduser' );
                }
 
-               if ( !$wgUser->isAllowed( 'block' ) ) {
+               if ( !$user->isAllowed( 'block' ) ) {
                        $this->dieUsageMsg( 'cantunblock' );
                }
                # bug 15810: blocked admins should have limited access here
-               if ( $wgUser->isBlocked() ) {
-                       $status = SpecialBlock::checkUnblockSelf( $params['user'] );
+               if ( $user->isBlocked() ) {
+                       $status = SpecialBlock::checkUnblockSelf( $params['user'], $user );
                        if ( $status !== true ) {
                                $this->dieUsageMsg( $status );
                        }
@@ -77,7 +72,7 @@ class ApiUnblock extends ApiBase {
                        'Reason' => is_null( $params['reason'] ) ? '' : $params['reason']
                );
                $block = Block::newFromTarget( $data['Target'] );
-               $retval = SpecialUnblock::processUnblock( $data );
+               $retval = SpecialUnblock::processUnblock( $data, $this->getContext() );
                if ( $retval !== true ) {
                        $this->dieUsageMsg( $retval[0] );
                }
@@ -149,7 +144,7 @@ class ApiUnblock extends ApiBase {
        }
 
        public function getHelpUrls() {
-               return 'http://www.mediawiki.org/wiki/API:Block';
+               return 'https://www.mediawiki.org/wiki/API:Block';
        }
 
        public function getVersion() {