Group Members in Velocity

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Group Members in Velocity

bruno.amaro
This post has NOT been accepted by the mailing list yet.
Hi

I`m trying to figure a way to check if a user is a member of one group.
I`m looking for something like:

a) retrieve the groups membership of an user in velocity
 
or

b) check if a user is a member of a specify group.


Thanks in advance
Regards,
Bruno
Reply | Threaded
Open this post in threaded view
|

Re: Group Members in Velocity

Tronicek
This post has NOT been accepted by the mailing list yet.
You are looking for something like:
#if($xwiki.getUser("XWiki.Admin").isUserInGroup("XWiki.XWikiAllGroup"))
...
#end

Check the API of your XWiki (http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki-core-1.8.1-javadoc.zip), please.

Here a snippet where the prefix "XWiki." is handled in Velocity. Only the user login name and group name has to be entered.

Have fun,
Rudi


#if(($request.action) && ($request.action == 'CheckGroupMembership'))

#set($group = "XWiki.${request.group}")
#set($user = "XWiki.${request.user}")
#if($xwiki.getUser($user).isUserInGroup($group))
User $user IS in group $group
#else
User $user IS NOT in group $group
#end

#end

1 Check Group Membership

<form action="$doc.getURL("view")" method="post">
<input type="hidden" name="action" value="null" />
Group:<input type="text" name="group" value="$!request.group" size="60" />
User:<input type="text" name="user" value="$!request.user" size="60" />
<input type="submit" value="Check Group Membership" onclick="document.getElementById('bequiet').style.visibility='visible';this.form.action.value='CheckGroupMembership'" />

<div id="bequiet" style="visibility:hidden">

busy...

</div>
</form>


bruno.amaro wrote
Hi

I`m trying to figure a way to check if a user is a member of one group.
I`m looking for something like:

a) retrieve the groups membership of an user in velocity
 
or

b) check if a user is a member of a specify group.


Thanks in advance
Regards,
Bruno
Reply | Threaded
Open this post in threaded view
|

Re: Group Members in Velocity

bruno.amaro
Thanks!

It works like a charm ;)


Tronicek wrote
You are looking for something like:
#if($xwiki.getUser("XWiki.Admin").isUserInGroup("XWiki.XWikiAllGroup"))
...
#end

Check the API of your XWiki (http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki-core-1.8.1-javadoc.zip), please.

Here a snippet where the prefix "XWiki." is handled in Velocity. Only the user login name and group name has to be entered.

Have fun,
Rudi


#if(($request.action) && ($request.action == 'CheckGroupMembership'))

#set($group = "XWiki.${request.group}")
#set($user = "XWiki.${request.user}")
#if($xwiki.getUser($user).isUserInGroup($group))
User $user IS in group $group
#else
User $user IS NOT in group $group
#end

#end

1 Check Group Membership

<form action="$doc.getURL("view")" method="post">
<input type="hidden" name="action" value="null" />
Group:<input type="text" name="group" value="$!request.group" size="60" />
User:<input type="text" name="user" value="$!request.user" size="60" />
<input type="submit" value="Check Group Membership" onclick="document.getElementById('bequiet').style.visibility='visible';this.form.action.value='CheckGroupMembership'" />

<div id="bequiet" style="visibility:hidden">

busy...

</div>
</form>


bruno.amaro wrote
Hi

I`m trying to figure a way to check if a user is a member of one group.
I`m looking for something like:

a) retrieve the groups membership of an user in velocity
 
or

b) check if a user is a member of a specify group.


Thanks in advance
Regards,
Bruno