24 namespace MediaWiki\Specials;
37 use Wikimedia\IPUtils;
54 private $linkBatchFactory;
57 private $blockRestrictionStore;
63 private $commentStore;
69 private $blockActionInfo;
72 private $rowCommentFormatter;
83 parent::__construct(
'BlockList' );
85 $this->linkBatchFactory = $linkBatchFactory;
86 $this->blockRestrictionStore = $blockRestrictionStore;
87 $this->dbProvider = $dbProvider;
88 $this->commentStore = $commentStore;
89 $this->blockUtils = $blockUtils;
90 $this->blockActionInfo = $blockActionInfo;
91 $this->rowCommentFormatter = $rowCommentFormatter;
102 $out->setPageTitle( $this->
msg(
'ipblocklist' ) );
103 $out->addModuleStyles( [
'mediawiki.special' ] );
106 $par = $request->getVal(
'ip', $par ??
'' );
107 $this->target = trim( $request->getVal(
'wpTarget', $par ) );
109 $this->options = $request->getArray(
'wpOptions', [] );
110 $this->blockType = $request->getVal(
'blockType' );
112 $action = $request->getText(
'action' );
114 if ( $action ==
'unblock' || $action ==
'submit' && $request->wasPosted() ) {
115 # B/C @since 1.18: Unblock interface is now at Special:Unblock
117 $out->redirect(
$title->getFullURL() );
122 # setup BlockListPager here to get the actual default Limit
125 # Just show the block list
129 'label-message' =>
'ipaddressorusername',
135 'type' =>
'multiselect',
136 'options-messages' => [
137 'blocklist-tempblocks' =>
'tempblocks',
138 'blocklist-indefblocks' =>
'indefblocks',
139 'blocklist-autoblocks' =>
'autoblocks',
140 'blocklist-userblocks' =>
'userblocks',
141 'blocklist-addressblocks' =>
'addressblocks',
142 'blocklist-rangeblocks' =>
'rangeblocks',
148 $fields[
'BlockType'] = [
150 'label-message' =>
'blocklist-type',
152 $this->
msg(
'blocklist-type-opt-all' )->escaped() =>
'',
153 $this->
msg(
'blocklist-type-opt-sitewide' )->escaped() =>
'sitewide',
154 $this->
msg(
'blocklist-type-opt-partial' )->escaped() =>
'partial',
156 'name' =>
'blockType',
157 'cssclass' =>
'mw-field-block-type',
161 'type' =>
'limitselect',
162 'label-message' =>
'table_pager_limit_label',
163 'options' => $pager->getLimitSelectList(),
165 'default' => $pager->getLimit(),
166 'cssclass' =>
'mw-field-limit mw-has-field-block-type',
173 ->setFormIdentifier(
'blocklist' )
174 ->setWrapperLegendMsg(
'ipblocklist-legend' )
175 ->setSubmitTextMsg(
'ipblocklist-submit' )
177 ->displayForm(
false );
188 $db = $this->
getDB();
189 # Is the user allowed to see hidden blocks?
190 if ( !$this->
getAuthority()->isAllowed(
'hideuser' ) ) {
191 $conds[
'ipb_deleted'] = 0;
194 if ( $this->target !==
'' ) {
195 [
$target,
$type ] = $this->blockUtils->parseBlockTarget( $this->target );
205 [ $start, $end ] = IPUtils::parseRange(
$target );
206 $conds[] = $db->makeList(
213 $conds[
'ipb_auto'] = 0;
217 $conds[
'ipb_address'] =
$target->getName();
218 $conds[
'ipb_auto'] = 0;
224 if ( in_array(
'userblocks', $this->options ) ) {
225 $conds[
'ipb_user'] = 0;
227 if ( in_array(
'autoblocks', $this->options ) ) {
229 $conds[] =
"ipb_parent_block_id IS NULL OR ipb_parent_block_id = 0";
231 if ( in_array(
'addressblocks', $this->options ) ) {
232 $conds[] =
"ipb_user != 0 OR ipb_range_end > ipb_range_start";
234 if ( in_array(
'rangeblocks', $this->options ) ) {
235 $conds[] =
"ipb_range_end = ipb_range_start";
238 $hideTemp = in_array(
'tempblocks', $this->options );
239 $hideIndef = in_array(
'indefblocks', $this->options );
240 if ( $hideTemp && $hideIndef ) {
243 } elseif ( $hideTemp ) {
244 $conds[
'ipb_expiry'] = $db->getInfinity();
245 } elseif ( $hideIndef ) {
246 $conds[] =
"ipb_expiry != " . $db->addQuotes( $db->getInfinity() );
249 if ( $this->blockType ===
'sitewide' ) {
250 $conds[
'ipb_sitewide'] = 1;
251 } elseif ( $this->blockType ===
'partial' ) {
252 $conds[
'ipb_sitewide'] = 0;
257 $this->blockActionInfo,
258 $this->blockRestrictionStore,
261 $this->linkBatchFactory,
264 $this->rowCommentFormatter,
277 # Check for other blocks, i.e. global/tor blocks
278 $otherBlockLink = [];
279 $this->
getHookRunner()->onOtherBlockLogLink( $otherBlockLink, $this->target );
281 # Show additional header for the local block only when other blocks exists.
282 # Not necessary in a standard installation without such extensions enabled
283 if ( count( $otherBlockLink ) ) {
285 Html::element(
'h2', [], $this->
msg(
'ipblocklist-localblock' )->text() ) .
"\n"
291 } elseif ( $this->target ) {
292 $out->addWikiMsg(
'ipblocklist-no-results' );
294 $out->addWikiMsg(
'ipblocklist-empty' );
297 if ( count( $otherBlockLink ) ) {
302 $this->
msg(
'ipblocklist-otherblocks', count( $otherBlockLink ) )->parse()
306 foreach ( $otherBlockLink as $link ) {
311 [
'class' =>
'mw-ipblocklist-otherblocks' ],
327 return $this->dbProvider->getReplicaDatabase();
334 class_alias( SpecialBlockList::class,
'SpecialBlockList' );
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getAuthority()
Shortcut to get the Authority executing this instance.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.