23use InvalidArgumentException;
86 parent::__construct(
'BlockList' );
88 $this->linkBatchFactory = $linkBatchFactory;
89 $this->blockStore = $blockStore;
90 $this->blockRestrictionStore = $blockRestrictionStore;
91 $this->dbProvider = $dbProvider;
92 $this->commentStore = $commentStore;
93 $this->blockTargetFactory = $blockTargetFactory;
94 $this->hideUserUtils = $hideUserUtils;
95 $this->blockActionInfo = $blockActionInfo;
96 $this->rowCommentFormatter = $rowCommentFormatter;
97 $this->tempUserConfig = $tempUserConfig;
108 $out->setPageTitleMsg( $this->
msg(
'ipblocklist' ) );
109 $out->addModuleStyles( [
'mediawiki.special' ] );
112 $par = $request->getVal(
'ip', $par ??
'' );
113 $this->target = trim( $request->getVal(
'wpTarget', $par ) );
115 $this->options = $request->getArray(
'wpOptions', [] );
116 $this->blockType = $request->getVal(
'blockType' );
118 $action = $request->getText(
'action' );
120 if ( $action ==
'unblock' || ( $action ==
'submit' && $request->wasPosted() ) ) {
123 $out->redirect( $title->getFullURL() );
131 $blockFilterOptions = [
132 'blocklist-tempblocks' =>
'tempblocks',
133 'blocklist-indefblocks' =>
'indefblocks',
134 'blocklist-autoblocks' =>
'autoblocks',
135 'blocklist-addressblocks' =>
'addressblocks',
136 'blocklist-rangeblocks' =>
'rangeblocks',
139 if ( $this->tempUserConfig->isKnown() ) {
141 $blockFilterOptions[
'blocklist-nameduserblocks'] =
'userblocks';
142 $blockFilterOptions[
'blocklist-tempuserblocks'] =
'tempuserblocks';
144 $blockFilterOptions[
'blocklist-userblocks'] =
'userblocks';
151 'label-message' =>
'ipaddressorusername',
157 'type' =>
'multiselect',
158 'options-messages' => $blockFilterOptions,
163 $fields[
'BlockType'] = [
165 'label-message' =>
'blocklist-type',
167 $this->
msg(
'blocklist-type-opt-all' )->escaped() =>
'',
168 $this->
msg(
'blocklist-type-opt-sitewide' )->escaped() =>
'sitewide',
169 $this->
msg(
'blocklist-type-opt-partial' )->escaped() =>
'partial',
171 'name' =>
'blockType',
172 'cssclass' =>
'mw-field-block-type',
176 'type' =>
'limitselect',
177 'label-message' =>
'table_pager_limit_label',
178 'options' => $pager->getLimitSelectList(),
180 'default' => $pager->getLimit(),
181 'cssclass' =>
'mw-field-limit mw-has-field-block-type',
184 $form = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
188 ->setFormIdentifier(
'blocklist' )
189 ->setWrapperLegendMsg(
'ipblocklist-legend' )
190 ->setSubmitTextMsg(
'ipblocklist-submit' )
192 ->displayForm(
false );
203 $db = $this->
getDB();
206 if ( $this->target !==
'' ) {
207 $target = $this->blockTargetFactory->newFromString( $this->target );
209 $conds = $this->getTargetConds(
$target );
214 if ( in_array(
'userblocks', $this->options ) ) {
215 $namedUserConds = $db->expr(
'bt_user',
'=',
null );
219 if ( $this->tempUserConfig->isKnown() ) {
220 $namedUserConds = $namedUserConds->orExpr(
221 $this->tempUserConfig->getMatchCondition( $db,
'bt_user_text', IExpression::LIKE )
225 $conds[] = $namedUserConds;
227 if ( in_array(
'autoblocks', $this->options ) ) {
228 $conds[
'bl_parent_block_id'] =
null;
230 if ( in_array(
'addressblocks', $this->options )
231 && in_array(
'rangeblocks', $this->options )
234 $conds[] = $db->expr(
'bt_user',
'!=',
null );
235 } elseif ( in_array(
'addressblocks', $this->options ) ) {
236 $conds[] = $db->expr(
'bt_user',
'!=',
null )->or(
'bt_range_start',
'!=',
null );
237 } elseif ( in_array(
'rangeblocks', $this->options ) ) {
238 $conds[
'bt_range_start'] =
null;
242 in_array(
'tempuserblocks', $this->options ) &&
243 $this->tempUserConfig->isKnown()
245 $conds[] = $db->expr(
'bt_user',
'=',
null )
247 $this->tempUserConfig->getMatchCondition( $db,
'bt_user_text', IExpression::NOT_LIKE )
251 $hideTemp = in_array(
'tempblocks', $this->options );
252 $hideIndef = in_array(
'indefblocks', $this->options );
253 if ( $hideTemp && $hideIndef ) {
256 } elseif ( $hideTemp ) {
257 $conds[
'bl_expiry'] = $db->getInfinity();
258 } elseif ( $hideIndef ) {
259 $conds[] = $db->expr(
'bl_expiry',
'!=', $db->getInfinity() );
262 if ( $this->blockType ===
'sitewide' ) {
263 $conds[
'bl_sitewide'] = 1;
264 } elseif ( $this->blockType ===
'partial' ) {
265 $conds[
'bl_sitewide'] = 0;
270 $this->blockActionInfo,
271 $this->blockRestrictionStore,
272 $this->blockTargetFactory,
273 $this->hideUserUtils,
275 $this->linkBatchFactory,
278 $this->rowCommentFormatter,
299 return [
'bl_id' =>
$target->getId() ];
301 if (
$target instanceof BlockTargetWithIp ) {
302 $range =
$target->toHexRange();
304 $this->blockStore->getRangeCond( $range[0], $range[1] ),
308 if (
$target instanceof UserBlockTarget ) {
309 $user =
$target->getUserIdentity();
310 if ( $user->getId() ) {
312 'bt_user' => $user->getId(),
320 throw new InvalidArgumentException(
'Invalid block target type' );
331 $otherBlockLink = [];
332 $this->
getHookRunner()->onOtherBlockLogLink( $otherBlockLink, $this->target );
336 if ( count( $otherBlockLink ) ) {
338 Html::element(
'h2', [], $this->
msg(
'ipblocklist-localblock' )->text() ) .
"\n"
343 $out->addParserOutputContent(
345 ParserOptions::newFromContext( $this->getContext() )
347 } elseif ( $this->target ) {
348 $out->addWikiMsg(
'ipblocklist-no-results' );
350 $out->addWikiMsg(
'ipblocklist-empty' );
353 if ( count( $otherBlockLink ) ) {
358 $this->
msg(
'ipblocklist-otherblocks', count( $otherBlockLink ) )->parse()
362 foreach ( $otherBlockLink as $link ) {
363 $list .= Html::rawElement(
'li', [], $link ) .
"\n";
365 $out->addHTML( Html::rawElement(
367 [
'class' =>
'mw-ipblocklist-otherblocks' ],
383 return $this->dbProvider->getReplicaDatabase();
388class_alias( SpecialBlockList::class,
'SpecialBlockList' );
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getPageTitle( $subpage=false)
Get a self-referential title 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.
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.