Go to the documentation of this file.
39 parent::__construct(
'Unblock',
'block' );
51 $this->block = DatabaseBlock::newFromTarget( $this->target );
52 if ( $this->target instanceof
User ) {
53 # Set the 'relevant user' in the skin, so it displays links like Contributions,
54 # User logs, UserRights, etc.
55 $this->
getSkin()->setRelevantUser( $this->target );
63 $out->setPageTitle( $this->
msg(
'unblockip' ) );
64 $out->addModules( [
'mediawiki.userSuggest' ] );
67 $form->setWrapperLegendMsg(
'unblockip' );
68 $form->setSubmitCallback( [ __CLASS__,
'processUIUnblock' ] );
69 $form->setSubmitTextMsg(
'ipusubmit' );
70 $form->addPreText( $this->
msg(
'unblockiptext' )->parseAsBlock() );
72 if ( $form->show() ) {
73 switch ( $this->type ) {
74 case DatabaseBlock::TYPE_IP:
77 case DatabaseBlock::TYPE_USER:
80 case DatabaseBlock::TYPE_RANGE:
83 case DatabaseBlock::TYPE_ID:
84 case DatabaseBlock::TYPE_AUTO:
95 'label-message' =>
'ipaddressorusername',
99 'cssclass' =>
'mw-autocomplete-user',
103 'label-message' =>
'ipaddressorusername',
107 'label-message' =>
'ipbreason',
112 list(
$target,
$type ) = $this->block->getTargetAndType();
114 # Autoblocks are logged as "autoblock #123 because the IP was recently used by
115 # User:Foo, and we've just got any block, auto or not, that applies to a target
116 # the user has specified. Someone could be fishing to connect IPs to autoblocks,
117 # so don't show any distinction between unblocked IPs and autoblocked IPs
118 if (
$type == DatabaseBlock::TYPE_AUTO && $this->type == DatabaseBlock::TYPE_IP ) {
120 unset( $fields[
'Name'] );
122 $fields[
'Target'][
'default'] =
$target;
123 $fields[
'Target'][
'type'] =
'hidden';
125 case DatabaseBlock::TYPE_IP:
130 $fields[
'Name'][
'raw'] =
true;
132 case DatabaseBlock::TYPE_USER:
137 $fields[
'Name'][
'raw'] =
true;
140 case DatabaseBlock::TYPE_RANGE:
141 $fields[
'Name'][
'default'] =
$target;
144 case DatabaseBlock::TYPE_AUTO:
145 $fields[
'Name'][
'default'] = $this->block->getRedactedName();
146 $fields[
'Name'][
'raw'] =
true;
147 # Don't expose the real target of the autoblock
148 $fields[
'Target'][
'default'] =
"#{$this->target}";
152 $fields[
'Target'][
'autofocus'] =
false;
153 $fields[
'Reason'][
'autofocus'] =
true;
157 unset( $fields[
'Name'] );
187 $block = DatabaseBlock::newFromTarget( $data[
'Target'] );
190 return [ [
'ipb_cant_unblock',
$target ] ];
193 # T17810: blocked admins should have limited access here. This
194 # won't allow sysops to remove autoblocks on themselves, but they
195 # should have ipblock-exempt anyway
201 # If the specified IP is a single address, and the block is a range block, don't
202 # unblock the whole range.
204 if (
$block->getType() == DatabaseBlock::TYPE_RANGE &&
$type == DatabaseBlock::TYPE_IP ) {
205 $range =
$block->getTarget();
207 return [ [
'ipb_blocked_as_range',
$target, $range ] ];
210 # If the name was hidden and the blocking user cannot hide
211 # names, then don't allow any block removals...
212 if ( !MediaWikiServices::getInstance()
214 ->userHasRight( $performer,
'hideuser' ) &&
$block->getHideName()
216 return [
'unblock-hideuser' ];
219 $reason = [
'hookaborted' ];
225 if ( !
$block->delete() ) {
226 return [ [
'ipb_cant_unblock', htmlspecialchars(
$block->getTarget() ) ] ];
231 # Unset _deleted fields as needed
232 if (
$block->getHideName() ) {
233 # Something is deeply FUBAR if this is not a User object, but who knows?
235 ?
$block->getTarget()->getId()
241 # Redact the name (IP address) for autoblocks
242 if (
$block->getType() == DatabaseBlock::TYPE_AUTO ) {
246 ?
$block->getTarget()->getUserPage()
252 $logEntry->setTarget( $page );
253 $logEntry->setComment( $data[
'Reason'] );
254 $logEntry->setPerformer( $performer );
255 if ( isset( $data[
'Tags'] ) ) {
256 $logEntry->addTags( $data[
'Tags'] );
258 $logEntry->setRelations( [
'ipb_id' =>
$block->getId() ] );
259 $logId = $logEntry->insert();
260 $logEntry->publish( $logId );
static processUnblock(array $data, IContextSource $context)
Process the form.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getContext()
Get the base IContextSource object.
getOutput()
Get the OutputPage being used for this instance.
static checkUnblockSelf( $target, User $performer)
T17810: blocked admins should not be able to block/unblock others, and probably shouldn't be able to ...
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getSkin()
Shortcut to get the skin being used for this instance.
static unsuppressUserName( $name, $userId, IDatabase $dbw=null)
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
getContext()
Gets the context this SpecialPage is executed in.
static processUIUnblock(array $data, HTMLForm $form)
Submit callback for an HTMLForm object.
execute( $par)
Default execute method Checks user permissions.
Parent class for all special pages.
getRequest()
Get the WebRequest being used for this instance.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Interface for objects which can provide a MediaWiki context on request.
static idFromName( $name, $flags=self::READ_NORMAL)
Get database id given a user name.
doesWrites()
Indicates whether this special page may perform database writes.
Class for creating new log entries and inserting them into the database.
static getTargetAndType( $par, WebRequest $request=null)
Determine the target of the block, and the type of target.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
A special page for unblocking users.
An error page which can definitely be safely rendered using the OutputPage.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...