78 parent::__construct(
'BlockList' );
80 $this->linkBatchFactory = $linkBatchFactory;
81 $this->blockStore = $blockStore;
82 $this->blockRestrictionStore = $blockRestrictionStore;
83 $this->dbProvider = $dbProvider;
84 $this->commentStore = $commentStore;
85 $this->blockUtils = $blockUtils;
86 $this->hideUserUtils = $hideUserUtils;
87 $this->blockActionInfo = $blockActionInfo;
88 $this->rowCommentFormatter = $rowCommentFormatter;
99 $out->setPageTitleMsg( $this->
msg(
'ipblocklist' ) );
100 $out->addModuleStyles( [
'mediawiki.special' ] );
103 $par = $request->getVal(
'ip', $par ??
'' );
104 $this->target = trim( $request->getVal(
'wpTarget', $par ) );
106 $this->options = $request->getArray(
'wpOptions', [] );
107 $this->blockType = $request->getVal(
'blockType' );
109 $action = $request->getText(
'action' );
111 if ( $action ==
'unblock' || ( $action ==
'submit' && $request->wasPosted() ) ) {
114 $out->redirect( $title->getFullURL() );
126 'label-message' =>
'ipaddressorusername',
132 'type' =>
'multiselect',
133 'options-messages' => [
134 'blocklist-tempblocks' =>
'tempblocks',
135 'blocklist-indefblocks' =>
'indefblocks',
136 'blocklist-autoblocks' =>
'autoblocks',
137 'blocklist-userblocks' =>
'userblocks',
138 'blocklist-addressblocks' =>
'addressblocks',
139 'blocklist-rangeblocks' =>
'rangeblocks',
145 $fields[
'BlockType'] = [
147 'label-message' =>
'blocklist-type',
149 $this->
msg(
'blocklist-type-opt-all' )->escaped() =>
'',
150 $this->
msg(
'blocklist-type-opt-sitewide' )->escaped() =>
'sitewide',
151 $this->
msg(
'blocklist-type-opt-partial' )->escaped() =>
'partial',
153 'name' =>
'blockType',
154 'cssclass' =>
'mw-field-block-type',
158 'type' =>
'limitselect',
159 'label-message' =>
'table_pager_limit_label',
160 'options' => $pager->getLimitSelectList(),
162 'default' => $pager->getLimit(),
163 'cssclass' =>
'mw-field-limit mw-has-field-block-type',
166 $form = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
170 ->setFormIdentifier(
'blocklist' )
171 ->setWrapperLegendMsg(
'ipblocklist-legend' )
172 ->setSubmitTextMsg(
'ipblocklist-submit' )
174 ->displayForm(
false );
185 $db = $this->
getDB();
187 if ( $this->target !==
'' ) {
188 [
$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 [ $start, $end ] = IPUtils::parseRange(
$target );
199 $conds[] = $this->blockStore->getRangeCond( $start, $end );
200 $conds[
'bt_auto'] = 0;
203 case DatabaseBlock::TYPE_USER:
205 $conds[
'bt_user'] =
$target->getId();
206 $conds[
'bt_auto'] = 0;
216 if ( in_array(
'userblocks', $this->options ) ) {
217 $conds[
'bt_user'] =
null;
219 if ( in_array(
'autoblocks', $this->options ) ) {
220 $conds[
'bl_parent_block_id'] =
null;
222 if ( in_array(
'addressblocks', $this->options )
223 && in_array(
'rangeblocks', $this->options )
226 $conds[] = $db->expr(
'bt_user',
'!=',
null );
227 } elseif ( in_array(
'addressblocks', $this->options ) ) {
228 $conds[] = $db->expr(
'bt_user',
'!=',
null )->or(
'bt_range_start',
'!=',
null );
229 } elseif ( in_array(
'rangeblocks', $this->options ) ) {
230 $conds[
'bt_range_start'] =
null;
233 $hideTemp = in_array(
'tempblocks', $this->options );
234 $hideIndef = in_array(
'indefblocks', $this->options );
235 if ( $hideTemp && $hideIndef ) {
238 } elseif ( $hideTemp ) {
239 $conds[
'bl_expiry'] = $db->getInfinity();
240 } elseif ( $hideIndef ) {
241 $conds[] = $db->expr(
'bl_expiry',
'!=', $db->getInfinity() );
244 if ( $this->blockType ===
'sitewide' ) {
245 $conds[
'bl_sitewide'] = 1;
246 } elseif ( $this->blockType ===
'partial' ) {
247 $conds[
'bl_sitewide'] = 0;
252 $this->blockActionInfo,
253 $this->blockRestrictionStore,
255 $this->hideUserUtils,
257 $this->linkBatchFactory,
260 $this->rowCommentFormatter,
274 $otherBlockLink = [];
275 $this->
getHookRunner()->onOtherBlockLogLink( $otherBlockLink, $this->target );
279 if ( count( $otherBlockLink ) ) {
281 Html::element(
'h2', [], $this->
msg(
'ipblocklist-localblock' )->text() ) .
"\n"
287 } elseif ( $this->target ) {
288 $out->addWikiMsg(
'ipblocklist-no-results' );
290 $out->addWikiMsg(
'ipblocklist-empty' );
293 if ( count( $otherBlockLink ) ) {
298 $this->
msg(
'ipblocklist-otherblocks', count( $otherBlockLink ) )->parse()
302 foreach ( $otherBlockLink as $link ) {
303 $list .= Html::rawElement(
'li', [], $link ) .
"\n";
305 $out->addHTML( Html::rawElement(
307 [
'class' =>
'mw-ipblocklist-otherblocks' ],
323 return $this->dbProvider->getReplicaDatabase();
328class_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.