MediaWiki master
SpecialAutoblockList.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\Specials;
25
38
46
47 private LinkBatchFactory $linkBatchFactory;
48 private BlockRestrictionStore $blockRestrictionStore;
49 private IConnectionProvider $dbProvider;
50 private CommentStore $commentStore;
51 private BlockUtils $blockUtils;
52 private HideUserUtils $hideUserUtils;
53 private BlockActionInfo $blockActionInfo;
54 private RowCommentFormatter $rowCommentFormatter;
55
66 public function __construct(
67 LinkBatchFactory $linkBatchFactory,
68 BlockRestrictionStore $blockRestrictionStore,
69 IConnectionProvider $dbProvider,
70 CommentStore $commentStore,
71 BlockUtils $blockUtils,
72 HideUserUtils $hideUserUtils,
73 BlockActionInfo $blockActionInfo,
74 RowCommentFormatter $rowCommentFormatter
75 ) {
76 parent::__construct( 'AutoblockList' );
77
78 $this->linkBatchFactory = $linkBatchFactory;
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;
86 }
87
91 public function execute( $par ) {
92 $this->setHeaders();
93 $this->outputHeader();
94 $out = $this->getOutput();
95 $out->setPageTitleMsg( $this->msg( 'autoblocklist' ) );
96 $this->addHelpLink( 'Autoblock' );
97 $out->addModuleStyles( [ 'mediawiki.special' ] );
98
99 # setup BlockListPager here to get the actual default Limit
100 $pager = $this->getBlockListPager();
101
102 # Just show the block list
103 $fields = [
104 'Limit' => [
105 'type' => 'limitselect',
106 'label-message' => 'table_pager_limit_label',
107 'options' => $pager->getLimitSelectList(),
108 'name' => 'limit',
109 'default' => $pager->getLimit(),
110 ]
111 ];
112
113 $form = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
114 $form->setMethod( 'get' )
115 ->setTitle( $this->getPageTitle() ) // Remove subpage
116 ->setFormIdentifier( 'blocklist' )
117 ->setWrapperLegendMsg( 'autoblocklist-legend' )
118 ->setSubmitTextMsg( 'autoblocklist-submit' )
119 ->prepareForm()
120 ->displayForm( false );
121
122 $this->showList( $pager );
123 }
124
129 protected function getBlockListPager() {
130 $conds = [
131 'bl_parent_block_id IS NOT NULL',
132 ];
133 # Is the user allowed to see hidden blocks?
134 if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
135 $conds['bl_deleted'] = 0;
136 }
137
138 return new BlockListPager(
139 $this->getContext(),
140 $this->blockActionInfo,
141 $this->blockRestrictionStore,
142 $this->blockUtils,
143 $this->hideUserUtils,
144 $this->commentStore,
145 $this->linkBatchFactory,
146 $this->getLinkRenderer(),
147 $this->dbProvider,
148 $this->rowCommentFormatter,
149 $this->getSpecialPageFactory(),
150 $conds
151 );
152 }
153
158 protected function showList( BlockListPager $pager ) {
159 $out = $this->getOutput();
160
161 # Check for other blocks, i.e. global/tor blocks
162 $otherAutoblockLink = [];
163 $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
164
165 # Show additional header for the local block only when other blocks exists.
166 # Not necessary in a standard installation without such extensions enabled
167 if ( count( $otherAutoblockLink ) ) {
168 $out->addHTML(
169 Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
170 $pager->getNumRows() )->parse() )
171 . "\n"
172 );
173 }
174
175 if ( $pager->getNumRows() ) {
176 $out->addParserOutputContent( $pager->getFullOutput() );
177 } else {
178 $out->addWikiMsg( 'autoblocklist-empty' );
179 }
180
181 if ( count( $otherAutoblockLink ) ) {
182 $out->addHTML(
183 Html::rawElement(
184 'h2',
185 [],
186 $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
187 ) . "\n"
188 );
189 $list = '';
190 foreach ( $otherAutoblockLink as $link ) {
191 $list .= Html::rawElement( 'li', [], $link ) . "\n";
192 }
193 $out->addHTML(
194 Html::rawElement(
195 'ul',
196 [ 'class' => 'mw-autoblocklist-otherblocks' ],
197 $list
198 ) . "\n"
199 );
200 }
201 }
202
203 protected function getGroupName() {
204 return 'users';
205 }
206}
207
209class_alias( SpecialAutoblockList::class, 'SpecialAutoblockList' );
Defines the actions that can be blocked by a partial block.
Backend class for blocking utils.
Helpers for building queries that determine whether a user is hidden.
This is basically a CommentFormatter with a CommentStore dependency, allowing it to retrieve comment ...
Handle database storage of comments such as edit summaries and log reasons.
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:206
This class is a collection of static functions that serve two purposes:
Definition Html.php:56
getNumRows()
Get the number of rows in the result set.
getFullOutput()
Get the formatted result list, with navigation bars.
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.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getAuthority()
Shortcut to get the Authority executing 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.
A special page that lists autoblocks.
getBlockListPager()
Setup a new BlockListPager instance.
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
__construct(LinkBatchFactory $linkBatchFactory, BlockRestrictionStore $blockRestrictionStore, IConnectionProvider $dbProvider, CommentStore $commentStore, BlockUtils $blockUtils, HideUserUtils $hideUserUtils, BlockActionInfo $blockActionInfo, RowCommentFormatter $rowCommentFormatter)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Provide primary and replica IDatabase connections.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...