Skip to content

Instantly share code, notes, and snippets.

@02strich
Created February 28, 2014 08:53
Show Gist options
  • Save 02strich/9267630 to your computer and use it in GitHub Desktop.
Save 02strich/9267630 to your computer and use it in GitHub Desktop.
Confluence People List User Macro
## Macro title: People List
## Macro has a body: N
## Body processing: no body
## Output: Selected output option
##
## Developed by: Stefan Richter
## Date created: 28/02/2014
## Installed by: Stefan Richter
## This is the people list
## @noparams
#set($containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null,null))
#set($containerContext = $containerManager.containerContext)
#set($userDetailsManager = $containerContext.getComponent('userDetailsManager'))
<table>
<tbody>
<tr>
<th>Photo</th>
<th>Name</th>
<th>Department</th>
<th>Location</th>
<th>Office Phone</th>
<th>Skype</th>
</tr>
#foreach ($username in $userAccessor.getUserNamesWithConfluenceAccess())
#set ($fullName = "-")
#set ($email = "-")
#set ($phone = "-")
#set ($department = "-")
#set ($location = "-")
#set ($im = "-")
#set ($user = $userAccessor.getUserByName($username))
#set ($fullName = $user.getFullName())
#set ($email = $user.getEmail())
#set ($phone = $userDetailsManager.getStringProperty($user, "phone"))
#set ($department = $userDetailsManager.getStringProperty($user, "department"))
#set ($location = $userDetailsManager.getStringProperty($user, "location"))
#set ($im = $userDetailsManager.getStringProperty($user, "im"))
#set($userPicture = $userAccessor.getUserProfilePicture($user).getDownloadPath())
#set($userPicIsDefault = $userAccessor.getUserProfilePicture($user).isDefault())
#if($username != "admin")
<tr>
<td>
#if(!$userPicIsDefault)
<a class="confluence-userlink rw_profile_picture" href="$req.contextPath/display/~$username" data-username="$username" title="" >
<img class="userLogo logo" title="" alt="User icon: $username" src="$req.contextPath$userPicture">
</a>
#elseif($currentUser.name == $username) ## Check if user == logged in user
<a class="confluence-userlink rw_profile_picture" href="$req.contextPath/users/editmyprofilepicture.action" data-username="$username" title="" >
<img class="userLogo logo" title="" alt="User icon: $username" src="$req.contextPath/images/icons/profilepics/add_profile_pic.png">
</a>
#else
<a class="confluence-userlink rw_profile_picture" href="$req.contextPath/display/~$username" data-username="$username" title="" >
<img class="userLogo logo" title="" alt="User icon: $username" src="$req.contextPath$userPicture">
</a>
#end
</td>
<td><a href="mailto:$email">$fullName</a></td>
<td>$department</td>
<td>$location</td>
<td>$phone</td>
<td>$im</td>
</tr>
#end
#end
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment