77 parent::__construct(
'Unblock',
'block' );
78 $this->unblockUserFactory = $unblockUserFactory;
79 $this->blockUtils = $blockUtils;
80 $this->blockStore = $blockStore;
81 $this->userNameUtils = $userNameUtils;
82 $this->userNamePrefixSearch = $userNamePrefixSearch;
83 $this->watchlistManager = $watchlistManager;
95 $this->block = $this->blockStore->newFromTarget( $this->target );
99 $this->
getSkin()->setRelevantUser( $this->target );
107 $out->setPageTitleMsg( $this->
msg(
'unblockip' ) );
108 $out->addModules( [
'mediawiki.userSuggest',
'mediawiki.special.block' ] );
111 ->setWrapperLegendMsg(
'unblockip' )
112 ->setSubmitCallback(
function ( array $data,
HTMLForm $form ) {
113 if ( $this->type != Block::TYPE_RANGE
114 && $this->type != Block::TYPE_AUTO
117 $this->watchlistManager->addWatchIgnoringRights(
119 Title::makeTitle(
NS_USER, $this->target )
122 return $this->unblockUserFactory->newUnblockUser(
129 ->setSubmitTextMsg(
'ipusubmit' )
130 ->addPreHtml( $this->
msg(
'unblockiptext' )->parseAsBlock() );
132 $userPage = $this->getTargetUserTitle( $this->target );
136 LogEventsList::showLogExtract(
144 'unblocklog-showlog',
145 $userPage->getText(),
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',
167 $userPage->getText(),
169 'showIfEmpty' =>
false
172 if ( $logExtract !==
'' ) {
178 if ( $form->
show() ) {
179 switch ( $this->type ) {
183 case Block::TYPE_USER:
186 case Block::TYPE_RANGE:
190 case Block::TYPE_AUTO:
207 private function getTargetAndType( ?
string $par,
WebRequest $request ) {
209 $request->
getVal(
'wpTarget',
null ),
211 $request->
getVal(
'ip',
null ),
213 $request->
getVal(
'wpBlockAddress',
null ),
215 foreach ( $possibleTargets as $possibleTarget ) {
216 $targetAndType = $this->blockUtils->parseBlockTarget( $possibleTarget );
218 if ( $targetAndType[ 1 ] !==
null ) {
222 return $targetAndType;
231 private function getTargetUserTitle(
$target ): ?Title {
247 'label-message' =>
'ipaddressorusername',
251 'cssclass' =>
'mw-autocomplete-user',
255 'label-message' =>
'ipaddressorusername',
259 'label-message' =>
'ipbreason',
263 if ( $this->block instanceof
Block ) {
264 $type = $this->block->getType();
265 $targetName = $this->block->getTargetName();
271 if ( $type == Block::TYPE_AUTO && $this->type == Block::TYPE_IP ) {
272 $fields[
'Target'][
'default'] = $this->target;
273 unset( $fields[
'Name'] );
275 $fields[
'Target'][
'default'] = $targetName;
276 $fields[
'Target'][
'type'] =
'hidden';
279 $fields[
'Name'][
'default'] = $this->getLinkRenderer()->makeKnownLink(
280 $this->getSpecialPageFactory()->getTitleForAlias(
'Contributions/' . $targetName ),
283 $fields[
'Name'][
'raw'] =
true;
285 case Block::TYPE_USER:
286 $fields[
'Name'][
'default'] = $this->getLinkRenderer()->makeLink(
290 $fields[
'Name'][
'raw'] =
true;
293 case Block::TYPE_RANGE:
294 $fields[
'Name'][
'default'] = $targetName;
297 case Block::TYPE_AUTO:
298 $fields[
'Name'][
'default'] = $this->block->getRedactedName();
299 $fields[
'Name'][
'raw'] =
true;
301 $fields[
'Target'][
'default'] =
"#{$this->target}";
305 $fields[
'Target'][
'autofocus'] =
false;
306 $fields[
'Reason'][
'autofocus'] =
true;
309 $fields[
'Target'][
'default'] = $this->target;
310 unset( $fields[
'Name'] );
313 if ( $this->
getUser()->isRegistered() ) {
316 'label-message' =>
'ipbwatchuser',
332 $search = $this->userNameUtils->getCanonical( $search );
338 return $this->userNamePrefixSearch
339 ->search( UserNamePrefixSearch::AUDIENCE_PUBLIC, $search, $limit, $offset );
351class_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.