80 parent::__construct(
'Unblock',
'block' );
81 $this->unblockUserFactory = $unblockUserFactory;
82 $this->blockUtils = $blockUtils;
83 $this->blockStore = $blockStore;
84 $this->userNameUtils = $userNameUtils;
85 $this->userNamePrefixSearch = $userNamePrefixSearch;
86 $this->watchlistManager = $watchlistManager;
98 $this->block = $this->blockStore->newFromTarget( $this->target );
102 $this->
getSkin()->setRelevantUser( $this->target );
110 $out->setPageTitleMsg( $this->
msg(
'unblockip' ) );
111 $out->addModules( [
'mediawiki.userSuggest',
'mediawiki.special.block' ] );
114 ->setWrapperLegendMsg(
'unblockip' )
115 ->setSubmitCallback(
function ( array $data,
HTMLForm $form ) {
116 if ( $this->type != Block::TYPE_RANGE
117 && $this->type != Block::TYPE_AUTO
120 $this->watchlistManager->addWatchIgnoringRights(
122 Title::makeTitle(
NS_USER, $this->target )
125 return $this->unblockUserFactory->newUnblockUser(
132 ->setSubmitTextMsg(
'ipusubmit' )
133 ->addPreHtml( $this->
msg(
'unblockiptext' )->parseAsBlock() );
135 $userPage = $this->getTargetUserTitle( $this->target );
139 LogEventsList::showLogExtract(
147 'unblocklog-showlog',
148 $userPage->getText(),
150 'showIfEmpty' =>
false
153 if ( $logExtract !==
'' ) {
158 if ( $this->
getAuthority()->isAllowed(
'suppressionlog' ) ) {
160 LogEventsList::showLogExtract(
167 'conds' => [
'log_action' => [
'block',
'reblock',
'unblock' ] ],
169 'unblocklog-showsuppresslog',
170 $userPage->getText(),
172 'showIfEmpty' =>
false
175 if ( $logExtract !==
'' ) {
181 if ( $form->
show() ) {
182 switch ( $this->type ) {
186 case Block::TYPE_USER:
189 case Block::TYPE_RANGE:
193 case Block::TYPE_AUTO:
210 private function getTargetAndType( ?
string $par,
WebRequest $request ) {
212 $request->
getVal(
'wpTarget',
null ),
214 $request->
getVal(
'ip',
null ),
216 $request->
getVal(
'wpBlockAddress',
null ),
218 foreach ( $possibleTargets as $possibleTarget ) {
219 $targetAndType = $this->blockUtils->parseBlockTarget( $possibleTarget );
221 if ( $targetAndType[ 1 ] !==
null ) {
225 return $targetAndType;
234 private function getTargetUserTitle(
$target ): ?Title {
250 'label-message' =>
'ipaddressorusername',
254 'cssclass' =>
'mw-autocomplete-user',
258 'label-message' =>
'ipaddressorusername',
262 'label-message' =>
'ipbreason',
266 if ( $this->block instanceof
Block ) {
267 $type = $this->block->getType();
268 $targetName = $this->block->getTargetName();
274 if ( $type == Block::TYPE_AUTO && $this->type == Block::TYPE_IP ) {
275 $fields[
'Target'][
'default'] = $this->target;
276 unset( $fields[
'Name'] );
278 $fields[
'Target'][
'default'] = $targetName;
279 $fields[
'Target'][
'type'] =
'hidden';
282 $fields[
'Name'][
'default'] = $this->getLinkRenderer()->makeKnownLink(
283 $this->getSpecialPageFactory()->getTitleForAlias(
'Contributions/' . $targetName ),
286 $fields[
'Name'][
'raw'] =
true;
288 case Block::TYPE_USER:
289 $fields[
'Name'][
'default'] = $this->getLinkRenderer()->makeLink(
293 $fields[
'Name'][
'raw'] =
true;
296 case Block::TYPE_RANGE:
297 $fields[
'Name'][
'default'] = $targetName;
300 case Block::TYPE_AUTO:
301 $fields[
'Name'][
'default'] = $this->block->getRedactedName();
302 $fields[
'Name'][
'raw'] =
true;
304 $fields[
'Target'][
'default'] =
"#{$this->target}";
308 $fields[
'Target'][
'autofocus'] =
false;
309 $fields[
'Reason'][
'autofocus'] =
true;
312 $fields[
'Target'][
'default'] = $this->target;
313 unset( $fields[
'Name'] );
316 if ( $this->
getUser()->isRegistered() ) {
319 'label-message' =>
'ipbwatchuser',
335 $search = $this->userNameUtils->getCanonical( $search );
341 return $this->userNamePrefixSearch
342 ->search( UserNamePrefixSearch::AUDIENCE_PUBLIC, $search, $limit, $offset );
354class_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 Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.