| Index: trunk/phase3/docs/hooks.txt |
| — | — | @@ -1757,6 +1757,11 @@ |
| 1758 | 1758 | $ip: IP of the user who sent the message out |
| 1759 | 1759 | $u: the account whose new password will be set |
| 1760 | 1760 | |
| | 1761 | +'UserAddGroup': called when adding a group; return false to override |
| | 1762 | +stock group addition. |
| | 1763 | +$user: the user object that is to have a group added |
| | 1764 | +$group: the group to add |
| | 1765 | + |
| 1761 | 1766 | 'UserArrayFromResult': called when creating an UserArray object from a |
| 1762 | 1767 | database result |
| 1763 | 1768 | &$userArray: set this to an object to override the default object returned |
| — | — | @@ -1884,6 +1889,11 @@ |
| 1885 | 1890 | $inject_html: Any HTML to inject after the "logged out" message. |
| 1886 | 1891 | $oldName: name of the user before logout (string) |
| 1887 | 1892 | |
| | 1893 | +'UserRemoveGroup': called when removing a group; return false to override |
| | 1894 | +stock group removal. |
| | 1895 | +$user: the user object that is to have a group removed |
| | 1896 | +$group: the group to be removed |
| | 1897 | + |
| 1888 | 1898 | 'UserRights': After a user's group memberships are changed |
| 1889 | 1899 | $user : User object that was changed |
| 1890 | 1900 | $add : Array of strings corresponding to groups added |
| Index: trunk/phase3/includes/User.php |
| — | — | @@ -2160,17 +2160,18 @@ |
| 2161 | 2161 | * @param $group String Name of the group to add |
| 2162 | 2162 | */ |
| 2163 | 2163 | function addGroup( $group ) { |
| 2164 | | - $dbw = wfGetDB( DB_MASTER ); |
| 2165 | | - if( $this->getId() ) { |
| 2166 | | - $dbw->insert( 'user_groups', |
| 2167 | | - array( |
| 2168 | | - 'ug_user' => $this->getID(), |
| 2169 | | - 'ug_group' => $group, |
| 2170 | | - ), |
| 2171 | | - __METHOD__, |
| 2172 | | - array( 'IGNORE' ) ); |
| | 2164 | + if( wfRunHooks( 'UserAddGroup', array( &$this, &$group ) ) ) { |
| | 2165 | + $dbw = wfGetDB( DB_MASTER ); |
| | 2166 | + if( $this->getId() ) { |
| | 2167 | + $dbw->insert( 'user_groups', |
| | 2168 | + array( |
| | 2169 | + 'ug_user' => $this->getID(), |
| | 2170 | + 'ug_group' => $group, |
| | 2171 | + ), |
| | 2172 | + __METHOD__, |
| | 2173 | + array( 'IGNORE' ) ); |
| | 2174 | + } |
| 2173 | 2175 | } |
| 2174 | | - |
| 2175 | 2176 | $this->loadGroups(); |
| 2176 | 2177 | $this->mGroups[] = $group; |
| 2177 | 2178 | $this->mRights = User::getGroupPermissions( $this->getEffectiveGroups( true ) ); |
| — | — | @@ -2185,13 +2186,14 @@ |
| 2186 | 2187 | */ |
| 2187 | 2188 | function removeGroup( $group ) { |
| 2188 | 2189 | $this->load(); |
| 2189 | | - $dbw = wfGetDB( DB_MASTER ); |
| 2190 | | - $dbw->delete( 'user_groups', |
| 2191 | | - array( |
| 2192 | | - 'ug_user' => $this->getID(), |
| 2193 | | - 'ug_group' => $group, |
| 2194 | | - ), __METHOD__ ); |
| 2195 | | - |
| | 2190 | + if( wfRunHooks( 'UserRemoveGroup', array( &$this, &$group ) ) ) { |
| | 2191 | + $dbw = wfGetDB( DB_MASTER ); |
| | 2192 | + $dbw->delete( 'user_groups', |
| | 2193 | + array( |
| | 2194 | + 'ug_user' => $this->getID(), |
| | 2195 | + 'ug_group' => $group, |
| | 2196 | + ), __METHOD__ ); |
| | 2197 | + } |
| 2196 | 2198 | $this->loadGroups(); |
| 2197 | 2199 | $this->mGroups = array_diff( $this->mGroups, array( $group ) ); |
| 2198 | 2200 | $this->mRights = User::getGroupPermissions( $this->getEffectiveGroups( true ) ); |