71 parent::__construct(
'Unblock',
'block' );
72 $this->unblockUserFactory = $unblockUserFactory;
73 $this->blockTargetFactory = $blockTargetFactory;
74 $this->blockStore = $blockStore;
75 $this->userNameUtils = $userNameUtils;
76 $this->userNamePrefixSearch = $userNamePrefixSearch;
77 $this->watchlistManager = $watchlistManager;
90 $this->target = $this->getTargetFromRequest( $par, $this->
getRequest() );
93 if ( $this->useCodex ) {
95 if ( $this->target ===
null ) {
105 $this->block = $this->blockStore->newFromTarget( $this->target );
109 $this->
getSkin()->setRelevantUser( $this->target->getUserIdentity() );
117 $out->setPageTitleMsg( $this->
msg(
'unblock-target' ) );
118 $out->addModules( [
'mediawiki.userSuggest',
'mediawiki.special.block' ] );
121 ->setWrapperLegendMsg(
'unblock-target' )
122 ->setSubmitCallback(
function ( array $data,
HTMLForm $form ) {
124 $this->watchlistManager->addWatchIgnoringRights(
126 Title::newFromPageReference( $this->target->getUserPage() )
129 $status = $this->unblockUserFactory->newUnblockUser(
136 if ( $status->hasMessage(
'ipb_cant_unblock_multiple_blocks' ) ) {
138 $status->error(
'unblock-error-multiblocks', $this->target );
142 ->setSubmitTextMsg(
'ipusubmit' )
143 ->addPreHtml( $this->
msg(
'unblockiptext' )->parseAsBlock() );
145 if ( $this->target ) {
146 $userPage = $this->target->getLogPage();
147 $targetName = (string)$this->target;
150 LogEventsList::showLogExtract(
158 'unblocklog-showlog',
161 'showIfEmpty' =>
false
164 if ( $logExtract !==
'' ) {
169 if ( $this->
getAuthority()->isAllowed(
'suppressionlog' ) ) {
171 LogEventsList::showLogExtract(
178 'conds' => [
'log_action' => [
'block',
'reblock',
'unblock' ] ],
180 'unblocklog-showsuppresslog',
183 'showIfEmpty' =>
false
186 if ( $logExtract !==
'' ) {
192 if ( $form->
show() ) {
194 Block::TYPE_IP =>
'unblocked-ip',
195 Block::TYPE_USER =>
'unblocked',
196 Block::TYPE_RANGE =>
'unblocked-range',
197 Block::TYPE_AUTO =>
'unblocked-id'
200 $msgsByType[$this->target->getType()],
215 private function getTargetFromRequest( ?
string $par,
WebRequest $request ) {
217 $request->
getVal(
'wpTarget',
null ),
219 $request->
getVal(
'ip',
null ),
221 $request->
getVal(
'wpBlockAddress',
null ),
223 foreach ( $possibleTargets as $possibleTarget ) {
224 $target = $this->blockTargetFactory->newFromString( $possibleTarget );
237 'label-message' =>
'unblock-target-label',
241 'cssclass' =>
'mw-autocomplete-user',
245 'label-message' =>
'unblock-target-label',
249 'label-message' =>
'ipbreason',
253 if ( $this->block instanceof
Block ) {
254 $type = $this->block->getType();
255 $targetName = $this->block->getTargetName();
261 if ( $type == Block::TYPE_AUTO && $this->target->getType() == Block::TYPE_IP ) {
262 $fields[
'Target'][
'default'] = (string)$this->target;
263 unset( $fields[
'Name'] );
265 $fields[
'Target'][
'default'] = $targetName;
266 $fields[
'Target'][
'type'] =
'hidden';
273 $fields[
'Name'][
'raw'] =
true;
275 case Block::TYPE_USER:
280 $fields[
'Name'][
'raw'] =
true;
283 case Block::TYPE_RANGE:
284 $fields[
'Name'][
'default'] = $targetName;
287 case Block::TYPE_AUTO:
289 $fields[
'Name'][
'default'] = $this->block->getRedactedName();
290 $fields[
'Name'][
'raw'] =
true;
291 $fields[
'Target'][
'default'] = $this->block->getRedactedTarget()->toString();
295 $fields[
'Target'][
'autofocus'] =
false;
296 $fields[
'Reason'][
'autofocus'] =
true;
300 unset( $fields[
'Name'] );
303 if ( $this->
getUser()->isRegistered() ) {
306 'label-message' =>
'ipbwatchuser',
322 $search = $this->userNameUtils->getCanonical( $search );
328 return $this->userNamePrefixSearch
341class_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...