It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

User macro help Edited

This macro is designed to show a list of all users with brief information, such as a photo, full name, email, position and department.

Everything worked on 6.15.1 but with the upgrade to 7.1.1 the position and department stopped working. I dug through all the release notes, but did not find what changed. Any help would be appreciated

 

## @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'))
#set($personalInformationManager = $containerContext.getComponent('personalInformationManager'))
#set($wikiStyleRenderer = $containerContext.getComponent('wikiStyleRenderer'))
#set($loginManager = $containerContext.getComponent('loginManager'))
#set($crowdService = $containerContext.getComponent('crowdService'))
#set($conf_users = $userAccessor.getGroup("confluence-users"))
#set($users = $userAccessor.getMemberNames($conf_users))
#set($bots = ['admin','conf_adm','root','gdadmin'])
#set($count = 0)

#foreach($user in $users)
#if ($bots.contains($user))
##special user/bot
#else
#set($count = $count + 1)
#set($userN = $userAccessor.getUser($user))
#set($crowdUser = $crowdService.getUser($userN.name))
#set($pi = $personalInformationManager.getPersonalInformation($userN))
#set($renderedAboutMe = $wikiStyleRenderer.convertWikiToXHtml($pi.toPageContext(), $pi.getBodyAsString()))
<div class="sc-user" style="border:1px solid; width: 220px; height: 270px; padding: 10px; text-align: center; margin: 5px; float: left; overflow: auto;">
<img class="userLogo logo" src="$userAccessor.getUserProfilePicture($userN).getUriReference()" alt="User icon: $user" title="" style="height: 128px; width: 128px;" />
<p>#usernameLink($userN.name)</p>
#if ($userDetailsManager.getStringProperty($userN, 'position'))
<p>$userDetailsManager.getStringProperty($userN, 'position')</p>
#else
<p style="color:red">No position</p>
#end

#if ($userDetailsManager.getStringProperty($userN, 'department'))
<p>$userDetailsManager.getStringProperty($userN, 'department')</p>
#else
<p style="color:red">No department</p>
#end

##<p>$userAccessor.getPropertySet($user))</p>
##<p>$renderedAboutMe</p>

<p>$action.dateFormatter.formatGivenString('yyyy/MM/dd', $crowdUser.createdDate)</p>
</div>
#end
#end

<p style="clear:both;padding:10px">Total users: $count.</p>

 

1 answer

I would guess you are using a class that was deprecated in the 7.x release. Check out these links..

https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/

https://confluence.atlassian.com/doc/preparing-for-confluence-7-0-950280675.html 

https://docs.atlassian.com/ConfluenceServer/rest/7.2.0/

https://docs.atlassian.com/ConfluenceServer/javadoc/7.2.0/

Check with your system admin if that is not you to see if you also upgraded Java to 11. Shouldn't affect anything but worth a look.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What project did you transition or start on Confluence with the shift to remote work?

It’s been great to hear from fellow users over the last few weeks about the best tips and fun moments you’ve had working on Confluence since the transition to working remote. I’d love to keep the c...

159 views 3 8
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you