82 parent::__construct(
'BlockList' );
84 $this->linkBatchFactory = $linkBatchFactory;
85 $this->blockStore = $blockStore;
86 $this->blockRestrictionStore = $blockRestrictionStore;
87 $this->dbProvider = $dbProvider;
88 $this->commentStore = $commentStore;
89 $this->blockUtils = $blockUtils;
90 $this->hideUserUtils = $hideUserUtils;
91 $this->blockActionInfo = $blockActionInfo;
92 $this->rowCommentFormatter = $rowCommentFormatter;
93 $this->tempUserConfig = $tempUserConfig;
104 $out->setPageTitleMsg( $this->
msg(
'ipblocklist' ) );
105 $out->addModuleStyles( [
'mediawiki.special' ] );
108 $par = $request->getVal(
'ip', $par ??
'' );
109 $this->target = trim( $request->getVal(
'wpTarget', $par ) );
111 $this->options = $request->getArray(
'wpOptions', [] );
112 $this->blockType = $request->getVal(
'blockType' );
114 $action = $request->getText(
'action' );
116 if ( $action ==
'unblock' || ( $action ==
'submit' && $request->wasPosted() ) ) {
119 $out->redirect( $title->getFullURL() );
127 $blockFilterOptions = [
128 'blocklist-tempblocks' =>
'tempblocks',
129 'blocklist-indefblocks' =>
'indefblocks',
130 'blocklist-autoblocks' =>
'autoblocks',
131 'blocklist-addressblocks' =>
'addressblocks',
132 'blocklist-rangeblocks' =>
'rangeblocks',
135 if ( $this->tempUserConfig->isKnown() ) {
137 $blockFilterOptions[
'blocklist-nameduserblocks'] =
'userblocks';
138 $blockFilterOptions[
'blocklist-tempuserblocks'] =
'tempuserblocks';
140 $blockFilterOptions[
'blocklist-userblocks'] =
'userblocks';
147 'label-message' =>
'ipaddressorusername',
153 'type' =>
'multiselect',
154 'options-messages' => $blockFilterOptions,
159 $fields[
'BlockType'] = [
161 'label-message' =>
'blocklist-type',
163 $this->
msg(
'blocklist-type-opt-all' )->escaped() =>
'',
164 $this->
msg(
'blocklist-type-opt-sitewide' )->escaped() =>
'sitewide',
165 $this->
msg(
'blocklist-type-opt-partial' )->escaped() =>
'partial',
167 'name' =>
'blockType',
168 'cssclass' =>
'mw-field-block-type',
172 'type' =>
'limitselect',
173 'label-message' =>
'table_pager_limit_label',
174 'options' => $pager->getLimitSelectList(),
176 'default' => $pager->getLimit(),
177 'cssclass' =>
'mw-field-limit mw-has-field-block-type',
180 $form = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
184 ->setFormIdentifier(
'blocklist' )
185 ->setWrapperLegendMsg(
'ipblocklist-legend' )
186 ->setSubmitTextMsg(
'ipblocklist-submit' )
188 ->displayForm(
false );
199 $db = $this->
getDB();
201 if ( $this->target !==
'' ) {
202 [
$target, $type ] = $this->blockUtils->parseBlockTarget( $this->target );
205 case DatabaseBlock::TYPE_ID:
206 case DatabaseBlock::TYPE_AUTO:
210 case DatabaseBlock::TYPE_IP:
211 case DatabaseBlock::TYPE_RANGE:
212 [ $start, $end ] = IPUtils::parseRange(
$target );
213 $conds[] = $this->blockStore->getRangeCond( $start, $end );
214 $conds[
'bt_auto'] = 0;
217 case DatabaseBlock::TYPE_USER:
219 $conds[
'bt_user'] =
$target->getId();
220 $conds[
'bt_auto'] = 0;
230 if ( in_array(
'userblocks', $this->options ) ) {
231 $namedUserConds = $db->expr(
'bt_user',
'=',
null );
235 if ( $this->tempUserConfig->isKnown() ) {
236 $namedUserConds = $namedUserConds->orExpr(
237 $this->tempUserConfig->getMatchCondition( $db,
'bt_user_text', IExpression::LIKE )
241 $conds[] = $namedUserConds;
243 if ( in_array(
'autoblocks', $this->options ) ) {
244 $conds[
'bl_parent_block_id'] =
null;
246 if ( in_array(
'addressblocks', $this->options )
247 && in_array(
'rangeblocks', $this->options )
250 $conds[] = $db->expr(
'bt_user',
'!=',
null );
251 } elseif ( in_array(
'addressblocks', $this->options ) ) {
252 $conds[] = $db->expr(
'bt_user',
'!=',
null )->or(
'bt_range_start',
'!=',
null );
253 } elseif ( in_array(
'rangeblocks', $this->options ) ) {
254 $conds[
'bt_range_start'] =
null;
258 in_array(
'tempuserblocks', $this->options ) &&
259 $this->tempUserConfig->isKnown()
261 $conds[] = $db->expr(
'bt_user',
'=',
null )
263 $this->tempUserConfig->getMatchCondition( $db,
'bt_user_text', IExpression::NOT_LIKE )
267 $hideTemp = in_array(
'tempblocks', $this->options );
268 $hideIndef = in_array(
'indefblocks', $this->options );
269 if ( $hideTemp && $hideIndef ) {
272 } elseif ( $hideTemp ) {
273 $conds[
'bl_expiry'] = $db->getInfinity();
274 } elseif ( $hideIndef ) {
275 $conds[] = $db->expr(
'bl_expiry',
'!=', $db->getInfinity() );
278 if ( $this->blockType ===
'sitewide' ) {
279 $conds[
'bl_sitewide'] = 1;
280 } elseif ( $this->blockType ===
'partial' ) {
281 $conds[
'bl_sitewide'] = 0;
286 $this->blockActionInfo,
287 $this->blockRestrictionStore,
289 $this->hideUserUtils,
291 $this->linkBatchFactory,
294 $this->rowCommentFormatter,
308 $otherBlockLink = [];
309 $this->
getHookRunner()->onOtherBlockLogLink( $otherBlockLink, $this->target );
313 if ( count( $otherBlockLink ) ) {
315 Html::element(
'h2', [], $this->
msg(
'ipblocklist-localblock' )->text() ) .
"\n"
321 } elseif ( $this->target ) {
322 $out->addWikiMsg(
'ipblocklist-no-results' );
324 $out->addWikiMsg(
'ipblocklist-empty' );
327 if ( count( $otherBlockLink ) ) {
332 $this->
msg(
'ipblocklist-otherblocks', count( $otherBlockLink ) )->parse()
336 foreach ( $otherBlockLink as $link ) {
337 $list .= Html::rawElement(
'li', [], $link ) .
"\n";
339 $out->addHTML( Html::rawElement(
341 [
'class' =>
'mw-ipblocklist-otherblocks' ],
357 return $this->dbProvider->getReplicaDatabase();
362class_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.