- protected function getCurrentUserInfo() {
- global $wgUser, $wgRequest;
- $result = $this->getResult();
- $vals = array();
- $vals['id'] = intval( $wgUser->getId() );
- $vals['name'] = $wgUser->getName();
+ /**
+ * Get basic info about a given block
+ * @param Block $block
+ * @return array Array containing several keys:
+ * - blockid - ID of the block
+ * - blockedby - username of the blocker
+ * - blockedbyid - user ID of the blocker
+ * - blockreason - reason provided for the block
+ * - blockedtimestamp - timestamp for when the block was placed/modified
+ * - blockexpiry - expiry time of the block
+ * - systemblocktype - system block type, if any
+ */
+ public static function getBlockInfo( Block $block ) {
+ $vals = [];
+ $vals['blockid'] = $block->getId();
+ $vals['blockedby'] = $block->getByName();
+ $vals['blockedbyid'] = $block->getBy();
+ $vals['blockreason'] = $block->mReason;
+ $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->mTimestamp );
+ $vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
+ if ( $block->getSystemBlockType() !== null ) {
+ $vals['systemblocktype'] = $block->getSystemBlockType();
+ }
+ return $vals;
+ }
+
+ /**
+ * Get central user info
+ * @param Config $config
+ * @param User $user
+ * @param string|null $attachedWiki
+ * @return array Central user info
+ * - centralids: Array mapping non-local Central ID provider names to IDs
+ * - attachedlocal: Array mapping Central ID provider names to booleans
+ * indicating whether the local user is attached.
+ * - attachedwiki: Array mapping Central ID provider names to booleans
+ * indicating whether the user is attached to $attachedWiki.
+ */
+ public static function getCentralUserInfo( Config $config, User $user, $attachedWiki = null ) {
+ $providerIds = array_keys( $config->get( 'CentralIdLookupProviders' ) );