48 parent::__construct( $page->getContext(), $page->getLinkRenderer() );
54 static $headers =
null;
56 if ( $headers ===
null ) {
58 'ipb_timestamp' =>
'blocklist-timestamp',
59 'ipb_target' =>
'blocklist-target',
60 'ipb_expiry' =>
'blocklist-expiry',
61 'ipb_by' =>
'blocklist-by',
62 'ipb_params' =>
'blocklist-params',
63 'ipb_reason' =>
'blocklist-reason',
65 foreach ( $headers as $key => $val ) {
66 $headers[$key] = $this->
msg( $val )->text();
81 if ( $msg ===
null ) {
87 'blocklist-nousertalk',
91 'blocklist-editing-sitewide',
94 foreach (
$keys as $key ) {
95 $msg[$key] = $this->
msg( $key )->text();
109 case 'ipb_timestamp':
110 $formatted = htmlspecialchars( $language->userTimeAndDate( $value, $this->getUser() ) );
114 if ( $row->ipb_auto ) {
115 $formatted = $this->
msg(
'autoblockid', $row->ipb_id )->parse();
117 list( $target,
$type ) = DatabaseBlock::parseTarget( $row->ipb_address );
119 case DatabaseBlock::TYPE_USER:
120 case DatabaseBlock::TYPE_IP:
129 case DatabaseBlock::TYPE_RANGE:
130 $formatted = htmlspecialchars( $target );
136 $formatted = htmlspecialchars( $language->formatExpiry(
140 if ( MediaWikiServices::getInstance()
141 ->getPermissionManager()
142 ->userHasRight( $this->
getUser(),
'block' )
145 if ( $row->ipb_auto ) {
150 [
'wpTarget' =>
"#{$row->ipb_id}" ]
159 $msg[
'change-blocklink']
162 $formatted .=
' ' . Html::rawElement(
164 [
'class' =>
'mw-blocklist-actions' ],
165 $this->
msg(
'parentheses' )->rawParams(
166 $language->pipeList( $links ) )->escaped()
169 if ( $value !==
'infinity' ) {
171 $formatted .=
'<br />' . $this->
msg(
172 'ipb-blocklist-duration-left',
173 $language->formatDuration(
174 $timestamp->getTimestamp() - MWTimestamp::time(),
188 if ( isset( $row->by_user_name ) ) {
192 $formatted = htmlspecialchars( $row->ipb_by_text );
204 if ( $this->
getConfig()->
get(
'EnablePartialBlocks' ) && $row->ipb_sitewide ) {
205 $properties[] = htmlspecialchars( $msg[
'blocklist-editing-sitewide'] );
208 if ( !$row->ipb_sitewide && $this->restrictions ) {
211 $properties[] = htmlspecialchars( $msg[
'blocklist-editing'] ) . $list;
215 if ( $row->ipb_anon_only ) {
216 $properties[] = htmlspecialchars( $msg[
'anononlyblock'] );
218 if ( $row->ipb_create_account ) {
219 $properties[] = htmlspecialchars( $msg[
'createaccountblock'] );
221 if ( $row->ipb_user && !$row->ipb_enable_autoblock ) {
222 $properties[] = htmlspecialchars( $msg[
'noautoblockblock'] );
225 if ( $row->ipb_block_email ) {
226 $properties[] = htmlspecialchars( $msg[
'emailblock'] );
229 if ( !$row->ipb_allow_usertalk ) {
230 $properties[] = htmlspecialchars( $msg[
'blocklist-nousertalk'] );
233 $formatted = Html::rawElement(
236 implode(
'', array_map(
function ( $prop ) {
237 return Html::rawElement(
247 $formatted =
"Unable to format $name";
265 foreach ( $this->restrictions as $restriction ) {
266 if ( $restriction->getBlockId() !== (int)$row->ipb_id ) {
270 switch ( $restriction->getType() ) {
271 case PageRestriction::TYPE:
272 '@phan-var PageRestriction $restriction';
273 if ( $restriction->getTitle() ) {
274 $items[$restriction->getType()][] = Html::rawElement(
281 case NamespaceRestriction::TYPE:
282 $text = $restriction->getValue() ===
NS_MAIN
283 ? $this->
msg(
'blanknamespace' )->text()
285 $restriction->getValue()
287 $items[$restriction->getType()][] = Html::rawElement(
295 'namespace' => $restriction->getValue()
303 if ( empty( $items ) ) {
308 foreach ( $items as $key => $value ) {
309 $sets[] = Html::rawElement(
312 $this->
msg(
'blocklist-editing-' . $key ) . Html::rawElement(
315 implode(
'', $value )
320 return Html::rawElement(
332 'tables' => array_merge(
333 [
'ipblocks' ], $commentQuery[
'tables'], $actorQuery[
'tables'], [
'user' ]
339 'by_user_name' =>
'user_name',
343 'ipb_create_account',
344 'ipb_enable_autoblock',
350 'ipb_allow_usertalk',
352 ] + $commentQuery[
'fields'] + $actorQuery[
'fields'],
355 'user' => [
'LEFT JOIN',
'user_id = ' . $actorQuery[
'fields'][
'ipb_by'] ]
356 ] + $commentQuery[
'joins'] + $actorQuery[
'joins']
359 # Filter out any expired blocks
361 $info[
'conds'][] =
'ipb_expiry > ' . $db->addQuotes( $db->timestamp() );
363 # Is the user allowed to see hidden blocks?
364 if ( !MediaWikiServices::getInstance()
365 ->getPermissionManager()
366 ->userHasRight( $this->
getUser(),
'hideuser' )
368 $info[
'conds'][
'ipb_deleted'] = 0;
381 $res =
$dbr->selectField(
'ipblocks',
385 'ipb_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() ),
395 return parent::getTableClass() .
' mw-blocklist';
399 return 'ipb_timestamp';
403 return 'ipb_timestamp';
415 # Do a link batch query
420 foreach ( $result as $row ) {
421 $lb->add(
NS_USER, $row->ipb_address );
424 if ( isset( $row->by_user_name ) ) {
425 $lb->add(
NS_USER, $row->by_user_name );
429 if ( !$row->ipb_sitewide ) {
430 $partialBlocks[] = $row->ipb_id;
434 if ( $partialBlocks ) {
437 $blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
438 $this->restrictions = $blockRestrictionStore->loadByBlockId( $partialBlocks );