dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "mediawiki.action.edit: Move collapsibleFooter cookies to localStorage"
[lhc/web/wiklou.git]
/
includes
/
user
/
UserRightsProxy.php
diff --git
a/includes/user/UserRightsProxy.php
b/includes/user/UserRightsProxy.php
index
09244a4
..
d801fa0
100644
(file)
--- a/
includes/user/UserRightsProxy.php
+++ b/
includes/user/UserRightsProxy.php
@@
-198,50
+198,47
@@
class UserRightsProxy {
* @return array
*/
function getGroups() {
* @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
*/
* @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 ) {
* @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 );
}
/**
}
/**
@@
-273,15
+270,20
@@
class UserRightsProxy {
* Replaces User::touchUser()
*/
function invalidateCache() {
* Replaces User::touchUser()
*/
function invalidateCache() {
- $this->db->update( 'user',
+ $this->db->update(
+ 'user',
[ 'user_touched' => $this->db->timestamp() ],
[ 'user_id' => $this->id ],
[ 'user_touched' => $this->db->timestamp() ],
[ 'user_id' => $this->id ],
- __METHOD__ );
+ __METHOD__
+ );
$wikiId = $this->db->getWikiID();
$userId = $this->id;
$wikiId = $this->db->getWikiID();
$userId = $this->id;
- $this->db->onTransactionPreCommitOrIdle( function() use ( $wikiId, $userId ) {
- User::purge( $wikiId, $userId );
- } );
+ $this->db->onTransactionPreCommitOrIdle(
+ function () use ( $wikiId, $userId ) {
+ User::purge( $wikiId, $userId );
+ },
+ __METHOD__
+ );
}
}
}
}