From: Derick Alangi Date: Sat, 23 Mar 2019 13:02:00 +0000 (+0100) Subject: SpecialUserrights: Improve ::userCanChangeRights() method logic X-Git-Tag: 1.34.0-rc.0~1857 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=d0a98441de61908c12e4b4be667322ddf1608be9;p=lhc%2Fweb%2Fwiklou.git SpecialUserrights: Improve ::userCanChangeRights() method logic Bug: T37674 Change-Id: I22aa9ff72aec175b0f86ebcf48cd7716f3328b01 --- diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 540754f923..7d97e58ddf 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -61,15 +61,23 @@ class UserrightsPage extends SpecialPage { $isself = $this->getUser()->equals( $targetUser ); $available = $this->changeableGroups(); - if ( $targetUser->getId() == 0 ) { + if ( $targetUser->getId() === 0 ) { return false; } - return !empty( $available['add'] ) - || !empty( $available['remove'] ) - || ( ( $isself || !$checkIfSelf ) && - ( !empty( $available['add-self'] ) - || !empty( $available['remove-self'] ) ) ); + if ( $available['add'] || $available['remove'] ) { + // can change some rights for any user + return true; + } + + if ( ( $available['add-self'] || $available['remove-self'] ) + && ( $isself || !$checkIfSelf ) + ) { + // can change some rights for self + return true; + } + + return false; } /**