Hi All,
I have a macro which scans the whole Confluence instance and results all the spaces/personal spaces of the instance and for each space/personal space list the groups having accessed.
This is very helpful because when creating a new user we don't have to see the space permission page for each space, but we have a separated admin page for this and we just search for the space and see the list of groups accessing to it.
Here is the code:
## Macro to list all Spaces in an installation with the Groups that have at least permission to view each Space.
## @noparams
<h1>Space Group Permissions</h1>
<p>Below listed the spaces and personal spaces alphabetically with the groups accessing on.</p>
#foreach ($space in $spaceManager.getAllSpaces())
<h2>$space.getName()</h2>
<p>The following groups can at least view the $space.getName() Space.</p>
<ul>
#foreach ($permission in $space.getPermissions())
#if ($permission.isGroupPermission() && $permission.getType() == "VIEWSPACE")
<li>$permission.getGroup()</li>
#end
#end
</ul>
#end
After using this macro for 4 weeks, many of my confluence admin colleagues and space admins requested an extension: they would like to see the permission types too below each group. I mean - if you try the macro you will see - that they need to know what kind of permissions grants a particular group in a space.
Now the above code results this:
TEST Space
The following groups have access to TEST Space:
And my users need this extension:
TEST Space
The following groups have access to TEST Space.
COMMENT
VIEWSPACE
REMOVEMAIL
SETPAGEPERMISSIONS
COMMENT
VIEWSPACE
Thanks to Andrew Frayling, there is an other macro, which list the permission types of every group on a particular space. Only disadvantage of the macro that it is a "reverse": it lists every spaces/personal spaces for each group and mark the permission types where the particular group has permission in the space. In case of 30 groups and 20 spaces, the result will be 600 lines!
Here is the code:
{code}
<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
{code}
I tried to paste the "$permission.getType()<br />" line in the first code above but nothing happened.<br>
Hence most of our groups don't refer the permission (I wasn't the admin earlier:) so it's almost impossible to figure out that for example group A gives view only right in space B.
I hope that this is just putting 1-2 lines in the code above but I haven't get aquinted with velocity.
Can you please suggest?
Thanks in advance!
Rumi