Forums de discussion
method to delete a line from users_groups
asile elisa, modifié il y a 14 années.
method to delete a line from users_groups
Regular Member Publications: 126 Date d'inscription: 17/02/10 Publications récentes
hi everyone,
I added a new community Mycommunity and I find it in group table
I find haw to add a user in this community :it is done by the method
and this method added a line in the table users_groups this table mapped a user with a particular group
but I did not find how to delete this assignment
thanks in advance
I added a new community Mycommunity and I find it in group table
I find haw to add a user in this community :it is done by the method
UserServiceUtil.addGroupUsers(idGroup, addUserIds);
and this method added a line in the table users_groups this table mapped a user with a particular group
but I did not find how to delete this assignment
thanks in advance
Sandeep Nair, modifié il y a 14 années.
RE: method to delete a line from users_groups
Liferay Legend Publications: 1744 Date d'inscription: 06/11/08 Publications récentes
Hi,
Try this
Regards,
Sandeep
Try this
UserServiceUtil.unsetGroupUsers(groupId,userIds);
Regards,
Sandeep
asile elisa, modifié il y a 14 années.
RE: method to delete a line from users_groups
Regular Member Publications: 126 Date d'inscription: 17/02/10 Publications récentes
thanks it works ;)
asile elisa, modifié il y a 14 années.
RE: method to delete a line from users_groups
Regular Member Publications: 126 Date d'inscription: 17/02/10 Publications récentes
hi,
do you have an idea how can I update a line or I will have to remove it and recreat it?
thanks in advance.
do you have an idea how can I update a line or I will have to remove it and recreat it?
thanks in advance.
Ivan Cheung, modifié il y a 14 années.
RE: method to delete a line from users_groups
Regular Member Publications: 113 Date d'inscription: 20/06/06 Publications récentesasile elisa:
hi,
do you have an idea how can I update a line or I will have to remove it and recreat it?
thanks in advance.
Hmm, what exactly do you mean by "update a line"?
asile elisa, modifié il y a 14 années.
RE: method to delete a line from users_groups
Regular Member Publications: 126 Date d'inscription: 17/02/10 Publications récentes
hi,
I mean to change the assignement, change the user community,
change the idGroup for a particular user
thanks
I mean to change the assignement, change the user community,
change the idGroup for a particular user
thanks
Ivan Cheung, modifié il y a 14 années.
RE: method to delete a line from users_groups
Regular Member Publications: 113 Date d'inscription: 20/06/06 Publications récentes
You can use:
If you look at the implementation you'll see that the logic unsets old groups and adds new groups.
UserLocalServiceUtil.updateGroups(long userId, long[] newGroupIds)
If you look at the implementation you'll see that the logic unsets old groups and adds new groups.
for (Group oldGroup : oldGroups) {
long oldGroupId = oldGroup.getGroupId();
oldGroupIds.add(oldGroupId);
if (!ArrayUtil.contains(newGroupIds, oldGroupId)) {
unsetGroupUsers(oldGroupId, new long[] {userId});
}
}
for (long newGroupId : newGroupIds) {
if (!oldGroupIds.contains(newGroupId)) {
addGroupUsers(newGroupId, new long[] {userId});
}
}
asile elisa, modifié il y a 14 années.
RE: method to delete a line from users_groups
Regular Member Publications: 126 Date d'inscription: 17/02/10 Publications récentes
thank you
but I have an older version I use liferay 4.2 and I did not find this method in UserLocalServiceUtil.
but I have an older version I use liferay 4.2 and I did not find this method in UserLocalServiceUtil.
Ivan Cheung, modifié il y a 14 années.
RE: method to delete a line from users_groups
Regular Member Publications: 113 Date d'inscription: 20/06/06 Publications récentes
Sorry, if the equivalent method is not available in 4.2, then you'll just have to do it the long way by unsetting and adding groups for each user.
Another option is if you extend the 4.2 version of UserLocalServiceImpl in the EXT environment to create an upgradeGroups equivalent.
Another option is if you extend the 4.2 version of UserLocalServiceImpl in the EXT environment to create an upgradeGroups equivalent.