Remove trailing empty lines in PHP
[lhc/web/wiklou.git] / includes / specials / SpecialUserrights.php
index 1d9c057..4db2198 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 ) {
@@ -103,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(
@@ -171,6 +178,9 @@ class UserrightsPage extends SpecialPage {
                                        $targetUser
                                );
 
+                               // Set session data for the success message
+                               $session->set( 'specialUserrightsSaveSuccess', 1 );
+
                                $out->redirect( $this->getSuccessURL() );
 
                                return;
@@ -184,7 +194,7 @@ class UserrightsPage extends SpecialPage {
        }
 
        function getSuccessURL() {
-               return $this->getPageTitle( $this->mTarget )->getFullURL( [ 'success' => 1 ] );
+               return $this->getPageTitle( $this->mTarget )->getFullURL();
        }
 
        /**
@@ -223,9 +233,10 @@ class UserrightsPage extends SpecialPage {
         * @param array $add Array of groups to add
         * @param array $remove Array of groups to remove
         * @param string $reason Reason for group change
+        * @param array $tags Array of change tags to add to the log entry
         * @return array Tuple of added, then removed groups
         */
-       function doSaveUserGroups( $user, $add, $remove, $reason = '' ) {
+       function doSaveUserGroups( $user, $add, $remove, $reason = '', $tags = [] ) {
                // Validate input set...
                $isself = $user->getName() == $this->getUser()->getName();
                $groups = $user->getGroups();
@@ -240,6 +251,8 @@ class UserrightsPage extends SpecialPage {
                        $groups )
                );
 
+               Hooks::run( 'ChangeUserGroups', [ $this->getUser(), $user, &$add, &$remove ] );
+
                $oldGroups = $user->getGroups();
                $newGroups = $oldGroups;
 
@@ -277,7 +290,7 @@ class UserrightsPage extends SpecialPage {
                Hooks::run( 'UserRights', [ &$user, $add, $remove ], '1.26' );
 
                if ( $newGroups != $oldGroups ) {
-                       $this->addLogEntry( $user, $oldGroups, $newGroups, $reason );
+                       $this->addLogEntry( $user, $oldGroups, $newGroups, $reason, $tags );
                }
 
                return [ $add, $remove ];
@@ -289,8 +302,9 @@ class UserrightsPage extends SpecialPage {
         * @param array $oldGroups
         * @param array $newGroups
         * @param array $reason
+        * @param array $tags
         */
-       function addLogEntry( $user, $oldGroups, $newGroups, $reason ) {
+       function addLogEntry( $user, $oldGroups, $newGroups, $reason, $tags ) {
                $logEntry = new ManualLogEntry( 'rights', 'rights' );
                $logEntry->setPerformer( $this->getUser() );
                $logEntry->setTarget( $user->getUserPage() );
@@ -300,6 +314,9 @@ class UserrightsPage extends SpecialPage {
                        '5::newgroups' => $newGroups,
                ] );
                $logid = $logEntry->insert();
+               if ( count( $tags ) ) {
+                       $logEntry->setTags( $tags );
+               }
                $logEntry->publish( $logid );
        }
 
@@ -785,4 +802,3 @@ class UserrightsPage extends SpecialPage {
                return 'users';
        }
 }
-