64 parent::__construct( $main, $action );
66 $this->permissionCheckerFactory = $permissionCheckerFactory;
67 $this->unblockUserFactory = $unblockUserFactory;
68 $this->userIdentityLookup = $userIdentityLookup;
69 $this->watchedItemStore = $watchedItemStore;
73 $this->watchlistMaxDuration =
75 $this->watchlistManager = $watchlistManager;
76 $this->userOptionsLookup = $userOptionsLookup;
89 $this->
dieWithError(
'apierror-permissiondenied-unblock',
'permissiondenied' );
92 if (
$params[
'userid'] !==
null ) {
93 $identity = $this->userIdentityLookup->getUserIdentityByUserId(
$params[
'userid'] );
97 $params[
'user'] = $identity->getName();
100 $target =
$params[
'id'] ===
null ?
$params[
'user'] :
"#{$params['id']}";
102 # T17810: blocked admins should have limited access here
103 $status = $this->permissionCheckerFactory
104 ->newBlockPermissionChecker(
107 )->checkBlockPermissions();
108 if ( $status !==
true ) {
113 [
'blockinfo' => $this->getBlockDetails( $performer->getBlock() ) ]
117 $status = $this->unblockUserFactory->newUnblockUser(
124 if ( !$status->isOK() ) {
128 $block = $status->getValue();
129 $targetType = $block->getType();
130 $targetName = $targetType === Block::TYPE_AUTO ?
'' : $block->getTargetName();
131 $targetUserId = $block->getTargetUserIdentity() ? $block->getTargetUserIdentity()->getId() : 0;
134 $watchuser =
$params[
'watchuser'];
135 $userPage = Title::makeTitle(
NS_USER, $targetName );
136 if ( $watchuser && $targetType !== Block::TYPE_RANGE && $targetType !== Block::TYPE_AUTO ) {
137 $this->
setWatch(
'watch', $userPage, $this->
getUser(),
null, $watchlistExpiry );
140 $watchlistExpiry =
null;
144 'id' => $block->getId(),
145 'user' => $targetName,
146 'userid' => $targetUserId,
148 'watchuser' => $watchuser,
150 if ( $watchlistExpiry !==
null ) {
152 $this->watchedItemStore,
171 ParamValidator::PARAM_TYPE =>
'integer',
174 ParamValidator::PARAM_TYPE =>
'user',
175 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'cidr',
'id' ],
178 ParamValidator::PARAM_TYPE =>
'integer',
179 ParamValidator::PARAM_DEPRECATED =>
true,
183 ParamValidator::PARAM_TYPE =>
'tags',
184 ParamValidator::PARAM_ISMULTI =>
true,
186 'watchuser' =>
false,
192 if ( $this->watchlistExpiryEnabled ) {
194 'watchlistexpiry' => [
195 ParamValidator::PARAM_TYPE =>
'expiry',
196 ExpiryDef::PARAM_MAX => $this->watchlistMaxDuration,
197 ExpiryDef::PARAM_USE_MAX =>
true,
211 'action=unblock&id=105'
212 =>
'apihelp-unblock-example-id',
213 'action=unblock&user=Bob&reason=Sorry%20Bob'
214 =>
'apihelp-unblock-example-user',
219 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Block';
224class_alias( ApiUnblock::class,
'ApiUnblock' );
array $params
The job parameters.
This is the main API class, used for both external and internal processing.
A class containing constants representing the names of configuration variables.
const WatchlistExpiry
Name constant for the WatchlistExpiry setting, for use with Config::get()
const WatchlistExpiryMaxDuration
Name constant for the WatchlistExpiryMaxDuration setting, for use with Config::get()
trait ApiWatchlistTrait
An ApiWatchlistTrait adds class properties and convenience methods for APIs that allow you to watch a...