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 );
187 $bl_deleted =
'ipb_deleted';
189 $bt_auto =
'ipb_auto';
190 $bt_user =
'ipb_user';
191 $bl_expiry =
'ipb_expiry';
192 $bl_sitewide =
'ipb_sitewide';
194 $bl_deleted =
'bl_deleted';
196 $bt_auto =
'bt_auto';
197 $bt_user =
'bt_user';
198 $bl_expiry =
'bl_expiry';
199 $bl_sitewide =
'bl_sitewide';
202 '$wgBlockTargetMigrationStage has an invalid read stage' );
206 $db = $this->
getDB();
208 if ( $this->target !==
'' ) {
209 [
$target, $type ] = $this->blockUtils->parseBlockTarget( $this->target );
212 case DatabaseBlock::TYPE_ID:
213 case DatabaseBlock::TYPE_AUTO:
217 case DatabaseBlock::TYPE_IP:
218 case DatabaseBlock::TYPE_RANGE:
219 [ $start, $end ] = IPUtils::parseRange(
$target );
220 $conds[] = $this->blockStore->getRangeCond( $start, $end,
221 DatabaseBlockStore::SCHEMA_CURRENT );
222 $conds[$bt_auto] = 0;
225 case DatabaseBlock::TYPE_USER:
227 $conds[$bt_user] =
$target->getId();
228 $conds[$bt_auto] = 0;
238 if ( in_array(
'userblocks', $this->options ) ) {
240 $conds[
'ipb_user'] = 0;
242 $conds[
'bt_user'] =
null;
245 if ( in_array(
'autoblocks', $this->options ) ) {
248 $conds[
'ipb_parent_block_id'] = [
null, 0 ];
250 $conds[
'bl_parent_block_id'] =
null;
253 if ( in_array(
'addressblocks', $this->options )
254 && in_array(
'rangeblocks', $this->options )
258 $conds[] =
"ipb_user != 0";
260 $conds[] =
"bt_user IS NOT NULL";
262 } elseif ( in_array(
'addressblocks', $this->options ) ) {
264 $conds[] =
"ipb_user != 0 OR ipb_range_end > ipb_range_start";
266 $conds[] =
"bt_user IS NOT NULL OR bt_range_start IS NOT NULL";
268 } elseif ( in_array(
'rangeblocks', $this->options ) ) {
270 $conds[] =
"ipb_range_end = ipb_range_start";
272 $conds[
'bt_range_start'] =
null;
276 $hideTemp = in_array(
'tempblocks', $this->options );
277 $hideIndef = in_array(
'indefblocks', $this->options );
278 if ( $hideTemp && $hideIndef ) {
281 } elseif ( $hideTemp ) {
282 $conds[$bl_expiry] = $db->getInfinity();
283 } elseif ( $hideIndef ) {
284 $conds[] = $db->expr( $bl_expiry,
'!=', $db->getInfinity() );
287 if ( $this->blockType ===
'sitewide' ) {
288 $conds[$bl_sitewide] = 1;
289 } elseif ( $this->blockType ===
'partial' ) {
290 $conds[$bl_sitewide] = 0;
295 $this->blockActionInfo,
296 $this->blockRestrictionStore,
298 $this->hideUserUtils,
300 $this->linkBatchFactory,
303 $this->rowCommentFormatter,
317 $otherBlockLink = [];
318 $this->
getHookRunner()->onOtherBlockLogLink( $otherBlockLink, $this->target );
322 if ( count( $otherBlockLink ) ) {
324 Html::element(
'h2', [], $this->
msg(
'ipblocklist-localblock' )->text() ) .
"\n"
330 } elseif ( $this->target ) {
331 $out->addWikiMsg(
'ipblocklist-no-results' );
333 $out->addWikiMsg(
'ipblocklist-empty' );
336 if ( count( $otherBlockLink ) ) {
341 $this->
msg(
'ipblocklist-otherblocks', count( $otherBlockLink ) )->parse()
345 foreach ( $otherBlockLink as $link ) {
346 $list .= Html::rawElement(
'li', [], $link ) .
"\n";
348 $out->addHTML( Html::rawElement(
350 [
'class' =>
'mw-ipblocklist-otherblocks' ],
366 return $this->dbProvider->getReplicaDatabase();
371class_alias( SpecialBlockList::class,
'SpecialBlockList' );
const SCHEMA_COMPAT_READ_NEW
const SCHEMA_COMPAT_READ_OLD
const SCHEMA_COMPAT_READ_MASK
A class containing constants representing the names of configuration variables.
const BlockTargetMigrationStage
Name constant for the BlockTargetMigrationStage setting, for use with Config::get()
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.
getConfig()
Shortcut to get main config 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 Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.