Alex Monk has uploaded a new change for review. https://gerrit.wikimedia.org/r/51786
Change subject: Bug 27551: Allow renaming of global groups ...................................................................... Bug 27551: Allow renaming of global groups Requires JavaScript. Change-Id: Iac3f0fa6df4d8c6b84449fca241ef5819019a22f --- M CentralAuth.i18n.php M CentralAuth.php A modules/ext.centralauth.globalgrouppermissions.js M specials/SpecialGlobalGroupPermissions.php 4 files changed, 48 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth refs/changes/86/51786/1 diff --git a/CentralAuth.i18n.php b/CentralAuth.i18n.php index 9e8be82..101c56a 100644 --- a/CentralAuth.i18n.php +++ b/CentralAuth.i18n.php @@ -285,6 +285,7 @@ 'centralauth-rightslog-entry-groupperms' => 'changed group permissions for $1 from $2 to $3', 'centralauth-rightslog-entry-groupperms2' => 'changed group permissions for $1. Added $2; Removed $3', 'centralauth-rightslog-entry-groupperms3' => 'changed group restricted wikis set for $1 from $2 to $3', + 'centralauth-rightslog-entry-grouprename' => 'renamed group $1 to $2', 'centralauth-rightslog-header' => 'This log contains operations on global groups: membership and permissions changes', 'centralauth-rightslog-entry-newset' => 'created $2 wiki set $1 with following wikis: $3', @@ -703,6 +704,9 @@ * $1 - the name of the group being changed * $2 - the name of the previous wiki set * $3 - the name of the new wiki set', + 'centralauth-rightslog-entry-grouprename' => 'A log entry when a user changes the name of a global group. +* $1 is the original name of the group +* $2 is the new name of the group', 'centralauth-rightslog-entry-newset' => "* \$1 is the name of the wiki set (example: \"''Test''\") * \$2 is \"''{{msg-mw|Centralauth-rightslog-set-optin}}''\" or \"''{{msg-mw|Centralauth-rightslog-set-optout}}''\" * \$3 is a list of wikis (example: \"''srwiki, hrwiki''\")", diff --git a/CentralAuth.php b/CentralAuth.php index 451dffb..51c9401 100644 --- a/CentralAuth.php +++ b/CentralAuth.php @@ -269,6 +269,7 @@ $wgLogActions['gblrights/groupperms'] = 'centralauth-rightslog-entry-groupperms'; $wgLogActions['gblrights/groupprms2'] = 'centralauth-rightslog-entry-groupperms2'; $wgLogActions['gblrights/groupprms3'] = 'centralauth-rightslog-entry-groupperms3'; +$wgLogActions['gblrights/grouprename'] = 'centralauth-rightslog-entry-grouprename'; foreach ( array( 'newset', 'setrename', 'setnewtype', 'setchange', 'deleteset' ) as $type ) { $wgLogActionsHandlers["gblrights/{$type}"] = 'efHandleWikiSetLogEntry'; @@ -312,6 +313,7 @@ 'styles' => 'ext.centralauth.globalusers.css', ) + $commonModuleInfo; $wgResourceModules['ext.centralauth.globalgrouppermissions'] = array( + 'scripts' => 'ext.centralauth.globalgrouppermissions.js', 'styles' => 'ext.centralauth.globalgrouppermissions.css', ) + $commonModuleInfo; diff --git a/modules/ext.centralauth.globalgrouppermissions.js b/modules/ext.centralauth.globalgrouppermissions.js new file mode 100644 index 0000000..3d6c8c3 --- /dev/null +++ b/modules/ext.centralauth.globalgrouppermissions.js @@ -0,0 +1,7 @@ +( function ( $ ) { + $( document ).ready( function () { + $( '#ca-ggp-name-edit' ).click( function () { + $( '#ca-ggp-name' ).html( $( '<input>' ).attr( { 'type': 'text', 'name': 'newname' } ).val( $( '#ca-ggp-name-current' ).text() ) ); + } ); + } ); +}( jQuery ) ); diff --git a/specials/SpecialGlobalGroupPermissions.php b/specials/SpecialGlobalGroupPermissions.php index 1b24193..81bdcfd 100644 --- a/specials/SpecialGlobalGroupPermissions.php +++ b/specials/SpecialGlobalGroupPermissions.php @@ -132,7 +132,13 @@ $fields = array(); - $fields['centralauth-editgroup-name'] = $group; + if ( $editable ) { + $fields['centralauth-editgroup-name'] = '<div id="ca-ggp-name"><span id="ca-ggp-name-current">' . $group . '</span> ' . $this->msg( 'parentheses', '<a id="ca-ggp-name-edit" href="#">edit</a>' )->plain() . '</div>'; + $this->getOutput()->addModules( 'ext.centralauth.globalgrouppermissions' ); + } else { + $fields['centralauth-editgroup-name'] = $group; + } + if( $this->getUser()->isAllowed( 'editinterface' ) ) { # Show edit link only to user with the editinterface right $fields['centralauth-editgroup-display'] = $this->msg( 'centralauth-editgroup-display-edit', $group, User::getGroupName( $group ) )->parse(); @@ -299,6 +305,34 @@ $this->invalidateRightsCache( $group ); + $newname = $this->getRequest()->getVal( 'newname' ); + if ( !is_null( $newname ) && $group != $newname ) { + // Global group rename + $dbw = CentralAuthUser::getCentralDB(); + $updates = array( + 'global_group_permissions' => 'ggp_group', + 'global_group_restrictions' => 'ggr_group', + 'global_user_groups' => 'gug_user' + ); + + foreach ( $updates as $table => $field ) { + $dbw->update( + $table, + array( $field => $newname ), + array( $field => $group ), + __METHOD__ + ); + } + + ( new LogPage( 'gblrights' ) )->addEntry( 'grouprename', + SpecialPage::getTitleFor( 'GlobalUsers', $group ), + $reason, + array( $newname ) + ); + } + + $this->invalidateRightsCache( $group ); + // Display success $this->getOutput()->setSubTitle( $this->msg( 'centralauth-editgroup-success' ) ); $this->getOutput()->addWikiMsg( 'centralauth-editgroup-success-text', $group ); -- To view, visit https://gerrit.wikimedia.org/r/51786 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iac3f0fa6df4d8c6b84449fca241ef5819019a22f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CentralAuth Gerrit-Branch: master Gerrit-Owner: Alex Monk <kren...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits