* @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.
$params = $this->extractRequestParams();
if ( $params['gettoken'] ) {
- $res['unblocktoken'] = $user->getEditToken( '', $this->getMain()->getRequest() );
+ $res['unblocktoken'] = $user->getEditToken();
$this->getResult()->addValue( null, $this->getModuleName(), $res );
return;
}
}
# bug 15810: blocked admins should have limited access here
if ( $user->isBlocked() ) {
- $status = SpecialBlock::checkUnblockSelf( $params['user'] );
+ $status = SpecialBlock::checkUnblockSelf( $params['user'], $user );
if ( $status !== true ) {
$this->dieUsageMsg( $status );
}
'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] );
}
$res['id'] = $block->getId();
- $res['user'] = $block->getType() == Block::TYPE_AUTO ? '' : $block->getTarget();
+ $target = $block->getType() == Block::TYPE_AUTO ? '' : $block->getTarget();
+ $res['user'] = $target;
+ $res['userid'] = $target instanceof User ? $target->getId() : 0;
$res['reason'] = $params['reason'];
$this->getResult()->addValue( null, $this->getModuleName(), $res );
}
),
'user' => null,
'token' => null,
- 'gettoken' => false,
+ 'gettoken' => array(
+ ApiBase::PARAM_DFLT => false,
+ ApiBase::PARAM_DEPRECATED => true,
+ ),
'reason' => null,
);
}
return array(
'id' => "ID of the block you want to unblock (obtained through list=blocks). Cannot be used together with {$p}user",
'user' => "Username, IP address or IP range you want to unblock. Cannot be used together with {$p}id",
- 'token' => "An unblock token previously obtained through the gettoken parameter or {$p}prop=info",
+ 'token' => "An unblock token previously obtained through prop=info",
'gettoken' => 'If set, an unblock token will be returned, and no other action will be taken',
'reason' => 'Reason for unblock (optional)',
);
}
public function getHelpUrls() {
- return 'http://www.mediawiki.org/wiki/API:Block';
+ return 'https://www.mediawiki.org/wiki/API:Block';
}
public function getVersion() {