| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Specials; |
| 22 |
|
| 23 |
use MediaWiki\Block\BlockActionInfo; |
| 24 |
use MediaWiki\Block\BlockRestrictionStore; |
| 25 |
use MediaWiki\Block\BlockUtils; |
| 26 |
use MediaWiki\Block\HideUserUtils; |
| 27 |
use MediaWiki\Cache\LinkBatchFactory; |
| 28 |
use MediaWiki\CommentFormatter\RowCommentFormatter; |
| 29 |
use MediaWiki\CommentStore\CommentStore; |
| 30 |
use MediaWiki\Html\Html; |
| 31 |
use MediaWiki\HTMLForm\HTMLForm; |
| 32 |
use MediaWiki\Pager\BlockListPager; |
| 33 |
use MediaWiki\SpecialPage\SpecialPage; |
| 34 |
use Wikimedia\Rdbms\IConnectionProvider; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
class SpecialAutoblockList extends SpecialPage { |
| 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 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 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 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 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 |
|
| 97 |
$pager = $this->getBlockListPager(); |
| 98 |
|
| 99 |
|
| 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() ) |
| 113 |
->setFormIdentifier( 'blocklist' ) |
| 114 |
->setWrapperLegendMsg( 'autoblocklist-legend' ) |
| 115 |
->setSubmitTextMsg( 'autoblocklist-submit' ) |
| 116 |
->prepareForm() |
| 117 |
->displayForm( false ); |
| 118 |
|
| 119 |
$this->showList( $pager ); |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
protected function getBlockListPager() { |
| 127 |
$conds = [ |
| 128 |
$this->dbProvider->getReplicaDatabase()->expr( 'bl_parent_block_id', '!=', null ), |
| 129 |
]; |
| 130 |
|
| 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 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
protected function showList( BlockListPager $pager ) { |
| 156 |
$out = $this->getOutput(); |
| 157 |
|
| 158 |
|
| 159 |
$otherAutoblockLink = []; |
| 160 |
$this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink ); |
| 161 |
|
| 162 |
|
| 163 |
|
| 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 |
|
| 205 |
|
| 206 |
class_alias( SpecialAutoblockList::class, 'SpecialAutoblockList' ); |