Merge "RaggettWrapper: Don't use ReplacementArray"
[lhc/web/wiklou.git] / includes / specials / SpecialUserrights.php
index 3ba46c1..c869528 100644 (file)
@@ -76,6 +76,7 @@ class UserrightsPage extends SpecialPage {
        public function execute( $par ) {
                $user = $this->getUser();
                $request = $this->getRequest();
+               $session = $request->getSession();
                $out = $this->getOutput();
 
                if ( $par !== null ) {
@@ -88,6 +89,10 @@ class UserrightsPage extends SpecialPage {
                        $this->mTarget = trim( $this->mTarget );
                }
 
+               if ( $this->mTarget !== null && User::getCanonicalName( $this->mTarget ) === $user->getName() ) {
+                       $this->isself = true;
+               }
+
                $fetchedStatus = $this->fetchUser( $this->mTarget, true );
                if ( $fetchedStatus->isOK() ) {
                        $this->mFetchedUser = $fetchedStatus->value;
@@ -99,7 +104,13 @@ class UserrightsPage extends SpecialPage {
                }
 
                // show a successbox, if the user rights was saved successfully
-               if ( $request->getCheck( 'success' ) && $this->mFetchedUser !== null ) {
+               if (
+                       $session->get( 'specialUserrightsSaveSuccess' ) &&
+                       $this->mFetchedUser !== null
+               ) {
+                       // Remove session data for the success message
+                       $session->remove( 'specialUserrightsSaveSuccess' );
+
                        $out->addModules( [ 'mediawiki.special.userrights' ] );
                        $out->addModuleStyles( 'mediawiki.notification.convertmessagebox.styles' );
                        $out->addHTML(
@@ -167,6 +178,9 @@ class UserrightsPage extends SpecialPage {
                                        $targetUser
                                );
 
+                               // Set session data for the success message
+                               $session->set( 'specialUserrightsSaveSuccess', 1 );
+
                                $out->redirect( $this->getSuccessURL() );
 
                                return;
@@ -180,7 +194,7 @@ class UserrightsPage extends SpecialPage {
        }
 
        function getSuccessURL() {
-               return $this->getPageTitle( $this->mTarget )->getFullURL( [ 'success' => 1 ] );
+               return $this->getPageTitle( $this->mTarget )->getFullURL();
        }
 
        /**
@@ -236,6 +250,8 @@ class UserrightsPage extends SpecialPage {
                        $groups )
                );
 
+               Hooks::run( 'ChangeUserGroups', [ $this->getUser(), $user, &$add, &$remove ] );
+
                $oldGroups = $user->getGroups();
                $newGroups = $oldGroups;