55 parent::__construct(
'Unblock',
'block' );
56 $this->unblockUserFactory = $unblockUserFactory;
57 $this->blockTargetFactory = $blockTargetFactory;
58 $this->blockStore = $blockStore;
59 $this->userNameUtils = $userNameUtils;
60 $this->userNamePrefixSearch = $userNamePrefixSearch;
61 $this->watchlistManager = $watchlistManager;
74 $this->target = $this->getTargetFromRequest( $par, $this->
getRequest() );
81 if ( $this->target ===
null ) {
91 $this->block = $this->blockStore->newFromTarget( $this->target );
95 $this->
getSkin()->setRelevantUser( $this->target->getUserIdentity() );
103 $out->setPageTitleMsg( $this->
msg(
'unblock-target' ) );
104 $out->addModules( [
'mediawiki.userSuggest',
'mediawiki.special.block' ] );
107 ->setWrapperLegendMsg(
'unblock-target' )
108 ->setSubmitCallback(
function ( array $data,
HTMLForm $form ) {
110 $this->watchlistManager->addWatchIgnoringRights(
112 Title::newFromPageReference( $this->target->getUserPage() )
115 $status = $this->unblockUserFactory->newUnblockUser(
122 if ( $status->hasMessage(
'ipb_cant_unblock_multiple_blocks' ) ) {
124 $status->error(
'unblock-error-multiblocks', $this->target->toString() );
128 ->setSubmitTextMsg(
'ipusubmit' )
129 ->addPreHtml( $this->
msg(
'unblockiptext' )->parseAsBlock() );
131 if ( $this->target ) {
132 $userPage = $this->target->getLogPage();
133 $targetName = (string)$this->target;
136 LogEventsList::showLogExtract(
144 'unblocklog-showlog',
147 'showIfEmpty' =>
false
150 if ( $logExtract !==
'' ) {
155 if ( $this->
getAuthority()->isAllowed(
'suppressionlog' ) ) {
157 LogEventsList::showLogExtract(
164 'conds' => [
'log_action' => [
'block',
'reblock',
'unblock' ] ],
166 'unblocklog-showsuppresslog',
169 'showIfEmpty' =>
false
172 if ( $logExtract !==
'' ) {
178 if ( $form->
show() ) {
180 Block::TYPE_IP =>
'unblocked-ip',
181 Block::TYPE_USER =>
'unblocked',
182 Block::TYPE_RANGE =>
'unblocked-range',
183 Block::TYPE_AUTO =>
'unblocked-id'
186 $msgsByType[$this->target->getType()],
201 private function getTargetFromRequest( ?
string $par,
WebRequest $request ) {
203 $request->
getVal(
'wpTarget',
null ),
205 $request->
getVal(
'ip',
null ),
207 $request->
getVal(
'wpBlockAddress',
null ),
209 foreach ( $possibleTargets as $possibleTarget ) {
210 $target = $this->blockTargetFactory->newFromString( $possibleTarget );
223 'label-message' =>
'unblock-target-label',
227 'cssclass' =>
'mw-autocomplete-user',
231 'label-message' =>
'unblock-target-label',
235 'label-message' =>
'ipbreason',
239 if ( $this->block instanceof
Block ) {
240 $type = $this->block->getType();
241 $targetName = $this->block->getTargetName();
247 if ( $type == Block::TYPE_AUTO && $this->target->getType() == Block::TYPE_IP ) {
248 $fields[
'Target'][
'default'] = (string)$this->target;
249 unset( $fields[
'Name'] );
251 $fields[
'Target'][
'default'] = $targetName;
252 $fields[
'Target'][
'type'] =
'hidden';
259 $fields[
'Name'][
'raw'] =
true;
261 case Block::TYPE_USER:
266 $fields[
'Name'][
'raw'] =
true;
269 case Block::TYPE_RANGE:
270 $fields[
'Name'][
'default'] = $targetName;
273 case Block::TYPE_AUTO:
275 $fields[
'Name'][
'default'] = $this->block->getRedactedName();
276 $fields[
'Name'][
'raw'] =
true;
277 $fields[
'Target'][
'default'] = $this->block->getRedactedTarget()->toString();
281 $fields[
'Target'][
'autofocus'] =
false;
282 $fields[
'Reason'][
'autofocus'] =
true;
286 unset( $fields[
'Name'] );
289 if ( $this->
getUser()->isRegistered() ) {
292 'label-message' =>
'ipbwatchuser',
308 $search = $this->userNameUtils->getCanonical( $search );
314 return $this->userNamePrefixSearch
328class_alias( SpecialUnblock::class,
'SpecialUnblock' );
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getContext()
Get the base IContextSource object.
A class containing constants representing the names of configuration variables.
const UseCodexSpecialBlock
Name constant for the UseCodexSpecialBlock setting, for use with Config::get()
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getSkin()
Shortcut to get the skin being used for this instance.
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,...
getUser()
Shortcut to get the User executing this instance.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
getConfig()
Shortcut to get main config object.
getContext()
Gets the context this SpecialPage is executed in.
getRequest()
Get the WebRequest being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getAuthority()
Shortcut to get the Authority executing this instance.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Shared interface for user and single IP targets, that is, for targets with a meaningful user page lin...