cogProvide script oriented APIs to manipulate users and groups
TypeJAR
CategoryAPI
Developed by

XWiki Development Team

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Compatibility

Since 10.8RC1

Description

The user module provides various script oriented APIs. It's also possible to extend it by registering a org.xwiki.script.service.ScriptService component with a hint prefixed with "user.".

Following are the default set of user related APIs:

  • user: $services.user The entry point of this module is the script service with the identifier user which then provide several "sub-script services". It will also contains user related manipulation APIs in the future.
    • group: $services.user.group This script service is dedicated to groups manipulation.

Examples

Member's groups

Get the groups the current user belongs to:

{{velocity}}
##########################
## Get all groups

# Search for the groups in all wikis
#set($allGroupsInAllWikis = $services.user.group.getGroupsFromAllWikis($xcontext.userReference))
# Search for the groups in the same wiki as the user
#set($allGroupsInUserWiki = $services.user.group.getGroupsFromMemberWiki($xcontext.userReference))
# Search for the groups in current wiki
#set($allGroupsInCurrentWiki = $services.user.group.getGroups($xcontext.userReference, $xcontext.database, true))

##########################
## Get only direct groups

# Search for the groups in all wikis
#set($directGroupsInAllWikis = $services.user.group.getGroups($xcontext.userReference, $NULL, false))
# Search for the groups in the same wiki as the user
#set($directGroupsInUserWiki = $services.user.group.getGroups($xcontext.userReference, $xcontext.userReference.wikiReference, false))
# Search for the groups in current wiki
#set($directGroupsInCurrentWiki = $services.user.group.getGroups($xcontext.userReference, $xcontext.database, false))
{{/velocity}}

Group's members

Get the members of some group:

{{velocity}}
# Get all the members by resolving sub-groups
#set($allGroupsInAllWikis = $services.user.group.getMembers('xwiki:XWiki.MyGroup'))

# Get only the direct members
#set($allGroupsInUserWiki = $services.user.group.getMembers('xwiki:XWiki.MyGroup', false))
{{/velocity}}
Tags:
Created by Thomas Mortagne on 2018/09/14 09:52
    

Get Connected