Merge "Add checkDependencies.php"
[lhc/web/wiklou.git] / includes / api / ApiUnblock.php
index 887edaa..5cef194 100644 (file)
@@ -1,9 +1,5 @@
 <?php
 /**
- *
- *
- * Created on Sep 7, 2007
- *
  * Copyright © 2007 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
  *
  * This program is free software; you can redistribute it and/or modify
@@ -24,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\Block\DatabaseBlock;
+
 /**
  * API module that facilitates the unblocking of users. Requires API write mode
  * to be enabled.
@@ -32,6 +30,8 @@
  */
 class ApiUnblock extends ApiBase {
 
+       use ApiBlockInfoTrait;
+
        /**
         * Unblocks the specified user or provides the reason the unblock failed.
         */
@@ -45,13 +45,14 @@ class ApiUnblock extends ApiBase {
                        $this->dieWithError( 'apierror-permissiondenied-unblock', 'permissiondenied' );
                }
                # T17810: blocked admins should have limited access here
-               if ( $user->isBlocked() ) {
+               $block = $user->getBlock();
+               if ( $block ) {
                        $status = SpecialBlock::checkUnblockSelf( $params['user'], $user );
                        if ( $status !== true ) {
                                $this->dieWithError(
                                        $status,
                                        null,
-                                       [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
+                                       [ 'blockinfo' => $this->getBlockDetails( $block ) ]
                                );
                        }
                }
@@ -79,14 +80,14 @@ class ApiUnblock extends ApiBase {
                        'Reason' => $params['reason'],
                        'Tags' => $params['tags']
                ];
-               $block = Block::newFromTarget( $data['Target'] );
+               $block = DatabaseBlock::newFromTarget( $data['Target'] );
                $retval = SpecialUnblock::processUnblock( $data, $this->getContext() );
                if ( $retval !== true ) {
                        $this->dieStatus( $this->errorArrayToStatus( $retval ) );
                }
 
                $res['id'] = $block->getId();
-               $target = $block->getType() == Block::TYPE_AUTO ? '' : $block->getTarget();
+               $target = $block->getType() == DatabaseBlock::TYPE_AUTO ? '' : $block->getTarget();
                $res['user'] = $target instanceof User ? $target->getName() : $target;
                $res['userid'] = $target instanceof User ? $target->getId() : 0;
                $res['reason'] = $params['reason'];