Skip to content

Instantly share code, notes, and snippets.

@dvdsmpsn
Last active May 4, 2021 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvdsmpsn/9d517231c6140247bd88f9dc9a6c4a91 to your computer and use it in GitHub Desktop.
Save dvdsmpsn/9d517231c6140247bd88f9dc9a6c4a91 to your computer and use it in GitHub Desktop.
## Macro title: user-pictures-for-group
## Macro has a body: Y or N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: David Simpson <usermacros@davidsimpson.me>
## Date created: 2014-06-18
## Installed by: *****My Name*****
##
## Users Pictures for Group - Confluence User Macro
##
## Produces a pile of user profile pictures for members of a specific group
##
## WARNING:
##
## Use very sparingly as this *will* slow down large Confluence instances.
## Yes, it will try to print out 100,000 users if you have that many in the group
##
## I generally remove this user macro after using once and add only when needed.
## Or enable it for admins only.
##
## @param Group:title=Group Name|type=string|required=true|desc=The group name (yes, really)
#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 = $groupManager.getGroup($paramGroup))
#set($users = $userAccessor.getMemberNamesAsList($group) )
<h2>Users in group <strong>$paramGroup</strong></h2>
#foreach($username in $users)
$username
#set($confluenceUser = $userAccessor.getUserByName($username))
<ac:structured-macro ac:name="profile-picture">
<ac:parameter ac:name="User">
<ri:user ri:userkey="$confluenceUser.key" />
</ac:parameter>
</ac:structured-macro>
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment