30 use Wikimedia\IPUtils;
84 parent::__construct( $page->getContext(), $page->getLinkRenderer() );
95 static $headers =
null;
97 if ( $headers ===
null ) {
99 'ipb_timestamp' =>
'blocklist-timestamp',
100 'ipb_target' =>
'blocklist-target',
101 'ipb_expiry' =>
'blocklist-expiry',
102 'ipb_by' =>
'blocklist-by',
103 'ipb_params' =>
'blocklist-params',
104 'ipb_reason' =>
'blocklist-reason',
106 foreach ( $headers as $key => $val ) {
107 $headers[$key] = $this->
msg( $val )->text();
122 if ( $msg ===
null ) {
125 'createaccountblock',
128 'blocklist-nousertalk',
132 'blocklist-editing-sitewide',
135 foreach (
$keys as $key ) {
136 $msg[$key] = $this->
msg( $key )->text();
139 '@phan-var string[] $msg';
151 case 'ipb_timestamp':
152 $formatted = htmlspecialchars( $language->userTimeAndDate( $value, $this->getUser() ) );
156 if ( $row->ipb_auto ) {
157 $formatted = $this->
msg(
'autoblockid', $row->ipb_id )->parse();
159 list( $target,
$type ) = DatabaseBlock::parseTarget( $row->ipb_address );
161 if ( is_string( $target ) ) {
162 if ( IPUtils::isValidRange( $target ) ) {
165 $formatted = $target;
182 $formatted = htmlspecialchars( $language->formatExpiry(
188 if ( $row->ipb_auto ) {
190 $this->specialPageFactory->getTitleForAlias(
'Unblock' ),
193 [
'wpTarget' =>
"#{$row->ipb_id}" ]
197 $this->specialPageFactory->getTitleForAlias(
'Unblock/' . $row->ipb_address ),
201 $this->specialPageFactory->getTitleForAlias(
'Block/' . $row->ipb_address ),
202 $msg[
'change-blocklink']
207 [
'class' =>
'mw-blocklist-actions' ],
208 $this->
msg(
'parentheses' )->rawParams(
209 $language->pipeList( $links ) )->escaped()
212 if ( $value !==
'infinity' ) {
214 $formatted .=
'<br />' . $this->
msg(
215 'ipb-blocklist-duration-left',
216 $language->formatDuration(
217 $timestamp->getTimestamp() - MWTimestamp::time(),
231 if ( isset( $row->by_user_name ) ) {
235 $formatted = htmlspecialchars( $row->ipb_by_text );
240 $value = $this->commentStore->getComment(
'ipb_reason', $row )->text;
247 if ( $row->ipb_sitewide ) {
248 $properties[] = htmlspecialchars( $msg[
'blocklist-editing-sitewide'] );
251 if ( !$row->ipb_sitewide && $this->restrictions ) {
254 $properties[] = htmlspecialchars( $msg[
'blocklist-editing'] ) . $list;
258 if ( $row->ipb_anon_only ) {
259 $properties[] = htmlspecialchars( $msg[
'anononlyblock'] );
261 if ( $row->ipb_create_account ) {
262 $properties[] = htmlspecialchars( $msg[
'createaccountblock'] );
264 if ( $row->ipb_user && !$row->ipb_enable_autoblock ) {
265 $properties[] = htmlspecialchars( $msg[
'noautoblockblock'] );
268 if ( $row->ipb_block_email ) {
269 $properties[] = htmlspecialchars( $msg[
'emailblock'] );
272 if ( !$row->ipb_allow_usertalk ) {
273 $properties[] = htmlspecialchars( $msg[
'blocklist-nousertalk'] );
279 implode(
'', array_map(
static function ( $prop ) {
290 $formatted =
"Unable to format $name";
308 foreach ( $this->restrictions as $restriction ) {
309 if ( $restriction->getBlockId() !== (
int)$row->ipb_id ) {
313 switch ( $restriction->getType() ) {
314 case PageRestriction::TYPE:
315 '@phan-var PageRestriction $restriction';
316 if ( $restriction->getTitle() ) {
324 case NamespaceRestriction::TYPE:
325 $text = $restriction->getValue() ===
NS_MAIN
326 ? $this->
msg(
'blanknamespace' )->text()
328 $restriction->getValue()
334 $this->specialPageFactory->getTitleForAlias(
'Allpages' ),
338 'namespace' => $restriction->getValue()
346 if ( empty( $items ) ) {
351 foreach ( $items as $key => $value ) {
358 implode(
'', $value )
371 $commentQuery = $this->commentStore->getJoin(
'ipb_reason' );
372 $actorQuery = $this->actorMigration->getJoin(
'ipb_by' );
375 'tables' => array_merge(
376 [
'ipblocks' ], $commentQuery[
'tables'], $actorQuery[
'tables'], [
'user' ]
382 'by_user_name' =>
'user_name',
386 'ipb_create_account',
387 'ipb_enable_autoblock',
393 'ipb_allow_usertalk',
395 ] + $commentQuery[
'fields'] + $actorQuery[
'fields'],
398 'user' => [
'LEFT JOIN',
'user_id = ' . $actorQuery[
'fields'][
'ipb_by'] ]
399 ] + $commentQuery[
'joins'] + $actorQuery[
'joins']
402 # Filter out any expired blocks
404 $info[
'conds'][] =
'ipb_expiry > ' . $db->addQuotes( $db->timestamp() );
406 # Is the user allowed to see hidden blocks?
407 if ( !$this->
getAuthority()->isAllowed(
'hideuser' ) ) {
408 $info[
'conds'][
'ipb_deleted'] = 0;
421 $res =
$dbr->selectField(
'ipblocks',
425 'ipb_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() ),
436 return parent::getTableClass() .
' mw-blocklist';
440 return [ [
'ipb_timestamp',
'ipb_id' ] ];
456 # Do a link batch query
457 $lb = $this->linkBatchFactory->newLinkBatch();
458 $lb->setCaller( __METHOD__ );
461 foreach ( $result as $row ) {
462 $lb->add(
NS_USER, $row->ipb_address );
465 if ( isset( $row->by_user_name ) ) {
466 $lb->add(
NS_USER, $row->by_user_name );
470 if ( !$row->ipb_sitewide ) {
471 $partialBlocks[] = $row->ipb_id;
475 if ( $partialBlocks ) {
478 $this->restrictions = $this->blockRestrictionStore->loadByBlockId( $partialBlocks );
480 foreach ( $this->restrictions as $restriction ) {
481 if ( $restriction->getType() === PageRestriction::TYPE ) {
482 '@phan-var PageRestriction $restriction';
483 $title = $restriction->getTitle();