35 use Wikimedia\IPUtils;
118 static $headers =
null;
120 if ( $headers ===
null ) {
122 'ipb_timestamp' =>
'blocklist-timestamp',
123 'ipb_target' =>
'blocklist-target',
124 'ipb_expiry' =>
'blocklist-expiry',
125 'ipb_by' =>
'blocklist-by',
126 'ipb_params' =>
'blocklist-params',
127 'ipb_reason' =>
'blocklist-reason',
129 foreach ( $headers as $key => $val ) {
130 $headers[$key] = $this->
msg( $val )->text();
145 if ( $msg ===
null ) {
148 'createaccountblock',
151 'blocklist-nousertalk',
155 'blocklist-editing-sitewide',
158 foreach (
$keys as $key ) {
159 $msg[$key] = $this->
msg( $key )->text();
162 '@phan-var string[] $msg';
174 case 'ipb_timestamp':
175 $formatted = htmlspecialchars( $language->userTimeAndDate( $value, $this->getUser() ) );
179 if ( $row->ipb_auto ) {
180 $formatted = $this->
msg(
'autoblockid', $row->ipb_id )->parse();
182 list( $target, ) = $this->blockUtils->parseBlockTarget( $row->ipb_address );
184 if ( is_string( $target ) ) {
185 if ( IPUtils::isValidRange( $target ) ) {
188 $formatted = $target;
205 $formatted = htmlspecialchars( $language->formatExpiry(
213 if ( $row->ipb_auto ) {
215 $this->specialPageFactory->getTitleForAlias(
'Unblock' ),
218 [
'wpTarget' =>
"#{$row->ipb_id}" ]
222 $this->specialPageFactory->getTitleForAlias(
'Unblock/' . $row->ipb_address ),
226 $this->specialPageFactory->getTitleForAlias(
'Block/' . $row->ipb_address ),
227 $msg[
'change-blocklink']
232 [
'class' =>
'mw-blocklist-actions' ],
233 $this->
msg(
'parentheses' )->rawParams(
234 $language->pipeList( $links ) )->escaped()
237 if ( $value !==
'infinity' ) {
239 $formatted .=
'<br />' . $this->
msg(
240 'ipb-blocklist-duration-left',
241 $language->formatDuration(
242 (
int)$timestamp->getTimestamp( TS_UNIX ) - MWTimestamp::time(),
267 if ( $row->ipb_sitewide ) {
268 $properties[] = htmlspecialchars( $msg[
'blocklist-editing-sitewide'] );
271 if ( !$row->ipb_sitewide && $this->restrictions ) {
274 $properties[] = htmlspecialchars( $msg[
'blocklist-editing'] ) . $list;
278 if ( $row->ipb_anon_only ) {
279 $properties[] = htmlspecialchars( $msg[
'anononlyblock'] );
281 if ( $row->ipb_create_account ) {
282 $properties[] = htmlspecialchars( $msg[
'createaccountblock'] );
284 if ( $row->ipb_user && !$row->ipb_enable_autoblock ) {
285 $properties[] = htmlspecialchars( $msg[
'noautoblockblock'] );
288 if ( $row->ipb_block_email ) {
289 $properties[] = htmlspecialchars( $msg[
'emailblock'] );
292 if ( !$row->ipb_allow_usertalk ) {
293 $properties[] = htmlspecialchars( $msg[
'blocklist-nousertalk'] );
299 implode(
'', array_map(
static function ( $prop ) {
310 $formatted =
"Unable to format $name";
328 foreach ( $this->restrictions as $restriction ) {
329 if ( $restriction->getBlockId() !== (
int)$row->ipb_id ) {
333 switch ( $restriction->getType() ) {
334 case PageRestriction::TYPE:
335 '@phan-var PageRestriction $restriction';
336 if ( $restriction->getTitle() ) {
344 case NamespaceRestriction::TYPE:
345 $text = $restriction->getValue() ===
NS_MAIN
346 ? $this->
msg(
'blanknamespace' )->text()
348 $restriction->getValue()
355 $this->specialPageFactory->getTitleForAlias(
'Allpages' ),
359 'namespace' => $restriction->getValue()
365 case ActionRestriction::TYPE:
366 $actionName = $this->blockActionInfo->getActionFromId( $restriction->getValue() );
367 $enablePartialActionBlocks =
368 $this->
getConfig()->get( MainConfigNames::EnablePartialActionBlocks );
369 if ( $actionName && $enablePartialActionBlocks ) {
373 $this->
msg(
'ipb-action-' .
374 $this->blockActionInfo->getActionFromId( $restriction->getValue() ) )->escaped()
381 if ( empty( $items ) ) {
386 foreach ( $items as $key => $value ) {
393 implode(
'', $value )
406 $commentQuery = $this->commentStore->getJoin(
'ipb_reason' );
409 'tables' => array_merge(
410 [
'ipblocks',
'ipblocks_by_actor' =>
'actor' ],
411 $commentQuery[
'tables']
417 'ipb_by' =>
'ipblocks_by_actor.actor_user',
418 'ipb_by_text' =>
'ipblocks_by_actor.actor_name',
422 'ipb_create_account',
423 'ipb_enable_autoblock',
429 'ipb_allow_usertalk',
431 ] + $commentQuery[
'fields'],
434 'ipblocks_by_actor' => [
'JOIN',
'actor_id=ipb_by_actor' ]
435 ] + $commentQuery[
'joins']
438 # Filter out any expired blocks
440 $info[
'conds'][] =
'ipb_expiry > ' . $db->addQuotes( $db->timestamp() );
442 # Is the user allowed to see hidden blocks?
443 if ( !$this->
getAuthority()->isAllowed(
'hideuser' ) ) {
444 $info[
'conds'][
'ipb_deleted'] = 0;
457 return (
int)
$dbr->selectField(
'ipblocks',
'COUNT(*)',
460 'ipb_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() ),
467 return parent::getTableClass() .
' mw-blocklist';
471 return [ [
'ipb_timestamp',
'ipb_id' ] ];
488 $lb = $this->linkBatchFactory->newLinkBatch();
489 $lb->setCaller( __METHOD__ );
492 foreach ( $result as $row ) {
493 $lb->add(
NS_USER, $row->ipb_address );
496 if ( $row->ipb_by ??
null ) {
497 $lb->add(
NS_USER, $row->ipb_by_text );
501 if ( !$row->ipb_sitewide ) {
502 $partialBlocks[] = $row->ipb_id;
506 if ( $partialBlocks ) {
509 $this->restrictions = $this->blockRestrictionStore->loadByBlockId( $partialBlocks );
511 foreach ( $this->restrictions as $restriction ) {
512 if ( $restriction->getType() === PageRestriction::TYPE ) {
513 '@phan-var PageRestriction $restriction';
514 $title = $restriction->getTitle();
526 $this->formattedComments = $this->rowCommentFormatter->formatRows( $result,
'ipb_reason' );
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
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.)
Library for creating and parsing MW-style timestamps.
A class containing constants representing the names of configuration variables.
Factory for handling the special page list and generating SpecialPage objects.
static newFromName( $name, $validate='valid')
Interface for objects which can provide a MediaWiki context on request.