75 parent::__construct(
'BlockList' );
77 $this->linkBatchFactory = $linkBatchFactory;
78 $this->blockStore = $blockStore;
79 $this->blockRestrictionStore = $blockRestrictionStore;
80 $this->dbProvider = $dbProvider;
81 $this->commentStore = $commentStore;
82 $this->blockUtils = $blockUtils;
83 $this->hideUserUtils = $hideUserUtils;
84 $this->blockActionInfo = $blockActionInfo;
85 $this->rowCommentFormatter = $rowCommentFormatter;
96 $out->setPageTitleMsg( $this->
msg(
'ipblocklist' ) );
97 $out->addModuleStyles( [
'mediawiki.special' ] );
100 $par = $request->getVal(
'ip', $par ??
'' );
101 $this->target = trim( $request->getVal(
'wpTarget', $par ) );
103 $this->options = $request->getArray(
'wpOptions', [] );
104 $this->blockType = $request->getVal(
'blockType' );
106 $action = $request->getText(
'action' );
108 if ( $action ==
'unblock' || ( $action ==
'submit' && $request->wasPosted() ) ) {
111 $out->redirect( $title->getFullURL() );
123 'label-message' =>
'ipaddressorusername',
129 'type' =>
'multiselect',
130 'options-messages' => [
131 'blocklist-tempblocks' =>
'tempblocks',
132 'blocklist-indefblocks' =>
'indefblocks',
133 'blocklist-autoblocks' =>
'autoblocks',
134 'blocklist-userblocks' =>
'userblocks',
135 'blocklist-addressblocks' =>
'addressblocks',
136 'blocklist-rangeblocks' =>
'rangeblocks',
142 $fields[
'BlockType'] = [
144 'label-message' =>
'blocklist-type',
146 $this->
msg(
'blocklist-type-opt-all' )->escaped() =>
'',
147 $this->
msg(
'blocklist-type-opt-sitewide' )->escaped() =>
'sitewide',
148 $this->
msg(
'blocklist-type-opt-partial' )->escaped() =>
'partial',
150 'name' =>
'blockType',
151 'cssclass' =>
'mw-field-block-type',
155 'type' =>
'limitselect',
156 'label-message' =>
'table_pager_limit_label',
157 'options' => $pager->getLimitSelectList(),
159 'default' => $pager->getLimit(),
160 'cssclass' =>
'mw-field-limit mw-has-field-block-type',
163 $form = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
167 ->setFormIdentifier(
'blocklist' )
168 ->setWrapperLegendMsg(
'ipblocklist-legend' )
169 ->setSubmitTextMsg(
'ipblocklist-submit' )
171 ->displayForm(
false );
182 $db = $this->
getDB();
184 if ( $this->target !==
'' ) {
185 [
$target, $type ] = $this->blockUtils->parseBlockTarget( $this->target );
188 case DatabaseBlock::TYPE_ID:
189 case DatabaseBlock::TYPE_AUTO:
193 case DatabaseBlock::TYPE_IP:
194 case DatabaseBlock::TYPE_RANGE:
195 [ $start, $end ] = IPUtils::parseRange(
$target );
196 $conds[] = $this->blockStore->getRangeCond( $start, $end );
197 $conds[
'bt_auto'] = 0;
200 case DatabaseBlock::TYPE_USER:
202 $conds[
'bt_user'] =
$target->getId();
203 $conds[
'bt_auto'] = 0;
213 if ( in_array(
'userblocks', $this->options ) ) {
214 $conds[
'bt_user'] =
null;
216 if ( in_array(
'autoblocks', $this->options ) ) {
217 $conds[
'bl_parent_block_id'] =
null;
219 if ( in_array(
'addressblocks', $this->options )
220 && in_array(
'rangeblocks', $this->options )
223 $conds[] = $db->expr(
'bt_user',
'!=',
null );
224 } elseif ( in_array(
'addressblocks', $this->options ) ) {
225 $conds[] = $db->expr(
'bt_user',
'!=',
null )->or(
'bt_range_start',
'!=',
null );
226 } elseif ( in_array(
'rangeblocks', $this->options ) ) {
227 $conds[
'bt_range_start'] =
null;
230 $hideTemp = in_array(
'tempblocks', $this->options );
231 $hideIndef = in_array(
'indefblocks', $this->options );
232 if ( $hideTemp && $hideIndef ) {
235 } elseif ( $hideTemp ) {
236 $conds[
'bl_expiry'] = $db->getInfinity();
237 } elseif ( $hideIndef ) {
238 $conds[] = $db->expr(
'bl_expiry',
'!=', $db->getInfinity() );
241 if ( $this->blockType ===
'sitewide' ) {
242 $conds[
'bl_sitewide'] = 1;
243 } elseif ( $this->blockType ===
'partial' ) {
244 $conds[
'bl_sitewide'] = 0;
249 $this->blockActionInfo,
250 $this->blockRestrictionStore,
252 $this->hideUserUtils,
254 $this->linkBatchFactory,
257 $this->rowCommentFormatter,
271 $otherBlockLink = [];
272 $this->
getHookRunner()->onOtherBlockLogLink( $otherBlockLink, $this->target );
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->dbProvider->getReplicaDatabase();
325class_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.