I would like to create a user-macro to get on start-page of the space an overview of keyusers and users.
user: can everything, but can’t do administrative tasks, can’t set/change permissions
keyuser: can everything, but can’t do administrative task, can set/change permissions
admin: can everything
I have only small spaces (20 Users for each).
So I would like to work with the permissionhelper and will show keyusers by filtering user objects which having right to “canSetPermissions” but which are no confluenceadministrators (to filter out Superuser).
So find my “quick & dirty” code below.
The problem: I was Setting permissions to a Group (keyuser) and add user to this group. But the permissionHelber didn’t resolve the activated option “can set permissions”
#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($users = $userAccessor.getUsers()) #set($spaces = $spaceManager.getAllSpaces()) <table class="aui"> <tr> <th class="confluenceTh">KeyUser</th> </tr> #foreach($spacer in $spaces) #if ($spacer.key == $space.key) #foreach($user in $users) #if ($permissionHelper.canSetPermissions($user, $spacer) and not $permissionHelper.isConfluenceAdministrator($user)) <tr> <td class="confluenceTd">#usernameLink($user.name)</td> </tr> #else #end #end #end #end </table>