Remove user rights link from anonymous contributions pages
authorAlex Monk <krenair@gmail.com>
Mon, 2 Apr 2012 16:32:23 +0000 (17:32 +0100)
committerAlex Monk <krenair@gmail.com>
Tue, 3 Apr 2012 19:57:51 +0000 (20:57 +0100)
Remove the user rights link from the Contributions/DeletedContributions pages for anonymous users, as you can't set user rights on anonymous users.

Change-Id: I21551aa6c9ec14c5cda997f2c78fe7434df6d371

includes/specials/SpecialContributions.php
includes/specials/SpecialDeletedContributions.php
includes/specials/SpecialUserrights.php

index 03dd522..e84118b 100644 (file)
@@ -333,7 +333,7 @@ class SpecialContributions extends SpecialPage {
                # Add a link to change user rights for privileged users
                $userrightsPage = new UserrightsPage();
                $userrightsPage->setContext( $this->getContext() );
-               if ( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
+               if ( $userrightsPage->userCanChangeRights( $target ) ) {
                        $tools[] = Linker::linkKnown(
                                SpecialPage::getTitleFor( 'Userrights', $username ),
                                $this->msg( 'sp-contributions-userrights' )->escaped()
index 64455d4..a6719c8 100644 (file)
@@ -405,7 +405,7 @@ class DeletedContributionsPage extends SpecialPage {
                        # Add a link to change user rights for privileged users
                        $userrightsPage = new UserrightsPage();
                        $userrightsPage->setContext( $this->getContext() );
-                       if( $id !== null && $userrightsPage->userCanChangeRights( User::newFromId( $id ) ) ) {
+                       if( $userrightsPage->userCanChangeRights( $userObj ) ) {
                                $tools[] = Linker::linkKnown(
                                        SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ),
                                        $this->msg( 'sp-contributions-userrights' )->escaped()
index f3582ff..3947f3a 100644 (file)
@@ -47,6 +47,9 @@ class UserrightsPage extends SpecialPage {
 
        public function userCanChangeRights( $user, $checkIfSelf = true ) {
                $available = $this->changeableGroups();
+               if ( $user->getId() == 0 ) {
+                       return false;
+               }
                return !empty( $available['add'] )
                        || !empty( $available['remove'] )
                        || ( ( $this->isself || !$checkIfSelf ) &&