* @file
*/
+use Wikimedia\Rdbms\IDatabase;
+
/**
* Cut-down copy of User interface for local-interwiki-database
* user rights manipulation.
class UserRightsProxy {
/**
- * Constructor.
- *
* @see newFromId()
* @see newFromName()
* @param IDatabase $db Db connection
* @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() );
}
/**
* @since 1.29
*/
function getGroupMemberships() {
- $res = $this->db->select( 'user_groups',
- UserGroupMembership::selectFields(),
- [ 'ug_user' => $this->id ],
- __METHOD__ );
- $ugms = [];
- foreach ( $res as $row ) {
- $ugms[$row->ug_group] = UserGroupMembership::newFromRow( $row );
- }
- return $ugms;
+ return UserGroupMembership::getMembershipsForUser( $this->id, $this->db );
}
/**
__METHOD__
);
- $wikiId = $this->db->getWikiID();
+ $domainId = $this->db->getDomainID();
$userId = $this->id;
$this->db->onTransactionPreCommitOrIdle(
- function () use ( $wikiId, $userId ) {
- User::purge( $wikiId, $userId );
+ function () use ( $domainId, $userId ) {
+ User::purge( $domainId, $userId );
},
__METHOD__
);