Apparently this feature is "missing" in 0.9.840. I don't know what's
in
the source versions now.
I got around this problem by assigning privileges for the group to a page,
and then checking for access to that page (less code).
Ludovic sent me the following script, which I believe is a more direct
answer to your question:
Currently there is no xwiki API for groups (it's missing).. But this works:
#set($ismember = false)
#set($groupdoc = $xwiki.getDocument("XWiki.MyGroup"))
#set($memberobj = $groupdoc.getObjects("XWiki.XWikiGroups"))
#foreach($mobj in $memberobj)
#set ($member = $groupdoc.display("member", "view", $mobj))
#if($member == $context.user)
#set($ismember = true)
#end
#end
#if($ismember==true)
do your stuff
#end
Don't forget to flush the cache after changing the members in a group.
It's another "bug" in 0.9.840.
Good luck!
-Nate
-----Original Message-----
From: Jeff Ousley [mailto:jousley@gmail.com]
Sent: Wednesday, June 14, 2006 7:12 AM
To: xwiki-users(a)objectweb.org
Subject: [xwiki-users] check for group membership
Hello,
Is there a way via velocity to check whether or not a user has
membership in a particular group? Could someone provide or point me to
examples of this.
Thanks!
-jeff