Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4058766
SpecialRemoveGlobalBlock.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
SpecialRemoveGlobalBlock.php
View Options
<?php
namespace
MediaWiki\Extension\GlobalBlocking\Special
;
use
MediaWiki\Block\BlockUtils
;
use
MediaWiki\Extension\GlobalBlocking\Services\GlobalBlockingLinkBuilder
;
use
MediaWiki\Extension\GlobalBlocking\Services\GlobalBlockLookup
;
use
MediaWiki\Extension\GlobalBlocking\Services\GlobalBlockManager
;
use
MediaWiki\Extension\GlobalBlocking\Widget\HTMLUserTextFieldAllowingGlobalBlockIds
;
use
MediaWiki\HTMLForm\HTMLForm
;
use
MediaWiki\SpecialPage\FormSpecialPage
;
use
MediaWiki\SpecialPage\SpecialPage
;
use
MediaWiki\Status\Status
;
use
MediaWiki\User\UserIdentity
;
use
MediaWiki\User\UserNameUtils
;
use
Wikimedia\IPUtils
;
class
SpecialRemoveGlobalBlock
extends
FormSpecialPage
{
private
string
$target
;
public
function
__construct
(
private
readonly
BlockUtils
$blockUtils
,
private
readonly
UserNameUtils
$userNameUtils
,
private
readonly
GlobalBlockManager
$globalBlockManager
,
private
readonly
GlobalBlockingLinkBuilder
$globalBlockingLinkBuilder
,
)
{
parent
::
__construct
(
'RemoveGlobalBlock'
,
'globalblock'
);
}
/** @inheritDoc */
public
function
execute
(
$par
)
{
parent
::
execute
(
$par
);
$this
->
addHelpLink
(
'Extension:GlobalBlocking'
);
$out
=
$this
->
getOutput
();
$out
->
setPageTitleMsg
(
$this
->
msg
(
'globalblocking-unblock'
)
);
$out
->
setSubtitle
(
$this
->
globalBlockingLinkBuilder
->
buildSubtitleLinks
(
$this
)
);
$out
->
disableClientCache
();
[
$target
]
=
$this
->
blockUtils
->
parseBlockTarget
(
$par
);
if
(
$target
instanceof
UserIdentity
)
{
$this
->
getSkin
()->
setRelevantUser
(
$target
);
}
}
/** @inheritDoc */
protected
function
setParameter
(
$par
)
{
parent
::
setParameter
(
$par
);
// 'address' is a old name for the 'target' field, which is retained for B/C
$request
=
$this
->
getRequest
();
$target
=
trim
(
$request
->
getText
(
'target'
,
$request
->
getText
(
'address'
,
$par
??
''
)
)
);
if
(
IPUtils
::
isValidRange
(
$target
)
)
{
$target
=
IPUtils
::
sanitizeRange
(
$target
);
}
elseif
(
IPUtils
::
isValid
(
$target
)
)
{
$target
=
IPUtils
::
sanitizeIP
(
$target
);
}
else
{
$target
=
$this
->
userNameUtils
->
getCanonical
(
$target
)
?:
$target
;
}
'@phan-var string $target'
;
$this
->
target
=
$target
;
}
/** @inheritDoc */
public
function
onSubmit
(
array
$data
)
{
return
Status
::
wrap
(
$this
->
globalBlockManager
->
unblock
(
$this
->
target
,
$data
[
'reason'
],
$this
->
getUser
()
)
);
}
/** @inheritDoc */
public
function
onSuccess
()
{
$successMsgKey
=
'globalblocking-unblock-unblocked'
;
$target
=
$this
->
target
;
// Display the global block ID specific message if the target is a global block ID.
$globalBlockId
=
GlobalBlockLookup
::
isAGlobalBlockId
(
$this
->
target
);
if
(
$globalBlockId
)
{
$successMsgKey
.=
'-for-id-target'
;
// Use the ID without the "#" prefix, as this is added by the message.
$target
=
$globalBlockId
;
}
// Display the success message and also a link to go to Special:GlobalBlockList
$msg
=
$this
->
msg
(
$successMsgKey
,
$target
)->
parseAsBlock
();
$link
=
$this
->
getLinkRenderer
()->
makeKnownLink
(
SpecialPage
::
getTitleFor
(
'GlobalBlockList'
),
$this
->
msg
(
'globalblocking-return'
)->
text
()
);
$this
->
getOutput
()->
addHTML
(
$msg
.
$link
);
}
/** @inheritDoc */
protected
function
alterForm
(
HTMLForm
$form
)
{
$form
->
setWrapperLegendMsg
(
'globalblocking-unblock-legend'
);
$form
->
setSubmitTextMsg
(
'globalblocking-unblock-submit'
);
$form
->
setPreHtml
(
$this
->
msg
(
'globalblocking-unblock-intro'
)->
parse
()
);
}
/** @inheritDoc */
protected
function
getFormFields
()
{
return
[
'target'
=>
[
'name'
=>
'target'
,
'class'
=>
HTMLUserTextFieldAllowingGlobalBlockIds
::
class
,
'ipallowed'
=>
true
,
'iprange'
=>
true
,
'id'
=>
'mw-globalblocking-target'
,
'label-message'
=>
'globalblocking-target-with-block-ids'
,
'required'
=>
true
,
'default'
=>
$this
->
target
,
],
'reason'
=>
[
'name'
=>
'wpReason'
,
'type'
=>
'text'
,
'id'
=>
'mw-globalblocking-unblock-reason'
,
'label-message'
=>
'globalblocking-unblock-reason'
,
],
];
}
/** @inheritDoc */
public
function
doesWrites
()
{
return
true
;
}
/** @inheritDoc */
protected
function
getGroupName
()
{
return
'users'
;
}
/** @inheritDoc */
protected
function
getDisplayFormat
()
{
return
'ooui'
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 16 2026, 04:59 (12 w, 21 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
40/a2/f66d27b81c5ee5471988424c0145
Default Alt Text
SpecialRemoveGlobalBlock.php (4 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment