71 parent::__construct(
'Unblock',
'block' );
87 $this->block = DatabaseBlock::newFromTarget( $this->target );
89 # Set the 'relevant user' in the skin, so it displays links like Contributions,
90 # User logs, UserRights, etc.
91 $this->
getSkin()->setRelevantUser( $this->target );
99 $out->setPageTitle( $this->
msg(
'unblockip' ) );
100 $out->addModules( [
'mediawiki.userSuggest' ] );
103 ->setWrapperLegendMsg(
'unblockip' )
104 ->setSubmitCallback(
function ( array $data,
HTMLForm $form ) {
105 return $this->unblockUserFactory->newUnblockUser(
112 ->setSubmitTextMsg(
'ipusubmit' )
113 ->addPreText( $this->
msg(
'unblockiptext' )->parseAsBlock() );
115 if ( $form->
show() ) {
116 switch ( $this->type ) {
117 case DatabaseBlock::TYPE_IP:
120 case DatabaseBlock::TYPE_USER:
123 case DatabaseBlock::TYPE_RANGE:
126 case DatabaseBlock::TYPE_ID:
127 case DatabaseBlock::TYPE_AUTO:
146 $request->
getVal(
'wpTarget',
null ),
148 $request->
getVal(
'ip',
null ),
150 $request->
getVal(
'wpBlockAddress',
null ),
152 foreach ( $possibleTargets as $possibleTarget ) {
153 $targetAndType = $this->blockUtils->parseBlockTarget( $possibleTarget );
155 if ( $targetAndType[ 1 ] !==
null ) {
159 return $targetAndType;
166 'label-message' =>
'ipaddressorusername',
170 'cssclass' =>
'mw-autocomplete-user',
174 'label-message' =>
'ipaddressorusername',
178 'label-message' =>
'ipbreason',
183 $type = $this->block->getType();
184 $targetName = $this->block->getTargetName();
186 # Autoblocks are logged as "autoblock #123 because the IP was recently used by
187 # User:Foo, and we've just got any block, auto or not, that applies to a target
188 # the user has specified. Someone could be fishing to connect IPs to autoblocks,
189 # so don't show any distinction between unblocked IPs and autoblocked IPs
190 if ( $type == DatabaseBlock::TYPE_AUTO && $this->type == DatabaseBlock::TYPE_IP ) {
191 $fields['Target']['default'] = $this->target;
192 unset( $fields['Name'] );
194 $fields['Target']['default'] = $targetName;
195 $fields['Target']['type'] = 'hidden';
197 case DatabaseBlock::TYPE_IP:
198 $fields['Name']['default'] = $this->getLinkRenderer()->makeKnownLink(
199 $this->getSpecialPageFactory()->getTitleForAlias( 'Contributions/' . $targetName ),
202 $fields['Name']['raw'] = true;
204 case DatabaseBlock::TYPE_USER:
205 $fields['Name']['default'] = $this->getLinkRenderer()->makeLink(
206 new TitleValue( NS_USER, $targetName ),
209 $fields['Name']['raw'] = true;
212 case DatabaseBlock::TYPE_RANGE:
213 $fields['Name']['default'] = $targetName;
216 case DatabaseBlock::TYPE_AUTO:
217 $fields['Name']['default'] = $this->block->getRedactedName();
218 $fields['Name']['raw'] = true;
219 # Don't expose the real target of the autoblock
220 $fields['Target']['default'] = "#{$this->target}";
223 // target is hidden, so the reason is the first element
224 $fields['Target']['autofocus'] = false;
225 $fields['Reason']['autofocus'] = true;
228 $fields['Target']['default'] = $this->target;
229 unset( $fields['Name'] );
243 public static function processUnblock( array $data, IContextSource $context ) {
244 wfDeprecated( __METHOD__, '1.36' );
246 if ( !isset( $data['Tags'] ) ) {
250 $unblockUser = MediaWikiServices::getInstance()->getUnblockUserFactory()->newUnblockUser(
252 $context->getAuthority(),
257 $status = $unblockUser->unblock();
258 if ( !$status->isOK() ) {
259 return $status->getErrorsArray();
273 public function prefixSearchSubpages( $search, $limit, $offset ) {
274 $search = $this->userNameUtils->getCanonical( $search );
276 // No prefix suggestion for invalid user
279 // Autocomplete subpage as user list - public to allow caching
280 return $this->userNamePrefixSearch
281 ->search( UserNamePrefixSearch::AUDIENCE_PUBLIC, $search, $limit, $offset );
284 protected function getGroupName() {
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getContext()
Get the base IContextSource object.
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getSkin()
Shortcut to get the skin being used for this instance.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
A special page for unblocking users.
getTargetAndType(?string $par, WebRequest $request)
Get the target and type, given the request and the subpage parameter.
UserIdentity string null $target
doesWrites()
Indicates whether this special page may perform database writes.
execute( $par)
Default execute method Checks user permissions.
UserNameUtils $userNameUtils
__construct(UnblockUserFactory $unblockUserFactory, BlockUtils $blockUtils, UserNameUtils $userNameUtils, UserNamePrefixSearch $userNamePrefixSearch)
UnblockUserFactory $unblockUserFactory
UserNamePrefixSearch $userNamePrefixSearch
int null $type
DatabaseBlock::TYPE_ constant.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
getVal( $name, $default=null)
Fetch a text string and partially normalized it.