Thanks for all the replies! This would really help.

Allen

--------------------------------------------------
From: "Sergiu Dumitriu" <ser...@xwiki.com>
Sent: Tuesday, February 09, 2010 1:32 AM
To: "XWiki Users" <users@xwiki.org>
Subject: Re: [xwiki-users] XWikiAllGroup

> On 02/08/2010 06:18 PM, Guillaume Lerouge wrote:
>> Hi Allen,
>>
>> On Mon, Feb 8, 2010 at 6:03 PM, J. Allen Q. Santos<jqsan...@msn.com> 
>> wrote:
>>
>>> Hi,
>>>
>>> how do I manually add a user in XWikiAllGroup using Java Code?
>>> Thanks in advance.
>>>
>>
>> It's the same thing as programatically adding an object to a page and
>> setting its properties. In velocity you would do:
>>
>> #set($allgroupdoc = $xwiki.getDocument('XWiki.XWikiAllGroup'))
>> #set($newuseringroup = $doc.getObject('XWiki.XWikiGroups', true))
>
> No, that's wrong, getObject will return an existing object, which means
> that it will replace an existing member with the new one.
>
> XWikiDocument doc = xwiki.getDocument("XWiki.XWikiAllGroup", context);
> if (doc.getObject("XWiki.XWikiGroups", "member", userDocName) == null) {
>     BaseObject obj = doc.newObject("XWiki.XWikiGroups"));
>     obj.set("member", userDocName, context);
>     xwiki.save(doc, context);
> }
>
>> $newuseringroup.set('member', 'XWiki.UserName')
>> $allgroupdoc.save()
>>
>> Or something similar.
>>
>> Guillaume
>
>
> -- 
> Sergiu Dumitriu
> http://purl.org/net/sergiu/
> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
> 
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to