Hello all,
is it possible to read out or output all existing crowd user groups with their corresponding members.
I have made a first attempt via
## Macro title: Listing Confluence groups
## Macro has a body: Y
## Body processing: N
## Output: Unsorted filtered list of confluence groups
##
## Developed by: xxx
## Date created: xx/xx/20xx
## Installed by: xxx
##
## Parameters
## @noparams
#set ($Count = 0)
<h1>User groups</h1>
<hr>
<ul>
#foreach($group in $userAccessor.getGroups())
<li>$group.Name</li>
#set ($Count = $Count + 1)
#end
</ul>
<hr>
<h6>Group count: <b>$Count</b></h6>
started.
Now I would like to replace the previous script with this
## Macro title: Show Group Membership
## Description: List all the members of a group
## Macro has a body: N
##
## Developed by: xxx
## Date created: xx/xx/20xx
## Installed by: xxx
##
## @param Group:title=Group Name|type=string|required=true|desc=Insert group name
#set($containerManagerClass = $action.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null,null))
#set($containerContext = $containerManager.containerContext)
#set($userAccessor = $containerManager.containerContext.getComponent('userAccessor'))
#set($groupManager = $containerManager.containerContext.getComponent("groupManager"))
#set($group = $userAccessor.getGroup($paramGroup))
#set($users = $userAccessor.getMemberNamesAsList($group))
<style type="text/css">
@media all {
.show-group-membership-macro .expand-control {
margin-bottom: 0px;
}
}
</style>
<span class="show-group-membership-macro">
<ac:structured-macro ac:name="expand" ac:schema-version="1">
<ac:parameter ac:name="title">$paramGroup</ac:parameter>
<ac:rich-text-body>
<ul>
#foreach( $username in $users )
#set($confluenceUser = $userAccessor.getUserByName($username))
<li><ac:link>
<ri:user ri:userkey="$confluenceUser.key" />
</ac:link></li>
#end
</ul>
</ac:rich-text-body>
</ac:structured-macro>
</span>
couple. Unfortunately I am missing the approach how to implement this.
Does anyone here have an idea or a little help.
Thanks for your help