Merge "allow xml page content or metadata dumps to target specific namespaces"
[lhc/web/wiklou.git] / includes / specials / SpecialUserrights.php
index 540754f..8655b1c 100644 (file)
@@ -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;
        }
 
        /**
@@ -152,8 +160,13 @@ class UserrightsPage extends SpecialPage {
                        * (e.g. they don't have the userrights permission), then don't
                        * allow them to change any user rights.
                        */
-                       if ( $user->isBlocked() && !$user->isAllowed( 'userrights' ) ) {
-                               throw new UserBlockedError( $user->getBlock() );
+                       if ( !$user->isAllowed( 'userrights' ) ) {
+                               // @TODO Should the user be blocked from changing user rights if they
+                               //       are partially blocked?
+                               $block = $user->getBlock();
+                               if ( $block ) {
+                                       throw new UserBlockedError( $user->getBlock() );
+                               }
                        }
 
                        $this->checkReadOnly();