X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryUserInfo.php;h=ab8d93a4f9a93ca594b4f41796f9d0d2b312f7c3;hb=529fc12d2ad2032337594389448fdb5b55802830;hp=00d7d84de8de4020d47ea66116bfeb93b9c35dd4;hpb=a826aa478bf076a46396eb2bb6c4d074bc324555;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index 00d7d84de8..ab8d93a4f9 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -20,6 +20,7 @@ * @file */ +use MediaWiki\Block\AbstractBlock; use MediaWiki\MediaWikiServices; /** @@ -29,6 +30,8 @@ use MediaWiki\MediaWikiServices; */ class ApiQueryUserInfo extends ApiQueryBase { + use ApiBlockInfoTrait; + const WL_UNREAD_LIMIT = 1000; private $params = []; @@ -52,29 +55,22 @@ class ApiQueryUserInfo extends ApiQueryBase { /** * 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 + * + * @deprecated since 1.34 Use ApiBlockInfoTrait::getBlockDetails() instead. + * @param AbstractBlock $block + * @return array See ApiBlockInfoTrait::getBlockDetails */ - public static function getBlockInfo( Block $block ) { - $vals = []; - $vals['blockid'] = $block->getId(); - $vals['blockedby'] = $block->getByName(); - $vals['blockedbyid'] = $block->getBy(); - $vals['blockreason'] = $block->getReason(); - $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->getTimestamp() ); - $vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' ); - $vals['blockpartial'] = !$block->isSitewide(); - if ( $block->getSystemBlockType() !== null ) { - $vals['systemblocktype'] = $block->getSystemBlockType(); - } - return $vals; + public static function getBlockInfo( AbstractBlock $block ) { + wfDeprecated( __METHOD__, '1.34' ); + + // Hack to access a private method from a trait: + $dummy = new class { + use ApiBlockInfoTrait { + getBlockDetails as public; + } + }; + + return $dummy->getBlockDetails( $block ); } /** @@ -129,7 +125,7 @@ class ApiQueryUserInfo extends ApiQueryBase { if ( isset( $this->prop['blockinfo'] ) ) { $block = $user->getBlock(); if ( $block ) { - $vals = array_merge( $vals, self::getBlockInfo( $block ) ); + $vals = array_merge( $vals, $this->getBlockDetails( $block ) ); } } @@ -163,8 +159,7 @@ class ApiQueryUserInfo extends ApiQueryBase { } if ( isset( $this->prop['rights'] ) ) { - // User::getRights() may return duplicate values, strip them - $vals['rights'] = array_values( array_unique( $user->getRights() ) ); + $vals['rights'] = $this->getPermissionManager()->getUserPermissions( $user ); ApiResult::setArrayType( $vals['rights'], 'array' ); // even if empty ApiResult::setIndexedTagName( $vals['rights'], 'r' ); // even if empty } @@ -184,7 +179,7 @@ class ApiQueryUserInfo extends ApiQueryBase { if ( isset( $this->prop['preferencestoken'] ) && !$this->lacksSameOriginSecurity() && - $user->isAllowed( 'editmyoptions' ) + $this->getPermissionManager()->userHasRight( $user, 'editmyoptions' ) ) { $vals['preferencestoken'] = $user->getEditToken( '', $this->getMain()->getRequest() ); } @@ -205,7 +200,8 @@ class ApiQueryUserInfo extends ApiQueryBase { $vals['realname'] = $user->getRealName(); } - if ( $user->isAllowed( 'viewmyprivateinfo' ) && isset( $this->prop['email'] ) ) { + if ( $this->getPermissionManager()->userHasRight( $user, 'viewmyprivateinfo' ) && + isset( $this->prop['email'] ) ) { $vals['email'] = $user->getEmail(); $auth = $user->getEmailAuthenticationTimestamp(); if ( $auth !== null ) {