X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fuser%2FUserRightsProxy.php;h=d801fa091b8082b6cc5001fe9a1cb7d002f56441;hb=4feb2bd8d6deaee787f11ae8be41c0393934f636;hp=69bc503b111abc410f6da4d9a997ebf623bb3152;hpb=6e67caaca7f22619c69a0f1245467aa63624bf37;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/user/UserRightsProxy.php b/includes/user/UserRightsProxy.php index 69bc503b11..d801fa091b 100644 --- a/includes/user/UserRightsProxy.php +++ b/includes/user/UserRightsProxy.php @@ -198,50 +198,47 @@ class UserRightsProxy { * @return array */ function getGroups() { - $res = $this->db->select( 'user_groups', - [ 'ug_group' ], - [ 'ug_user' => $this->id ], - __METHOD__ ); - $groups = []; - foreach ( $res as $row ) { - $groups[] = $row->ug_group; - } - return $groups; + return array_keys( self::getGroupMemberships() ); } /** - * Replaces User::addUserGroup() - * @param string $group + * Replaces User::getGroupMemberships() + * + * @return array + * @since 1.29 + */ + function getGroupMemberships() { + return UserGroupMembership::getMembershipsForUser( $this->id, $this->db ); + } + + /** + * Replaces User::addGroup() * + * @param string $group + * @param string|null $expiry * @return bool */ - function addGroup( $group ) { - $this->db->insert( 'user_groups', - [ - 'ug_user' => $this->id, - 'ug_group' => $group, - ], - __METHOD__, - [ 'IGNORE' ] ); + function addGroup( $group, $expiry = null ) { + if ( $expiry ) { + $expiry = wfTimestamp( TS_MW, $expiry ); + } - return true; + $ugm = new UserGroupMembership( $this->id, $group, $expiry ); + return $ugm->insert( true, $this->db ); } /** - * Replaces User::removeUserGroup() - * @param string $group + * Replaces User::removeGroup() * + * @param string $group * @return bool */ function removeGroup( $group ) { - $this->db->delete( 'user_groups', - [ - 'ug_user' => $this->id, - 'ug_group' => $group, - ], - __METHOD__ ); - - return true; + $ugm = UserGroupMembership::getMembership( $this->id, $group, $this->db ); + if ( !$ugm ) { + return false; + } + return $ugm->delete( $this->db ); } /**