Hi All,
as a Confluence admin I need to achieve an overview. Hence, we have already more than 140 different spaces and 3 times more groups, it's very cumbersome to overview the space permissions, groups and users.
I'd liket to implement a macro which display the groups, permissions and users of each spaces, this way:
SpaceA
group1
permission(s) of the group in this space: e.g. VIEWONLY, ADMIN, etc.
user list of this group
group2
permission(s) of the group in this space: e.g. VIEWONLY, ADMIN, etc.
user list of this group
.....
SpaceB
groupX
permission(s) of the group in this space: e.g. VIEWONLY, ADMIN, etc.
user list of this group
.....
So, this macro would be on a page especially serves the admins to have an overview.
I got several macro code yet, which are give solutions for these features but apart:
This macro displays the groups and the group's user list of a space:
#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">Space Administrators</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() == "COMMENT")
#set ( $groupString = $permission.getGroup() )
#set ( $groupObject = $userAccessor.getGroup($groupString) )
#set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )
<h3>$groupString</h3>
<table class="confluenceTable">
<tr>
<th class="confluenceTh">Space Administrators</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() == "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">Space Administrators</th>
</tr>
#foreach ($member in $memberList)
<tr>
<td class="confluenceTd">#usernameLink($member)</td>
</tr>
#end
</table>
#end
#end
This macro list the groups with all the spaces having access to:
<h1>Groups</h1>
## get all the groups
#set ( $allGroups = $userAccessor.getGroupsAsList() )
## get all the spaces
#set ( $allSpaces = $spaceManager.getAllSpaces() )
#foreach ($group in $allGroups)
<h2>$group</h2>
#foreach ($space in $allSpaces)
<h3>$space.getName()</h3>
#foreach ($permission in $space.getPermissions())
#if ($permission.isGroupPermission())
#if ($permission.getGroup() == $group)
$permission.getType()<br />
#end
#end
#end
#end
#end
This macro list the permissions of a group on a particular space:
## Macro title: Group Permissions
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Date created: 06/05/2012
## Installed by: <your name>
## Macro loops through every group and every space listings permissions on that space grouped by group
## @noparams
<h1>Groups</h1>
## get all the groups
#set ( $allGroups = $userAccessor.getGroupsAsList() )
## get all the spaces
#set ( $allSpaces = $spaceManager.getAllSpaces() )
#foreach ($group in $allGroups)
<h2>$group</h2>
#foreach ($space in $allSpaces)
<h3>$space.getName()</h3>
#foreach ($permission in $space.getPermissions())
#if ($permission.isGroupPermission())
#if ($permission.getGroup() == $group)
$permission.getType()<br />
#end
#end
#end
#end
#end
(Thanks to Andrew!)
So the features are apart but how can they achieve my requrement?
Can you please suggest?
Thanks in advance!
Rumi