From 2da101ba2c4771e5d00cb15fbc547981e239fcbf Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Thu, 18 Jun 2009 14:47:18 +0000 Subject: [PATCH] * Remove the two hooks introduced in r52082 * Remove the unused UserrightsChangeableGroups hook introduced in r39368 (1.14) * Fix typo in Special:ListGroupRights introduced in r52083 * Prevent duplicate key display in Special:ListGroupRights (new behavior: if a permission is both assigned and revoked from a group, it only displays as revoked). * Fix $wgRevokePermissions handling, it now runs after every group permission has been assigned in order to revoke the permission properly. --- RELEASE-NOTES | 5 +--- docs/hooks.txt | 30 -------------------- includes/User.php | 4 +++ includes/specials/SpecialListgrouprights.php | 5 ++-- includes/specials/SpecialUserrights.php | 12 +------- 5 files changed, 9 insertions(+), 47 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 046e7526ef..4ba479d2fa 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -40,6 +40,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Oracle: maintenance/ora/user.sql script for creating DB user on oracle with appropriate privileges. Creating this user with web-install page requires oci8.privileged_connect set to On in php.ini. +* Removed UserrightsChangeableGroups hook introduced in 1.14 === New features in 1.16 === @@ -83,10 +84,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * DISPLAYTITLE now accepts a limited amount of wiki markup (the single-quote items) * Special:Search now could search terms in all variant-forms. ONLY apply on wikis with LanguageConverter -* Add hook 'UserrightsGetCheckboxes' to give extensions the ability to modify - the arrangement of checkboxes on the Special:UserRights form -* Add hook 'UserrightsSaveUserGroups' to give extensions the ability to modify - the groups being added and removed last-minute. * Add autopromote condition APCOND_BLOCKED to autopromote blocked users to various user groups. * Add $wgRevokePermissions as a means of restricting a group's rights. The syntax is diff --git a/docs/hooks.txt b/docs/hooks.txt index 7980db0291..ada88d1acc 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1538,36 +1538,6 @@ $user : User object that was changed $add : Array of strings corresponding to groups added $remove: Array of strings corresponding to groups removed -'UserrightsChangeableGroups': allows modification of the groups a user -may add or remove via Special:UserRights -$userrights : UserrightsPage object -$user : User object of the current user -$addergroups : Array of groups that the user is in -&$groups : Array of groups that can be added or removed. In format of - array( - 'add' => array( addablegroups ), - 'remove' => array( removablegroups ), - 'add-self' => array( addablegroups to self ), - 'remove-self' => array( removable groups from self ) - ) - -'UserrightsGroupCheckboxes': allows modification of the display of -checkboxes in the Special:UserRights interface. -$usergroups : Array of groups that the target user belongs to -&$columns : Array of checkboxes, in the form of - $columns['column name']['group name'] = array( - 'set' => is this checkbox checked by default? - 'disabled' => is this checkbox disabled? - 'irreversible' => can this action not be reversed? - ); - -'UserrightsSaveUserGroups': allow extensions to modify the added/removed groups -&$user : User object of the user being altered -$oldGroups : Array of groups that the user is currently in -&$add : Array of groups to add -&$remove : Array of groups to remove -$reason : Summary provided by user on the form - 'UserRetrieveNewTalks': called when retrieving "You have new messages!" message(s) $user: user retrieving new talks messages diff --git a/includes/User.php b/includes/User.php index d57932e1c2..5849ec0b12 100644 --- a/includes/User.php +++ b/includes/User.php @@ -3067,12 +3067,16 @@ class User { static function getGroupPermissions( $groups ) { global $wgGroupPermissions, $wgRevokePermissions; $rights = array(); + // grant every granted permission first foreach( $groups as $group ) { if( isset( $wgGroupPermissions[$group] ) ) { $rights = array_merge( $rights, // array_filter removes empty items array_keys( array_filter( $wgGroupPermissions[$group] ) ) ); } + } + // now revoke the revoked permissions + foreach( $groups as $group ) { if( isset( $wgRevokePermissions[$group] ) ) { $rights = array_diff( $rights, array_keys( array_filter( $wgRevokePermissions[$group] ) ) ); diff --git a/includes/specials/SpecialListgrouprights.php b/includes/specials/SpecialListgrouprights.php index 31476270b2..f8f0362ca4 100644 --- a/includes/specials/SpecialListgrouprights.php +++ b/includes/specials/SpecialListgrouprights.php @@ -127,7 +127,8 @@ class SpecialListGroupRights extends SpecialPage { global $wgLang; $r = array(); foreach( $permissions as $permission => $granted ) { - if( $granted ) { + //show as granted only if it isn't revoked to prevent duplicate display of permissions + if( $granted && ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) ) { $description = wfMsgExt( 'listgrouprights-right-display', array( 'parseinline' ), User::getRightDescription( $permission ), $permission @@ -137,7 +138,7 @@ class SpecialListGroupRights extends SpecialPage { } foreach( $revoke as $permission => $revoked ) { if( $revoked ) { - $description = wfMsgExt( 'lisgrouprights-right-revoked', array( 'parseinline' ), + $description = wfMsgExt( 'listgrouprights-right-revoked', array( 'parseinline' ), User::getRightDescription( $permission ), $permission ); diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 41e7f79feb..22929b17f3 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -196,9 +196,6 @@ class UserrightsPage extends SpecialPage { $oldGroups = $user->getGroups(); $newGroups = $oldGroups; - // Run a hook beforehand to allow extensions to modify the added/removed groups - wfRunHooks( 'UserrightsSaveUserGroups', array( &$user, $oldGroups, &$add, &$remove, $reason ) ); - // remove then add groups if( $remove ) { $newGroups = array_diff($newGroups, $remove); @@ -486,9 +483,6 @@ class UserrightsPage extends SpecialPage { } } - # Run a hook to allow extensions to modify the column listing - wfRunHooks( 'UserrightsGroupCheckboxes', array( $usergroups, &$columns ) ); - # Build the HTML table $ret .= Xml::openElement( 'table', array( 'border' => '0', 'class' => 'mw-userrights-groups' ) ) . "\n"; @@ -548,11 +542,7 @@ class UserrightsPage extends SpecialPage { */ function changeableGroups() { global $wgUser; - $groups = $wgUser->changeableGroups(); - // Run a hook because we can - wfRunHooks( 'UserrightsChangeableGroups', array( $this, - $wgUser, $wgUser->getEffectiveGroups(), &$groups ) ); - return $groups; + return $wgUser->changeableGroups(); } /** -- 2.20.1