*/
class ApiBlock extends ApiBase {
+ use ApiBlockInfoTrait;
+
/**
* Blocks the user specified in the parameters for the given expiry, with the
* given reason, and with all other settings provided in the params. If the block
$this->requireOnlyOneParameter( $params, 'user', 'userid' );
# 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->getBlockInfo( $block ) ]
);
}
}
$editingRestriction = 'sitewide';
$pageRestrictions = '';
+ $namespaceRestrictions = '';
if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
if ( $params['partial'] ) {
$editingRestriction = 'partial';
}
$pageRestrictions = implode( "\n", (array)$params['pagerestrictions'] );
+ $namespaceRestrictions = implode( "\n", (array)$params['namespacerestrictions'] );
}
if ( $params['userid'] !== null ) {
'Tags' => $params['tags'],
'EditingRestriction' => $editingRestriction,
'PageRestrictions' => $pageRestrictions,
+ 'NamespaceRestrictions' => $namespaceRestrictions,
];
$retval = SpecialBlock::processForm( $data, $this->getContext() );
$block = Block::newFromTarget( $target, null, true );
if ( $block instanceof Block ) {
- $res['expiry'] = ApiResult::formatExpiry( $block->mExpiry, 'infinite' );
+ $res['expiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
$res['id'] = $block->getId();
} else {
# should be unreachable
if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
$res['partial'] = $params['partial'];
$res['pagerestrictions'] = $params['pagerestrictions'];
+ $res['namespacerestrictions'] = $params['namespacerestrictions'];
}
$this->getResult()->addValue( null, $this->getModuleName(), $res );
ApiBase::PARAM_ISMULTI_LIMIT1 => 10,
ApiBase::PARAM_ISMULTI_LIMIT2 => 10,
];
+ $params['namespacerestrictions'] = [
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_TYPE => 'namespace',
+ ];
}
return $params;