47 private $linkBatchFactory;
50 private $blockRestrictionStore;
53 private $loadBalancer;
56 private $commentStore;
62 private $blockActionInfo;
65 private $rowCommentFormatter;
76 parent::__construct(
'BlockList' );
78 $this->linkBatchFactory = $linkBatchFactory;
79 $this->blockRestrictionStore = $blockRestrictionStore;
80 $this->loadBalancer = $loadBalancer;
81 $this->commentStore = $commentStore;
82 $this->blockUtils = $blockUtils;
83 $this->blockActionInfo = $blockActionInfo;
84 $this->rowCommentFormatter = $rowCommentFormatter;
95 $out->setPageTitle( $this->
msg(
'ipblocklist' ) );
96 $out->addModuleStyles( [
'mediawiki.special' ] );
99 $par = $request->getVal(
'ip', $par ??
'' );
100 $this->target = trim( $request->getVal(
'wpTarget', $par ) );
102 $this->options = $request->getArray(
'wpOptions', [] );
103 $this->blockType = $request->getVal(
'blockType' );
105 $action = $request->getText(
'action' );
107 if ( $action ==
'unblock' || $action ==
'submit' && $request->wasPosted() ) {
108 # B/C @since 1.18: Unblock interface is now at Special:Unblock
110 $out->redirect(
$title->getFullURL() );
115 # setup BlockListPager here to get the actual default Limit
118 # Just show the block list
122 'label-message' =>
'ipaddressorusername',
128 'type' =>
'multiselect',
129 'options-messages' => [
130 'blocklist-tempblocks' =>
'tempblocks',
131 'blocklist-indefblocks' =>
'indefblocks',
132 'blocklist-autoblocks' =>
'autoblocks',
133 'blocklist-userblocks' =>
'userblocks',
134 'blocklist-addressblocks' =>
'addressblocks',
135 'blocklist-rangeblocks' =>
'rangeblocks',
141 $fields[
'BlockType'] = [
143 'label-message' =>
'blocklist-type',
145 $this->
msg(
'blocklist-type-opt-all' )->escaped() =>
'',
146 $this->
msg(
'blocklist-type-opt-sitewide' )->escaped() =>
'sitewide',
147 $this->
msg(
'blocklist-type-opt-partial' )->escaped() =>
'partial',
149 'name' =>
'blockType',
150 'cssclass' =>
'mw-field-block-type',
154 'type' =>
'limitselect',
155 'label-message' =>
'table_pager_limit_label',
156 'options' => $pager->getLimitSelectList(),
158 'default' => $pager->getLimit(),
159 'cssclass' =>
'mw-field-limit mw-has-field-block-type',
162 $form = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
166 ->setFormIdentifier(
'blocklist' )
167 ->setWrapperLegendMsg(
'ipblocklist-legend' )
168 ->setSubmitTextMsg(
'ipblocklist-submit' )
170 ->displayForm(
false );
181 $db = $this->
getDB();
182 # Is the user allowed to see hidden blocks?
183 if ( !$this->
getAuthority()->isAllowed(
'hideuser' ) ) {
184 $conds[
'ipb_deleted'] = 0;
187 if ( $this->target !==
'' ) {
188 list(
$target,
$type ) = $this->blockUtils->parseBlockTarget( $this->target );
191 case DatabaseBlock::TYPE_ID:
192 case DatabaseBlock::TYPE_AUTO:
196 case DatabaseBlock::TYPE_IP:
197 case DatabaseBlock::TYPE_RANGE:
198 list( $start, $end ) = IPUtils::parseRange(
$target );
199 $conds[] = $db->makeList(
202 DatabaseBlock::getRangeCond( $start, $end )
206 $conds[
'ipb_auto'] = 0;
209 case DatabaseBlock::TYPE_USER:
210 $conds[
'ipb_address'] =
$target->getName();
211 $conds[
'ipb_auto'] = 0;
217 if ( in_array(
'userblocks', $this->options ) ) {
218 $conds[
'ipb_user'] = 0;
220 if ( in_array(
'autoblocks', $this->options ) ) {
222 $conds[] =
"ipb_parent_block_id IS NULL OR ipb_parent_block_id = 0";
224 if ( in_array(
'addressblocks', $this->options ) ) {
225 $conds[] =
"ipb_user != 0 OR ipb_range_end > ipb_range_start";
227 if ( in_array(
'rangeblocks', $this->options ) ) {
228 $conds[] =
"ipb_range_end = ipb_range_start";
231 $hideTemp = in_array(
'tempblocks', $this->options );
232 $hideIndef = in_array(
'indefblocks', $this->options );
233 if ( $hideTemp && $hideIndef ) {
236 } elseif ( $hideTemp ) {
237 $conds[
'ipb_expiry'] = $db->getInfinity();
238 } elseif ( $hideIndef ) {
239 $conds[] =
"ipb_expiry != " . $db->addQuotes( $db->getInfinity() );
242 if ( $this->blockType ===
'sitewide' ) {
243 $conds[
'ipb_sitewide'] = 1;
244 } elseif ( $this->blockType ===
'partial' ) {
245 $conds[
'ipb_sitewide'] = 0;
250 $this->blockActionInfo,
251 $this->blockRestrictionStore,
254 $this->linkBatchFactory,
257 $this->rowCommentFormatter,
270 # Check for other blocks, i.e. global/tor blocks
271 $otherBlockLink = [];
272 $this->
getHookRunner()->onOtherBlockLogLink( $otherBlockLink, $this->target );
274 # Show additional header for the local block only when other blocks exists.
275 # Not necessary in a standard installation without such extensions enabled
276 if ( count( $otherBlockLink ) ) {
278 Html::element(
'h2', [], $this->
msg(
'ipblocklist-localblock' )->text() ) .
"\n"
284 } elseif ( $this->target ) {
285 $out->addWikiMsg(
'ipblocklist-no-results' );
287 $out->addWikiMsg(
'ipblocklist-empty' );
290 if ( count( $otherBlockLink ) ) {
295 $this->
msg(
'ipblocklist-otherblocks', count( $otherBlockLink ) )->parse()
299 foreach ( $otherBlockLink as $link ) {
300 $list .= Html::rawElement(
'li', [], $link ) .
"\n";
302 $out->addHTML( Html::rawElement(
304 [
'class' =>
'mw-ipblocklist-otherblocks' ],
320 return $this->loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA );
A special page that lists existing blocks.
getDB()
Return a IDatabase object for reading.
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
__construct(LinkBatchFactory $linkBatchFactory, BlockRestrictionStore $blockRestrictionStore, ILoadBalancer $loadBalancer, CommentStore $commentStore, BlockUtils $blockUtils, BlockActionInfo $blockActionInfo, RowCommentFormatter $rowCommentFormatter)
getBlockListPager()
Setup a new BlockListPager instance.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
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.