public function execute( $par ) {
$user = $this->getUser();
$request = $this->getRequest();
+ $session = $request->getSession();
$out = $this->getOutput();
if ( $par !== null ) {
$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;
}
// 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(
$targetUser
);
+ // Set session data for the success message
+ $session->set( 'specialUserrightsSaveSuccess', 1 );
+
$out->redirect( $this->getSuccessURL() );
return;
}
function getSuccessURL() {
- return $this->getPageTitle( $this->mTarget )->getFullURL( [ 'success' => 1 ] );
+ return $this->getPageTitle( $this->mTarget )->getFullURL();
}
/**
* @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();
$groups )
);
+ Hooks::run( 'ChangeUserGroups', [ $this->getUser(), $user, &$add, &$remove ] );
+
$oldGroups = $user->getGroups();
$newGroups = $oldGroups;
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 ];
* @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() );
'5::newgroups' => $newGroups,
] );
$logid = $logEntry->insert();
+ if ( count( $tags ) ) {
+ $logEntry->setTags( $tags );
+ }
$logEntry->publish( $logid );
}
return 'users';
}
}
-