24 namespace MediaWiki\Specials;
39 use Wikimedia\IPUtils;
76 parent::__construct(
'Unblock',
'block' );
77 $this->unblockUserFactory = $unblockUserFactory;
78 $this->blockUtils = $blockUtils;
79 $this->userNameUtils = $userNameUtils;
80 $this->userNamePrefixSearch = $userNamePrefixSearch;
81 $this->watchlistManager = $watchlistManager;
97 $this->
getSkin()->setRelevantUser( $this->target );
105 $out->setPageTitleMsg( $this->
msg(
'unblockip' ) );
106 $out->addModules( [
'mediawiki.userSuggest',
'mediawiki.special.block' ] );
109 ->setWrapperLegendMsg(
'unblockip' )
110 ->setSubmitCallback(
function ( array $data,
HTMLForm $form ) {
115 $this->watchlistManager->addWatchIgnoringRights(
120 return $this->unblockUserFactory->newUnblockUser(
127 ->setSubmitTextMsg(
'ipusubmit' )
128 ->addPreHtml( $this->
msg(
'unblockiptext' )->parseAsBlock() );
130 $userPage = $this->getTargetUserTitle( $this->target );
142 'unblocklog-showlog',
143 $userPage->getText(),
145 'showIfEmpty' =>
false
148 if ( $logExtract !==
'' ) {
153 if ( $this->
getAuthority()->isAllowed(
'suppressionlog' ) ) {
162 'conds' => [
'log_action' => [
'block',
'reblock',
'unblock' ] ],
164 'unblocklog-showsuppresslog',
165 $userPage->getText(),
167 'showIfEmpty' =>
false
170 if ( $logExtract !==
'' ) {
176 if ( $form->
show() ) {
177 switch ( $this->type ) {
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',
266 $type = $this->block->getType();
267 $targetName = $this->block->getTargetName();
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;
288 $fields[
'Name'][
'default'] = $this->getLinkRenderer()->makeLink(
292 $fields[
'Name'][
'raw'] =
true;
296 $fields[
'Name'][
'default'] = $targetName;
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
341 ->search( UserNamePrefixSearch::AUDIENCE_PUBLIC, $search, $limit, $offset );
353 class_alias( SpecialUnblock::class,
'SpecialUnblock' );
wfEscapeWikiText( $text)
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.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
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 Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.