X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialBlock.php;h=1b0db7345c4cb3e910733c8dfcf2befa65d5e96e;hb=9642ee9419450bf0e944c08a5f0c27768f5d7b88;hp=3a266f23d717f98baf896b57896ea1dfddfb4951;hpb=13f4dfb519ebdc75b39109c11d31868faa56d49c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 3a266f23d7..1b0db7345c 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -25,6 +25,7 @@ use MediaWiki\Block\DatabaseBlock; use MediaWiki\Block\Restriction\PageRestriction; use MediaWiki\Block\Restriction\NamespaceRestriction; use MediaWiki\MediaWikiServices; +use MediaWiki\User\UserIdentity; /** * A special page that allows users with 'block' right to block users from @@ -269,7 +270,10 @@ class SpecialBlock extends FormSpecialPage { ]; # Allow some users to hide name from block log, blocklist and listusers - if ( $user->isAllowed( 'hideuser' ) ) { + if ( MediaWikiServices::getInstance() + ->getPermissionManager() + ->userHasRight( $user, 'hideuser' ) + ) { $a['HideUser'] = [ 'type' => 'check', 'label-message' => 'ipbhidename', @@ -363,7 +367,10 @@ class SpecialBlock extends FormSpecialPage { // If the username was hidden (ipb_deleted == 1), don't show the reason // unless this user also has rights to hideuser: T37839 - if ( !$block->getHideName() || $this->getUser()->isAllowed( 'hideuser' ) ) { + if ( !$block->getHideName() || MediaWikiServices::getInstance() + ->getPermissionManager() + ->userHasRight( $this->getUser(), 'hideuser' ) + ) { $fields['Reason']['default'] = $block->getReason(); } else { $fields['Reason']['default'] = ''; @@ -423,6 +430,8 @@ class SpecialBlock extends FormSpecialPage { foreach ( $block->getRestrictions() as $restriction ) { switch ( $restriction->getType() ) { case PageRestriction::TYPE: + /** @var PageRestriction $restriction */ + '@phan-var PageRestriction $restriction'; if ( $restriction->getTitle() ) { $pageRestrictions[] = $restriction->getTitle()->getPrefixedText(); } @@ -543,7 +552,8 @@ class SpecialBlock extends FormSpecialPage { $user = $this->getUser(); # Link to edit the block dropdown reasons, if applicable - if ( $user->isAllowed( 'editinterface' ) ) { + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); + if ( $permissionManager->userHasRight( $user, 'editinterface' ) ) { $links[] = $linkRenderer->makeKnownLink( $this->msg( 'ipbreason-dropdown' )->inContentLanguage()->getTitle(), $this->msg( 'ipb-edit-dropdown' )->text(), @@ -577,7 +587,7 @@ class SpecialBlock extends FormSpecialPage { $text .= $out; # Add suppression block entries if allowed - if ( $user->isAllowed( 'suppressionlog' ) ) { + if ( $permissionManager->userHasRight( $user, 'suppressionlog' ) ) { LogEventsList::showLogExtract( $out, 'suppress', @@ -826,7 +836,10 @@ class SpecialBlock extends FormSpecialPage { } if ( $data['HideUser'] ) { - if ( !$performer->isAllowed( 'hideuser' ) ) { + if ( !MediaWikiServices::getInstance() + ->getPermissionManager() + ->userHasRight( $performer, 'hideuser' ) + ) { # this codepath is unreachable except by a malicious user spoofing forms, # or by race conditions (user has hideuser and block rights, loads block form, # and loses hideuser rights before submission); so need to fail completely @@ -936,7 +949,10 @@ class SpecialBlock extends FormSpecialPage { } # If the name was hidden and the blocking user cannot hide # names, then don't allow any block changes... - if ( $currentBlock->getHideName() && !$performer->isAllowed( 'hideuser' ) ) { + if ( $currentBlock->getHideName() && !MediaWikiServices::getInstance() + ->getPermissionManager() + ->userHasRight( $performer, 'hideuser' ) + ) { return [ 'cant-see-hidden-user' ]; } @@ -1104,13 +1120,15 @@ class SpecialBlock extends FormSpecialPage { /** * Can we do an email block? - * @param User $user The sysop wanting to make a block + * @param UserIdentity $user The sysop wanting to make a block * @return bool */ - public static function canBlockEmail( $user ) { + public static function canBlockEmail( UserIdentity $user ) { global $wgEnableUserEmail, $wgSysopEmailBans; - return ( $wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ) ); + return ( $wgEnableUserEmail && $wgSysopEmailBans && MediaWikiServices::getInstance() + ->getPermissionManager() + ->userHasRight( $user, 'blockemail' ) ); } /** @@ -1136,7 +1154,10 @@ class SpecialBlock extends FormSpecialPage { if ( $performer->getBlock() ) { if ( $target instanceof User && $target->getId() == $performer->getId() ) { # User is trying to unblock themselves - if ( $performer->isAllowed( 'unblockself' ) ) { + if ( MediaWikiServices::getInstance() + ->getPermissionManager() + ->userHasRight( $performer, 'unblockself' ) + ) { return true; # User blocked themselves and is now trying to reverse it } elseif ( $performer->blockedBy() === $performer->getName() ) {