MediaWiki master
SpecialAutoblockList.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Specials;
22
35
43
44 private LinkBatchFactory $linkBatchFactory;
45 private BlockRestrictionStore $blockRestrictionStore;
46 private IConnectionProvider $dbProvider;
47 private CommentStore $commentStore;
48 private BlockUtils $blockUtils;
49 private HideUserUtils $hideUserUtils;
50 private BlockActionInfo $blockActionInfo;
51 private RowCommentFormatter $rowCommentFormatter;
52
63 public function __construct(
64 LinkBatchFactory $linkBatchFactory,
65 BlockRestrictionStore $blockRestrictionStore,
66 IConnectionProvider $dbProvider,
67 CommentStore $commentStore,
68 BlockUtils $blockUtils,
69 HideUserUtils $hideUserUtils,
70 BlockActionInfo $blockActionInfo,
71 RowCommentFormatter $rowCommentFormatter
72 ) {
73 parent::__construct( 'AutoblockList' );
74
75 $this->linkBatchFactory = $linkBatchFactory;
76 $this->blockRestrictionStore = $blockRestrictionStore;
77 $this->dbProvider = $dbProvider;
78 $this->commentStore = $commentStore;
79 $this->blockUtils = $blockUtils;
80 $this->hideUserUtils = $hideUserUtils;
81 $this->blockActionInfo = $blockActionInfo;
82 $this->rowCommentFormatter = $rowCommentFormatter;
83 }
84
88 public function execute( $par ) {
89 $this->setHeaders();
90 $this->outputHeader();
91 $out = $this->getOutput();
92 $out->setPageTitleMsg( $this->msg( 'autoblocklist' ) );
93 $this->addHelpLink( 'Autoblock' );
94 $out->addModuleStyles( [ 'mediawiki.special' ] );
95
96 # setup BlockListPager here to get the actual default Limit
97 $pager = $this->getBlockListPager();
98
99 # Just show the block list
100 $fields = [
101 'Limit' => [
102 'type' => 'limitselect',
103 'label-message' => 'table_pager_limit_label',
104 'options' => $pager->getLimitSelectList(),
105 'name' => 'limit',
106 'default' => $pager->getLimit(),
107 ]
108 ];
109
110 $form = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
111 $form->setMethod( 'get' )
112 ->setTitle( $this->getPageTitle() ) // Remove subpage
113 ->setFormIdentifier( 'blocklist' )
114 ->setWrapperLegendMsg( 'autoblocklist-legend' )
115 ->setSubmitTextMsg( 'autoblocklist-submit' )
116 ->prepareForm()
117 ->displayForm( false );
118
119 $this->showList( $pager );
120 }
121
126 protected function getBlockListPager() {
127 $conds = [
128 $this->dbProvider->getReplicaDatabase()->expr( 'bl_parent_block_id', '!=', null ),
129 ];
130 # Is the user allowed to see hidden blocks?
131 if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
132 $conds['bl_deleted'] = 0;
133 }
134
135 return new BlockListPager(
136 $this->getContext(),
137 $this->blockActionInfo,
138 $this->blockRestrictionStore,
139 $this->blockUtils,
140 $this->hideUserUtils,
141 $this->commentStore,
142 $this->linkBatchFactory,
143 $this->getLinkRenderer(),
144 $this->dbProvider,
145 $this->rowCommentFormatter,
146 $this->getSpecialPageFactory(),
147 $conds
148 );
149 }
150
155 protected function showList( BlockListPager $pager ) {
156 $out = $this->getOutput();
157
158 # Check for other blocks, i.e. global/tor blocks
159 $otherAutoblockLink = [];
160 $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
161
162 # Show additional header for the local block only when other blocks exists.
163 # Not necessary in a standard installation without such extensions enabled
164 if ( count( $otherAutoblockLink ) ) {
165 $out->addHTML(
166 Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
167 $pager->getNumRows() )->parse() )
168 . "\n"
169 );
170 }
171
172 if ( $pager->getNumRows() ) {
173 $out->addParserOutputContent( $pager->getFullOutput() );
174 } else {
175 $out->addWikiMsg( 'autoblocklist-empty' );
176 }
177
178 if ( count( $otherAutoblockLink ) ) {
179 $out->addHTML(
180 Html::rawElement(
181 'h2',
182 [],
183 $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
184 ) . "\n"
185 );
186 $list = '';
187 foreach ( $otherAutoblockLink as $link ) {
188 $list .= Html::rawElement( 'li', [], $link ) . "\n";
189 }
190 $out->addHTML(
191 Html::rawElement(
192 'ul',
193 [ 'class' => 'mw-autoblocklist-otherblocks' ],
194 $list
195 ) . "\n"
196 );
197 }
198 }
199
200 protected function getGroupName() {
201 return 'users';
202 }
203}
204
206class_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:208
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.
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.