79 parent::__construct(
'Unblock',
'block' );
80 $this->unblockUserFactory = $unblockUserFactory;
81 $this->blockUtils = $blockUtils;
82 $this->blockStore = $blockStore;
83 $this->userNameUtils = $userNameUtils;
84 $this->userNamePrefixSearch = $userNamePrefixSearch;
85 $this->watchlistManager = $watchlistManager;
97 $this->block = $this->blockStore->newFromTarget( $this->target );
101 $this->
getSkin()->setRelevantUser( $this->target );
109 $out->setPageTitleMsg( $this->
msg(
'unblockip' ) );
110 $out->addModules( [
'mediawiki.userSuggest',
'mediawiki.special.block' ] );
113 ->setWrapperLegendMsg(
'unblockip' )
114 ->setSubmitCallback(
function ( array $data,
HTMLForm $form ) {
115 if ( $this->type != Block::TYPE_RANGE
116 && $this->type != Block::TYPE_AUTO
119 $this->watchlistManager->addWatchIgnoringRights(
121 Title::makeTitle(
NS_USER, $this->target )
124 return $this->unblockUserFactory->newUnblockUser(
131 ->setSubmitTextMsg(
'ipusubmit' )
132 ->addPreHtml( $this->
msg(
'unblockiptext' )->parseAsBlock() );
134 $userPage = $this->getTargetUserTitle( $this->target );
138 LogEventsList::showLogExtract(
146 'unblocklog-showlog',
147 $userPage->getText(),
149 'showIfEmpty' =>
false
152 if ( $logExtract !==
'' ) {
157 if ( $this->
getAuthority()->isAllowed(
'suppressionlog' ) ) {
159 LogEventsList::showLogExtract(
166 'conds' => [
'log_action' => [
'block',
'reblock',
'unblock' ] ],
168 'unblocklog-showsuppresslog',
169 $userPage->getText(),
171 'showIfEmpty' =>
false
174 if ( $logExtract !==
'' ) {
180 if ( $form->
show() ) {
181 switch ( $this->type ) {
185 case Block::TYPE_USER:
188 case Block::TYPE_RANGE:
192 case Block::TYPE_AUTO:
209 private function getTargetAndType( ?
string $par,
WebRequest $request ) {
211 $request->
getVal(
'wpTarget',
null ),
213 $request->
getVal(
'ip',
null ),
215 $request->
getVal(
'wpBlockAddress',
null ),
217 foreach ( $possibleTargets as $possibleTarget ) {
218 $targetAndType = $this->blockUtils->parseBlockTarget( $possibleTarget );
220 if ( $targetAndType[ 1 ] !==
null ) {
224 return $targetAndType;
233 private function getTargetUserTitle(
$target ): ?Title {
249 'label-message' =>
'ipaddressorusername',
253 'cssclass' =>
'mw-autocomplete-user',
257 'label-message' =>
'ipaddressorusername',
261 'label-message' =>
'ipbreason',
265 if ( $this->block instanceof
Block ) {
266 $type = $this->block->getType();
267 $targetName = $this->block->getTargetName();
273 if ( $type == Block::TYPE_AUTO && $this->type == Block::TYPE_IP ) {
274 $fields[
'Target'][
'default'] = $this->target;
275 unset( $fields[
'Name'] );
277 $fields[
'Target'][
'default'] = $targetName;
278 $fields[
'Target'][
'type'] =
'hidden';
281 $fields[
'Name'][
'default'] = $this->getLinkRenderer()->makeKnownLink(
282 $this->getSpecialPageFactory()->getTitleForAlias(
'Contributions/' . $targetName ),
285 $fields[
'Name'][
'raw'] =
true;
287 case Block::TYPE_USER:
288 $fields[
'Name'][
'default'] = $this->getLinkRenderer()->makeLink(
292 $fields[
'Name'][
'raw'] =
true;
295 case Block::TYPE_RANGE:
296 $fields[
'Name'][
'default'] = $targetName;
299 case Block::TYPE_AUTO:
300 $fields[
'Name'][
'default'] = $this->block->getRedactedName();
301 $fields[
'Name'][
'raw'] =
true;
303 $fields[
'Target'][
'default'] =
"#{$this->target}";
307 $fields[
'Target'][
'autofocus'] =
false;
308 $fields[
'Reason'][
'autofocus'] =
true;
311 $fields[
'Target'][
'default'] = $this->target;
312 unset( $fields[
'Name'] );
315 if ( $this->getUser()->isRegistered() ) {
318 'label-message' =>
'ipbwatchuser',
334 $search = $this->userNameUtils->getCanonical( $search );
340 return $this->userNamePrefixSearch
353class_alias( SpecialUnblock::class,
'SpecialUnblock' );
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
if(!defined('MW_SETUP_CALLBACK'))
getContext()
Get the base IContextSource object.
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.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
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.