76 parent::__construct(
'BlockList' );
78 $this->linkBatchFactory = $linkBatchFactory;
79 $this->blockStore = $blockStore;
80 $this->blockRestrictionStore = $blockRestrictionStore;
81 $this->dbProvider = $dbProvider;
82 $this->commentStore = $commentStore;
83 $this->blockUtils = $blockUtils;
84 $this->hideUserUtils = $hideUserUtils;
85 $this->blockActionInfo = $blockActionInfo;
86 $this->rowCommentFormatter = $rowCommentFormatter;
97 $out->setPageTitleMsg( $this->
msg(
'ipblocklist' ) );
98 $out->addModuleStyles( [
'mediawiki.special' ] );
101 $par = $request->getVal(
'ip', $par ??
'' );
102 $this->target = trim( $request->getVal(
'wpTarget', $par ) );
104 $this->options = $request->getArray(
'wpOptions', [] );
105 $this->blockType = $request->getVal(
'blockType' );
107 $action = $request->getText(
'action' );
109 if ( $action ==
'unblock' || ( $action ==
'submit' && $request->wasPosted() ) ) {
112 $out->redirect( $title->getFullURL() );
124 'label-message' =>
'ipaddressorusername',
130 'type' =>
'multiselect',
131 'options-messages' => [
132 'blocklist-tempblocks' =>
'tempblocks',
133 'blocklist-indefblocks' =>
'indefblocks',
134 'blocklist-autoblocks' =>
'autoblocks',
135 'blocklist-userblocks' =>
'userblocks',
136 'blocklist-addressblocks' =>
'addressblocks',
137 'blocklist-rangeblocks' =>
'rangeblocks',
143 $fields[
'BlockType'] = [
145 'label-message' =>
'blocklist-type',
147 $this->
msg(
'blocklist-type-opt-all' )->escaped() =>
'',
148 $this->
msg(
'blocklist-type-opt-sitewide' )->escaped() =>
'sitewide',
149 $this->
msg(
'blocklist-type-opt-partial' )->escaped() =>
'partial',
151 'name' =>
'blockType',
152 'cssclass' =>
'mw-field-block-type',
156 'type' =>
'limitselect',
157 'label-message' =>
'table_pager_limit_label',
158 'options' => $pager->getLimitSelectList(),
160 'default' => $pager->getLimit(),
161 'cssclass' =>
'mw-field-limit mw-has-field-block-type',
164 $form = HTMLForm::factory(
'ooui', $fields, $this->
getContext() );
168 ->setFormIdentifier(
'blocklist' )
169 ->setWrapperLegendMsg(
'ipblocklist-legend' )
170 ->setSubmitTextMsg(
'ipblocklist-submit' )
172 ->displayForm(
false );
183 $db = $this->
getDB();
185 if ( $this->target !==
'' ) {
186 [
$target, $type ] = $this->blockUtils->parseBlockTarget( $this->target );
189 case DatabaseBlock::TYPE_ID:
190 case DatabaseBlock::TYPE_AUTO:
194 case DatabaseBlock::TYPE_IP:
195 case DatabaseBlock::TYPE_RANGE:
196 [ $start, $end ] = IPUtils::parseRange(
$target );
197 $conds[] = $this->blockStore->getRangeCond( $start, $end );
198 $conds[
'bt_auto'] = 0;
201 case DatabaseBlock::TYPE_USER:
203 $conds[
'bt_user'] =
$target->getId();
204 $conds[
'bt_auto'] = 0;
214 if ( in_array(
'userblocks', $this->options ) ) {
215 $conds[
'bt_user'] =
null;
217 if ( in_array(
'autoblocks', $this->options ) ) {
218 $conds[
'bl_parent_block_id'] =
null;
220 if ( in_array(
'addressblocks', $this->options )
221 && in_array(
'rangeblocks', $this->options )
224 $conds[] =
"bt_user IS NOT NULL";
225 } elseif ( in_array(
'addressblocks', $this->options ) ) {
226 $conds[] =
"bt_user IS NOT NULL OR bt_range_start IS NOT NULL";
227 } elseif ( in_array(
'rangeblocks', $this->options ) ) {
228 $conds[
'bt_range_start'] =
null;
231 $hideTemp = in_array(
'tempblocks', $this->options );
232 $hideIndef = in_array(
'indefblocks', $this->options );
233 if ( $hideTemp && $hideIndef ) {
236 } elseif ( $hideTemp ) {
237 $conds[
'bl_expiry'] = $db->getInfinity();
238 } elseif ( $hideIndef ) {
239 $conds[] = $db->expr(
'bl_expiry',
'!=', $db->getInfinity() );
242 if ( $this->blockType ===
'sitewide' ) {
243 $conds[
'bl_sitewide'] = 1;
244 } elseif ( $this->blockType ===
'partial' ) {
245 $conds[
'bl_sitewide'] = 0;
250 $this->blockActionInfo,
251 $this->blockRestrictionStore,
253 $this->hideUserUtils,
255 $this->linkBatchFactory,
258 $this->rowCommentFormatter,
272 $otherBlockLink = [];
273 $this->
getHookRunner()->onOtherBlockLogLink( $otherBlockLink, $this->target );
277 if ( count( $otherBlockLink ) ) {
279 Html::element(
'h2', [], $this->
msg(
'ipblocklist-localblock' )->text() ) .
"\n"
285 } elseif ( $this->target ) {
286 $out->addWikiMsg(
'ipblocklist-no-results' );
288 $out->addWikiMsg(
'ipblocklist-empty' );
291 if ( count( $otherBlockLink ) ) {
296 $this->
msg(
'ipblocklist-otherblocks', count( $otherBlockLink ) )->parse()
300 foreach ( $otherBlockLink as $link ) {
301 $list .= Html::rawElement(
'li', [], $link ) .
"\n";
303 $out->addHTML( Html::rawElement(
305 [
'class' =>
'mw-ipblocklist-otherblocks' ],
321 return $this->dbProvider->getReplicaDatabase();
326class_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.