24 namespace MediaWiki\Specials;
37 use Wikimedia\IPUtils;
70 parent::__construct(
'BlockList' );
72 $this->linkBatchFactory = $linkBatchFactory;
73 $this->blockRestrictionStore = $blockRestrictionStore;
74 $this->dbProvider = $dbProvider;
75 $this->commentStore = $commentStore;
76 $this->blockUtils = $blockUtils;
77 $this->blockActionInfo = $blockActionInfo;
78 $this->rowCommentFormatter = $rowCommentFormatter;
89 $out->setPageTitleMsg( $this->
msg(
'ipblocklist' ) );
90 $out->addModuleStyles( [
'mediawiki.special' ] );
93 $par = $request->getVal(
'ip', $par ??
'' );
94 $this->target = trim( $request->getVal(
'wpTarget', $par ) );
96 $this->options = $request->getArray(
'wpOptions', [] );
97 $this->blockType = $request->getVal(
'blockType' );
99 $action = $request->getText(
'action' );
101 if ( $action ==
'unblock' || $action ==
'submit' && $request->wasPosted() ) {
104 $out->redirect( $title->getFullURL() );
116 'label-message' =>
'ipaddressorusername',
122 'type' =>
'multiselect',
123 'options-messages' => [
124 'blocklist-tempblocks' =>
'tempblocks',
125 'blocklist-indefblocks' =>
'indefblocks',
126 'blocklist-autoblocks' =>
'autoblocks',
127 'blocklist-userblocks' =>
'userblocks',
128 'blocklist-addressblocks' =>
'addressblocks',
129 'blocklist-rangeblocks' =>
'rangeblocks',
135 $fields[
'BlockType'] = [
137 'label-message' =>
'blocklist-type',
139 $this->
msg(
'blocklist-type-opt-all' )->escaped() =>
'',
140 $this->
msg(
'blocklist-type-opt-sitewide' )->escaped() =>
'sitewide',
141 $this->
msg(
'blocklist-type-opt-partial' )->escaped() =>
'partial',
143 'name' =>
'blockType',
144 'cssclass' =>
'mw-field-block-type',
148 'type' =>
'limitselect',
149 'label-message' =>
'table_pager_limit_label',
150 'options' => $pager->getLimitSelectList(),
152 'default' => $pager->getLimit(),
153 'cssclass' =>
'mw-field-limit mw-has-field-block-type',
160 ->setFormIdentifier(
'blocklist' )
161 ->setWrapperLegendMsg(
'ipblocklist-legend' )
162 ->setSubmitTextMsg(
'ipblocklist-submit' )
164 ->displayForm(
false );
175 $db = $this->
getDB();
177 if ( !$this->
getAuthority()->isAllowed(
'hideuser' ) ) {
178 $conds[
'ipb_deleted'] = 0;
181 if ( $this->target !==
'' ) {
182 [
$target, $type ] = $this->blockUtils->parseBlockTarget( $this->target );
192 [ $start, $end ] = IPUtils::parseRange(
$target );
193 $conds[] = $db->makeList(
200 $conds[
'ipb_auto'] = 0;
204 $conds[
'ipb_address'] =
$target->getName();
205 $conds[
'ipb_auto'] = 0;
211 if ( in_array(
'userblocks', $this->options ) ) {
212 $conds[
'ipb_user'] = 0;
214 if ( in_array(
'autoblocks', $this->options ) ) {
216 $conds[
'ipb_parent_block_id'] = [
null, 0 ];
218 if ( in_array(
'addressblocks', $this->options ) ) {
219 $conds[] =
"ipb_user != 0 OR ipb_range_end > ipb_range_start";
221 if ( in_array(
'rangeblocks', $this->options ) ) {
222 $conds[] =
"ipb_range_end = ipb_range_start";
225 $hideTemp = in_array(
'tempblocks', $this->options );
226 $hideIndef = in_array(
'indefblocks', $this->options );
227 if ( $hideTemp && $hideIndef ) {
230 } elseif ( $hideTemp ) {
231 $conds[
'ipb_expiry'] = $db->getInfinity();
232 } elseif ( $hideIndef ) {
233 $conds[] =
"ipb_expiry != " . $db->addQuotes( $db->getInfinity() );
236 if ( $this->blockType ===
'sitewide' ) {
237 $conds[
'ipb_sitewide'] = 1;
238 } elseif ( $this->blockType ===
'partial' ) {
239 $conds[
'ipb_sitewide'] = 0;
244 $this->blockActionInfo,
245 $this->blockRestrictionStore,
248 $this->linkBatchFactory,
251 $this->rowCommentFormatter,
265 $otherBlockLink = [];
266 $this->
getHookRunner()->onOtherBlockLogLink( $otherBlockLink, $this->target );
270 if ( count( $otherBlockLink ) ) {
272 Html::element(
'h2', [], $this->
msg(
'ipblocklist-localblock' )->text() ) .
"\n"
278 } elseif ( $this->target ) {
279 $out->addWikiMsg(
'ipblocklist-no-results' );
281 $out->addWikiMsg(
'ipblocklist-empty' );
284 if ( count( $otherBlockLink ) ) {
289 $this->
msg(
'ipblocklist-otherblocks', count( $otherBlockLink ) )->parse()
293 foreach ( $otherBlockLink as $link ) {
298 [
'class' =>
'mw-ipblocklist-otherblocks' ],
314 return $this->dbProvider->getReplicaDatabase();
321 class_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.
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.