MediaWiki  master
ApiBlockInfoTrait.php
Go to the documentation of this file.
1 <?php
23 
28 
43  private function getBlockDetails(
44  AbstractBlock $block,
45  $language = null
46  ) {
47  if ( $language === null ) {
48  $language = $this->getLanguage();
49  }
50 
51  $vals = [];
52  $vals['blockid'] = $block->getId();
53  $vals['blockedby'] = $block->getByName();
54  $vals['blockedbyid'] = $block->getBy();
55  $vals['blockreason'] = $block->getReasonComment()
56  ->message->inLanguage( $language )->plain();
57  $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->getTimestamp() );
58  $vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
59  $vals['blockpartial'] = !$block->isSitewide();
60  $vals['blocknocreate'] = $block->isCreateAccountBlocked();
61  $vals['blockanononly'] = !$block->isHardblock();
62 
63  if ( $block instanceof SystemBlock ) {
64  $vals['systemblocktype'] = $block->getSystemBlockType();
65  }
66 
67  return $vals;
68  }
69 
70  // region Methods required from ApiBase
79  abstract public function getLanguage();
80 
82  // endregion -- end of methods required from ApiBase
83 
84 }
MediaWiki\Block\AbstractBlock\getBy
getBy()
Get the user id of the blocking sysop.
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1831
MediaWiki\Block\AbstractBlock\isCreateAccountBlocked
isCreateAccountBlocked( $x=null)
Get or set the flag indicating whether this block blocks the target from creating an account.
Definition: AbstractBlock.php:233
MediaWiki\Block\AbstractBlock\getId
getId()
Get the block ID.
Definition: AbstractBlock.php:143
MediaWiki\Block\AbstractBlock\isHardblock
isHardblock( $x=null)
Get/set whether the block is a hardblock (affects logged-in users on a given IP/range)
Definition: AbstractBlock.php:272
MediaWiki\Block\AbstractBlock\getReasonComment
getReasonComment()
Get the reason for creating the block.
Definition: AbstractBlock.php:177
MediaWiki\Block\AbstractBlock\isSitewide
isSitewide( $x=null)
Indicates that the block is a sitewide block.
Definition: AbstractBlock.php:220
ApiBlockInfoTrait
trait ApiBlockInfoTrait
Definition: ApiBlockInfoTrait.php:27
MediaWiki\Block\SystemBlock
System blocks are temporary blocks that are created on enforcement (e.g.
Definition: SystemBlock.php:33
MediaWiki\Block\AbstractBlock\getExpiry
getExpiry()
Get the block expiry time.
Definition: AbstractBlock.php:384
MediaWiki\Block\AbstractBlock\getTimestamp
getTimestamp()
Get the timestamp indicating when the block was created.
Definition: AbstractBlock.php:404
ApiResult\formatExpiry
static formatExpiry( $expiry, $infinity='infinity')
Format an expiry timestamp for API output.
Definition: ApiResult.php:1189
MediaWiki\Block\AbstractBlock
Definition: AbstractBlock.php:37
MediaWiki\Block\AbstractBlock\getByName
getByName()
Get the username of the blocking sysop.