Spaces administration macro for Confluence

Spaces administration macro for Confluence

I wrote a cool Confluence macro to ease space administrations and check for permissions, especially for big Confluence platforms, with a lot of spaces and users. This a macro that allow to check:

  • global anonymous permissions is active or not.
  • spaces permissions: for each existing spaces, list all administrators (users) and check also if anonymous permission is active or not.

This macro is also compatible with Table Filter and Charts for Confluence add-on, so you can easily filters by Space names and / or Spaces administrators (users).

This macro was tested on Confluence Server / Data Center 6.15.* but it should work as-is with Confluence Server / Data Center 7.* normally.

The code :

## Macro title: Spaces Admins
## Macro has a body: None
## Body processing: None
## Output: HTML and Wiki Markup
##
## Developed by: Damien Lauberton
## Modified by: Damien Lauberton
## Date created: 12/12/2019
## Date modified: 13/12/2019
## Installed by: Damien Lauberton
## Macro to display anonymous global permissions, 
## and for each space: list administrators and check for anonymous permission.
## @noparams

## ICONS FOR STATUS WITH WIKI MARKUP 
#set($globalHelper = $action.getHelper())
#set($validIcon = $globalHelper.renderConfluenceMacro("(/)"))
#set($errorIcon = $globalHelper.renderConfluenceMacro("(x)"))

## GET ALL SPACES 
#set($spaces = $spaceManager.getAllSpaces())

## GLOBAL PERMISSIONS CHECK 
<table>
 <tr>
  <th style="text-align:center"><h2>Global Permissions - Anonymous Access</h2></th>
 </tr>
 <tr>
  <td style="text-align:center">
  #if($permissionHelper.isGlobalAnonymousAccessEnabled())
   $validIcon
  #else
   $errorIcon
  #end
  </td>
 </tr>
</table>

<br/>

## SPACES PERMISSIONS CHECK
<table style="border-collapse: collapse;">
 <tr>
  <th colspan="3" style="text-align:center"><h2>Spaces Permissions</h2></th>
 </tr>
 <tr>
  <th>Spaces</th>
  <th>Anonymous Permission</th>
  <th>Administrators</th>
 </tr>
#foreach($spacer in $spaces)
 #set($spacesadmins = $spaceManager.getSpaceAdmins($spacer))
 #set($varrowspan = $spacesadmins.size()+1)
 <tr>
  <td rowspan="${varrowspan}">
   <strong><a href="$req.contextPath/display/$spacer.key">$spacer.name</a></strong>
  </td>
  <td rowspan="${varrowspan}">
   #set($flagvalid = false)
   #set($spacespermissions = $spacer.getPermissions())
   #foreach($permission in $spacespermissions)
    #if($permission.isAnonymousPermission())
     $permission.getType() $validIcon 
     #set($flagvalid = true)
    #end
   #end
   #if(!$flagvalid)
    $errorIcon
   #end
  </td>
  #foreach($spaceadmin in $spacesadmins)
   <tr><td>$spaceadmin.getFullName()</td></tr>
  #end
#end
</table>

How to install it:

  1. open the Confluence administration page
  2. click on User Macro (or go to BASE_URL/admin/usermacros.action)
  3. hit the link Create a User Macro
  4. fill the form as follow :
  • Macro Name = spacesadmins
  • Visibility = Visible only to system administrators in the Macro Browser
  • Macro Title = Spaces Admins
  • Description = Display anonymous global permissions, and for each space: list administrators and check for anonymous permission.
  • Categories = Administration
  • Macro Body Processing = No macro body
  • Template = copy / paste the code provided earlier
  • click on the Save button

Enjoy and let me know what you think about it ;)

Celine Beuchet

Coach agile @scale Transformation - SAFe Program Consultant (SPC 5.1) - LPM 5.1 - RTE - Scrum Master // en mission chez REXEL

5 年
Angelo Ivan Rossi

Chief Reg. Compliance & Information Officer

5 年
回复

Nice script, I added this check for each space:??#if((!($spacer.isArchived())) && ($spacer.isGlobal()))? Then archived and personal spaces are not included in the list.

Maxim Grouchevoi

Enterprise Agile & Atlassian Expert, Solutions Creator, Knowledge Facilitator

5 年

Thank you, Damien Lauberton. Have you tested your macro on a instance with +1000 site spaces??

要查看或添加评论,请登录

Damien Lauberton的更多文章

社区洞察

其他会员也浏览了