X-Git-Url: http://git.cyclocoop.org//%22javascript:ModifierStyle%28%27%22.%24id.%22%27%29/%22?a=blobdiff_plain;f=includes%2Fblock%2FAbstractBlock.php;h=fa91909b60bb2bcff463685645bc1527c629bd4b;hb=2f115a877f99c8ec5b4cb5f237a48097db933047;hp=f6544040bb42461d3ecf4068624371e08c387424;hpb=b14dd60f43a42bf9e37476529de96a23702eabdf;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/block/AbstractBlock.php b/includes/block/AbstractBlock.php index f6544040bb..fa91909b60 100644 --- a/includes/block/AbstractBlock.php +++ b/includes/block/AbstractBlock.php @@ -23,6 +23,7 @@ namespace MediaWiki\Block; use IContextSource; use InvalidArgumentException; use IP; +use MediaWiki\MediaWikiServices; use RequestContext; use Title; use User; @@ -89,12 +90,13 @@ abstract class AbstractBlock { /** * Create a new block with specified parameters on a user, IP or IP range. * - * @param array $options Parameters of the block: - * address string|User Target user name, User object, IP address or IP range - * by int User ID of the blocker - * reason string Reason of the block - * timestamp string The time at which the block comes into effect - * byText string Username of the blocker (for foreign users) + * @param array $options Parameters of the block, with supported options: + * - address: (string|User) Target user name, User object, IP address or IP range + * - by: (int) User ID of the blocker + * - reason: (string) Reason of the block + * - timestamp: (string) The time at which the block comes into effect + * - byText: (string) Username of the blocker (for foreign users) + * - hideName: (bool) Hide the target user name */ public function __construct( array $options = [] ) { $defaults = [ @@ -103,6 +105,7 @@ abstract class AbstractBlock { 'reason' => '', 'timestamp' => '', 'byText' => '', + 'hideName' => false, ]; $options += $defaults; @@ -119,6 +122,7 @@ abstract class AbstractBlock { $this->setReason( $options['reason'] ); $this->setTimestamp( wfTimestamp( TS_MW, $options['timestamp'] ) ); + $this->setHideName( (bool)$options['hideName'] ); } /** @@ -246,8 +250,9 @@ abstract class AbstractBlock { * may be overridden according to global configs. * * @since 1.33 - * @param string $right Right to check - * @return bool|null null if unrecognized right or unset property + * @param string $right + * @return bool|null The block applies to the right, or null if + * unsure (e.g. unrecognized right or unset property) */ public function appliesToRight( $right ) { $config = RequestContext::getMain()->getConfig(); @@ -279,8 +284,9 @@ abstract class AbstractBlock { if ( !$res && $blockDisablesLogin ) { // If a block would disable login, then it should // prevent any right that all users cannot do + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); $anon = new User; - $res = $anon->isAllowed( $right ) ? $res : true; + $res = $permissionManager->userHasRight( $anon, $right ) ? $res : true; } return $res; @@ -339,8 +345,9 @@ abstract class AbstractBlock { if ( !$res && $blockDisablesLogin ) { // If a block would disable login, then it should // prevent any action that all users cannot do + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); $anon = new User; - $res = $anon->isAllowed( $action ) ? $res : true; + $res = $permissionManager->userHasRight( $anon, $action ) ? $res : true; } return $res;