Jack Phoenix has uploaded a new change for review. https://gerrit.wikimedia.org/r/276680
Change subject: GlobalUserrights: synchronize with ShoutWiki's version (1.3-SW) ...................................................................... GlobalUserrights: synchronize with ShoutWiki's version (1.3-SW) * PHP entry point deleted; thus MediaWiki 1.25 or newer is required * extension.json thus added * Fixed fatals in the special page body file when attempting to change a user's global rights * Added the ShoutWiki-specific "fix Special:Statistics so that it displays the correct amount of staff members and global bots" patch. The ShoutWiki-specific patch does nothing on a vanilla MW since the hook which it's hooked to isn't present. To add the hook, edit /includes/SiteStats.php, function numberingroup(), and add the following line before the $wgMemc->set() call: Hooks::run( 'SiteStatsNumberInGroup', array( &$hit, $group ) ); Change-Id: I3f0eeb220af84190017d16fe0d4eff1f3c3bc237 --- D GlobalUserrights.php M GlobalUserrightsHooks.php M GlobalUserrights_body.php A extension.json 4 files changed, 88 insertions(+), 48 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalUserrights refs/changes/80/276680/1 diff --git a/GlobalUserrights.php b/GlobalUserrights.php deleted file mode 100644 index 790f5f3..0000000 --- a/GlobalUserrights.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * GlobalUserrights -- Special page to allow management of global user groups - * - * @file - * @ingroup Extensions - * @author Nathaniel Herman <redw...@yahoo.com> - * @copyright Copyright © 2008 Nathaniel Herman - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later - * @note Some of the code based on stuff by Lukasz 'TOR' Garczewski, as well as SpecialUserrights.php and CentralAuth - */ - -// Extension credits -$wgExtensionCredits['specialpage'][] = array( - 'path' => __FILE__, - 'name' => 'GlobalUserrights', - 'url' => 'https://www.mediawiki.org/wiki/Extension:GlobalUserrights', - 'version' => '1.2', - 'author' => 'Nathaniel Herman', - 'descriptionmsg' => 'gur-desc', -); - -// Set up the new special page -$wgMessagesDirs['GlobalUserrights'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['GlobalUserrightsAlias'] = __DIR__ . '/GlobalUserrights.alias.php'; -$wgAutoloadClasses['GlobalUserrights'] = __DIR__ . '/GlobalUserrights_body.php'; -$wgSpecialPages['GlobalUserrights'] = 'GlobalUserrights'; - -// New user right, required to use Special:GlobalUserrights -$wgAvailableRights[] = 'userrights-global'; -$wgGroupPermissions['staff']['userrights-global'] = true; - -// New log type for global right changes -$wgLogTypes[] = 'gblrights'; -$wgLogNames['gblrights'] = 'gur-rightslog-name'; -$wgLogHeaders['gblrights'] = 'gur-rightslog-header'; -$wgLogActions['gblrights/rights'] = 'gur-rightslog-entry'; - -// Hooked functions -$wgAutoloadClasses['GlobalUserrightsHooks'] = __DIR__ . '/GlobalUserrightsHooks.php'; -$wgHooks['UserEffectiveGroups'][] = 'GlobalUserrightsHooks::onUserEffectiveGroups'; -$wgHooks['SpecialListusersQueryInfo'][] = 'GlobalUserrightsHooks::onSpecialListusersQueryInfo'; \ No newline at end of file diff --git a/GlobalUserrightsHooks.php b/GlobalUserrightsHooks.php index a712ddb..a28d635 100644 --- a/GlobalUserrightsHooks.php +++ b/GlobalUserrightsHooks.php @@ -84,4 +84,24 @@ return true; } + /** + * Fixes Special:Statistics so that the correct amount of global group members + * is shown there. + * + * @param ResultWrapper $hit + * @param string $group User group name + * @return bool + */ + public static function updateStatsForGUR( &$hit, $group ) { + if ( $group == 'staff' || $group == 'globalbot' ) { + $dbr = wfGetDB( DB_SLAVE ); + $hit = $dbr->selectField( + 'global_user_groups', + 'COUNT(*)', + array( 'gug_group' => $group ), + __METHOD__ + ); + } + return true; + } } \ No newline at end of file diff --git a/GlobalUserrights_body.php b/GlobalUserrights_body.php index 7857978..6ec31fd 100644 --- a/GlobalUserrights_body.php +++ b/GlobalUserrights_body.php @@ -1,9 +1,13 @@ <?php /** - * Special:GlobalUserrights, Special:Userrights for global groups + * Special:GlobalUserrights, Special:UserRights for global groups * * @file * @ingroup Extensions + * @author Nathaniel Herman <redw...@yahoo.com> + * @copyright Copyright © 2008 Nathaniel Herman + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + * @note Some of the code based on stuff by Lukasz 'TOR' Garczewski, as well as SpecialUserrights.php and CentralAuth */ class GlobalUserrights extends UserrightsPage { @@ -20,7 +24,7 @@ * @param $reason String: reason */ function doSaveUserGroups( $user, $add, $remove, $reason = '' ) { - $oldGroups = efGURgetGroups( $user ); + $oldGroups = GlobalUserrightsHooks::getGroups( $user ); $newGroups = $oldGroups; // remove then add groups @@ -65,7 +69,7 @@ 'IGNORE' ); } - + function removeGroup( $uid, $group ) { $dbw = wfGetDB( DB_MASTER ); $dbw->delete( @@ -79,7 +83,7 @@ } /** - * Add a gblrights log entry + * Add a gblrights log entry */ function addLogEntry( $user, $oldGroups, $newGroups, $reason ) { $log = new LogPage( 'gblrights' ); @@ -95,9 +99,9 @@ } protected function showEditUserGroupsForm( $user, $groups ) { - // override the $groups that is passed, which will be + // override the $groups that is passed, which will be // the user's local groups - $groups = efGURgetGroups( $user ); + $groups = GlobalUserrightsHooks::getGroups( $user ); parent::showEditUserGroupsForm( $user, $groups ); } diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..b56de1e --- /dev/null +++ b/extension.json @@ -0,0 +1,58 @@ +{ + "name": "GlobalUserrights", + "version": "1.3-SW", + "author": [ + "Nathaniel Herman" + ], + "license-name": "GPL-2.0+", + "url": "https://www.mediawiki.org/wiki/Extension:GlobalUserrights", + "descriptionmsg": "gur-desc", + "type": "specialpage", + "SpecialPages": { + "GlobalUserrights": "GlobalUserrights" + }, + "MessagesDirs": { + "GlobalUserrights": [ + "i18n" + ] + }, + "ExtensionMessagesFiles": { + "GlobalUserrightsAlias": "GlobalUserrights.alias.php" + }, + "AutoloadClasses": { + "GlobalUserrights": "GlobalUserrights_body.php", + "GlobalUserrightsHooks": "GlobalUserrightsHooks.php" + }, + "Hooks": { + "UserEffectiveGroups": [ + "GlobalUserrightsHooks::onUserEffectiveGroups" + ], + "SpecialListusersQueryInfo": [ + "GlobalUserrightsHooks::onSpecialListusersQueryInfo" + ], + "SiteStatsNumberInGroup": [ + "GlobalUserrightsHooks::updateStatsForGUR" + ] + }, + "LogTypes": [ + "gblrights" + ], + "LogNames": { + "gblrights": "gur-rightslog-name" + }, + "LogHeaders": { + "gblrights": "gur-rightslog-header" + }, + "LogActions": { + "gblrights/rights": "gur-rightslog-entry" + }, + "AvailableRights": [ + "userrights-global" + ], + "GroupPermissions": { + "staff": { + "userrights-global": true + } + }, + "manifest_version": 1 +} -- To view, visit https://gerrit.wikimedia.org/r/276680 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3f0eeb220af84190017d16fe0d4eff1f3c3bc237 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GlobalUserrights Gerrit-Branch: master Gerrit-Owner: Jack Phoenix <j...@countervandalism.net> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits