User macro now displays user name instead of full name
Asked by Patrick Vanhoof:

After we upgraded to version 7.19.7 the result of a user macro has changed, namely it now shows the user name instead of the full name.

The macro code is the following:

## Macro title: Space Administrators  
## Macro has a body: N  
## Body processing: Selected body processing option  
## Output: Selected output option  
##  
## Developed by: Andrew Frayling  
## Date created: 21/03/2012  
## Installed by: \&lt;your name\&gt;  
## Macro to display a list of user that are able to administer the current space.  
## @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($loginManager = $containerContext.getComponent('loginManager'))  
#set($users = $userAccessor.getUsers())

\<table class="confluenceTable"\>  
\<tr\>  
\<th class="confluenceTh"\>Beheerders\</th\>  
\</tr\>

#foreach ($permission in $space.getPermissions())  
#if ($permission.isUserPermission() \&\& $permission.getType() == "SETSPACEPERMISSIONS")  
\<tr\>  
\<td class="confluenceTd"\>#usernameLink($permission.getUserName())\</td\>  
\</tr\>  
#end  
#end  
\</table\>

Where before the upgrade it would display 'Patrick Vanhoof' as a result of the macro, it now shows 'PVanhoof'.

Why?


Answers:
author: Fabio Racobaldo _Herzum_
body: Hey [@Patrick Vanhoof](/t5/user/viewprofilepage/user-id/1131759) ,

try to substitute the following row:

```
...
<td class="confluenceTd">#usernameLink($permission.getUserName())</td>
...
```

with :

```
...
<td class="confluenceTd">#usernameLink($permission.https://docs.atlassian.com/atlassian-confluence/6.1.1/com/atlassian/confluence/security/SpacePermission.html#getUserSubject--`()`.getFullName() )</td>
...
```

Hope this helps,

Fabio

comments: author: Patrick Vanhoof
body: Thanks a lot!


author: Fabio Racobaldo _Herzum_
body: you're welcome [@Patrick Vanhoof](/t5/user/viewprofilepage/user-id/1131759) ;)


author: Ulrich Hinze
body: In this context I found the one which we are using which is slightly different. It also shows the groups and their members which are having access.

Now the macro editor shows the following:

"User Macro **users-in-space** may use context keys **\[** userAccessor **\]** which are not set in system property **macro.required.velocity.context.keys** . If the macro is not rendered as expected, try to manually add those keys into the system property."

This is the code for the group extension which is affected by the message above:

```
#if($paramShowGroups == true)
<h2>Gruppen ... </h2>
#if($paramListUsers == true)
#foreach ($permission in $space.getPermissions())
#if ($permission.isGroupPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
#set ( $groupString = $permission.getGroup() )
#set ( $groupObject = $userAccessor.getGroup($groupString) )
#set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )
<h3>$groupString</h3>
<table class="confluenceTable">
<tr>
<th class="confluenceTh">... mit Administratorrechten</th>
</tr>
#foreach ($member in $memberList)
<tr>
<td class="confluenceTd">#usernameLink($member)</td>
</tr>
#end
</table>
#end
#end
#foreach ($permission in $space.getPermissions())
#if ($permission.isGroupPermission() && $permission.getType() == "VIEWSPACE")
#set ( $groupString = $permission.getGroup() )
#set ( $groupObject = $userAccessor.getGroup($groupString) )
#set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )
<h3>$groupString</h3>
<table class="confluenceTable">
<tr>
<th class="confluenceTh">... ohne Administratorrechte</th>
</tr>
#foreach ($member in $memberList)
<tr>
<td class="confluenceTd">#usernameLink($member)</td>
</tr>
#end
</table>
#end
#end
#else
#foreach ($permission in $space.getPermissions())
#if ($permission.isGroupPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
#set ( $groupString = $permission.getGroup() )
#set ( $groupObject = $userAccessor.getGroup($groupString) )
<li>$groupString</li>
#end
#end
#foreach ($permission in $space.getPermissions())
#if ($permission.isGroupPermission() && $permission.getType() == "VIEWSPACE")
#set ( $groupString = $permission.getGroup() )
#set ( $groupObject = $userAccessor.getGroup($groupString) )
<li>$groupString</li>
#end
```

Now the question for me is, how to "*manually add those keys into the system property.*"

Any help would be appreciated.

Thanks

Uli


author: Charles Pikscher
body: See <https://developer.atlassian.com/server/confluence/confluence-objects-accessible-from-velocity/>


author: Ulrich Hinze
body: Oh btw. we got it fixed the way it was described above. Our system administrator added the missing velocity key into teh system properties and now it works fine again.


Tags: confluence-server

server