50 parent::__construct( $page->getContext(), $page->getLinkRenderer() );
56 static $headers =
null;
58 if ( $headers ===
null ) {
60 'ipb_timestamp' =>
'blocklist-timestamp',
61 'ipb_target' =>
'blocklist-target',
62 'ipb_expiry' =>
'blocklist-expiry',
63 'ipb_by' =>
'blocklist-by',
64 'ipb_params' =>
'blocklist-params',
65 'ipb_reason' =>
'blocklist-reason',
67 foreach ( $headers as $key => $val ) {
68 $headers[$key] = $this->
msg( $val )->text();
83 if ( $msg ===
null ) {
89 'blocklist-nousertalk',
93 'blocklist-editing-sitewide',
96 foreach (
$keys as $key ) {
97 $msg[$key] = $this->
msg( $key )->text();
100 '@phan-var string[] $msg';
112 case 'ipb_timestamp':
113 $formatted = htmlspecialchars( $language->userTimeAndDate( $value, $this->getUser() ) );
117 if ( $row->ipb_auto ) {
118 $formatted = $this->
msg(
'autoblockid', $row->ipb_id )->parse();
120 list( $target,
$type ) = DatabaseBlock::parseTarget( $row->ipb_address );
122 if ( is_string( $target ) ) {
123 if ( IPUtils::isValidRange( $target ) ) {
126 $formatted = $target;
143 $formatted = htmlspecialchars( $language->formatExpiry(
147 if ( MediaWikiServices::getInstance()
149 ->userHasRight( $this->
getUser(),
'block' )
152 if ( $row->ipb_auto ) {
157 [
'wpTarget' =>
"#{$row->ipb_id}" ]
166 $msg[
'change-blocklink']
169 $formatted .=
' ' . Html::rawElement(
171 [
'class' =>
'mw-blocklist-actions' ],
172 $this->
msg(
'parentheses' )->rawParams(
173 $language->pipeList( $links ) )->escaped()
176 if ( $value !==
'infinity' ) {
178 $formatted .=
'<br />' . $this->
msg(
179 'ipb-blocklist-duration-left',
180 $language->formatDuration(
181 $timestamp->getTimestamp() - MWTimestamp::time(),
195 if ( isset( $row->by_user_name ) ) {
199 $formatted = htmlspecialchars( $row->ipb_by_text );
204 $value = CommentStore::getStore()->getComment(
'ipb_reason', $row )->text;
211 if ( $row->ipb_sitewide ) {
212 $properties[] = htmlspecialchars( $msg[
'blocklist-editing-sitewide'] );
215 if ( !$row->ipb_sitewide && $this->restrictions ) {
218 $properties[] = htmlspecialchars( $msg[
'blocklist-editing'] ) . $list;
222 if ( $row->ipb_anon_only ) {
223 $properties[] = htmlspecialchars( $msg[
'anononlyblock'] );
225 if ( $row->ipb_create_account ) {
226 $properties[] = htmlspecialchars( $msg[
'createaccountblock'] );
228 if ( $row->ipb_user && !$row->ipb_enable_autoblock ) {
229 $properties[] = htmlspecialchars( $msg[
'noautoblockblock'] );
232 if ( $row->ipb_block_email ) {
233 $properties[] = htmlspecialchars( $msg[
'emailblock'] );
236 if ( !$row->ipb_allow_usertalk ) {
237 $properties[] = htmlspecialchars( $msg[
'blocklist-nousertalk'] );
240 $formatted = Html::rawElement(
243 implode(
'', array_map(
function ( $prop ) {
244 return Html::rawElement(
254 $formatted =
"Unable to format $name";
272 foreach ( $this->restrictions as $restriction ) {
273 if ( $restriction->getBlockId() !== (
int)$row->ipb_id ) {
277 switch ( $restriction->getType() ) {
278 case PageRestriction::TYPE:
279 '@phan-var PageRestriction $restriction';
280 if ( $restriction->getTitle() ) {
281 $items[$restriction->getType()][] = Html::rawElement(
288 case NamespaceRestriction::TYPE:
289 $text = $restriction->getValue() ===
NS_MAIN
290 ? $this->
msg(
'blanknamespace' )->text()
292 $restriction->getValue()
294 $items[$restriction->getType()][] = Html::rawElement(
302 'namespace' => $restriction->getValue()
310 if ( empty( $items ) ) {
315 foreach ( $items as $key => $value ) {
316 $sets[] = Html::rawElement(
319 $this->
msg(
'blocklist-editing-' . $key ) . Html::rawElement(
322 implode(
'', $value )
327 return Html::rawElement(
335 $commentQuery = CommentStore::getStore()->getJoin(
'ipb_reason' );
336 $actorQuery = ActorMigration::newMigration()->getJoin(
'ipb_by' );
339 'tables' => array_merge(
340 [
'ipblocks' ], $commentQuery[
'tables'], $actorQuery[
'tables'], [
'user' ]
346 'by_user_name' =>
'user_name',
350 'ipb_create_account',
351 'ipb_enable_autoblock',
357 'ipb_allow_usertalk',
359 ] + $commentQuery[
'fields'] + $actorQuery[
'fields'],
362 'user' => [
'LEFT JOIN',
'user_id = ' . $actorQuery[
'fields'][
'ipb_by'] ]
363 ] + $commentQuery[
'joins'] + $actorQuery[
'joins']
366 # Filter out any expired blocks
368 $info[
'conds'][] =
'ipb_expiry > ' . $db->addQuotes( $db->timestamp() );
370 # Is the user allowed to see hidden blocks?
371 if ( !MediaWikiServices::getInstance()
373 ->userHasRight( $this->
getUser(),
'hideuser' )
375 $info[
'conds'][
'ipb_deleted'] = 0;
388 $res =
$dbr->selectField(
'ipblocks',
392 'ipb_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() ),
403 return parent::getTableClass() .
' mw-blocklist';
407 return [ [
'ipb_timestamp',
'ipb_id' ] ];
423 # Do a link batch query
428 foreach ( $result as $row ) {
429 $lb->add(
NS_USER, $row->ipb_address );
432 if ( isset( $row->by_user_name ) ) {
433 $lb->add(
NS_USER, $row->by_user_name );
437 if ( !$row->ipb_sitewide ) {
438 $partialBlocks[] = $row->ipb_id;
442 if ( $partialBlocks ) {
445 $blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
446 $this->restrictions = $blockRestrictionStore->loadByBlockId( $partialBlocks );
448 foreach ( $this->restrictions as $restriction ) {
449 if ( $restriction->getType() === PageRestriction::TYPE ) {
450 '@phan-var PageRestriction $restriction';
451 $title = $restriction->getTitle();
getUser()
Stable to override.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Class representing a list of titles The execute() method checks them all for existence and adds them ...
setCaller( $caller)
Use ->setCaller( METHOD ) to indicate which code is using this class.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
const TOOL_LINKS_NOBLOCK
Flags for userToolLinks()
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
Library for creating and parsing MW-style timestamps.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
static getTitleValueFor( $name, $subpage=false, $fragment='')
Get a localised TitleValue object for a specified special page name.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.