macro to display all authorized readers of a page

Is there a macro to display all users, who are allowed to watch a page?

We have users who want to know beforehand, who will be able to read something they post.

3 answers

This widget could not be displayed.
Davin Studer Community Champion Nov 19, 2014

Here is a user macro I created that shows the restriction set on a page. This will only show the page restrictions ... meaning it doesn't take into account space permissions.

## Developed by: Davin Studer
## Date created: 10/24/2013
## @noparams
#set ($vPerms = $content.getContentPermissionSet("View"))
#set ($ePerms = $content.getContentPermissionSet("Edit"))
#set ($viewSize = $vPerms.size())
#set ($editSize = $ePerms.size())
#if(!$viewSize)
    #set($viewSize = 0)
#end
#if(!$editSize)
    #set($editSize = 0)
#end

#if($viewSize == 0 && $editSize == 0)
    There are no restrictions set.<br />
#else
    ###################
    ##    Viewers    ##
    ###################
    #if ($viewSize > 0)
        Viewers:<br />
        <ul>
        #foreach($vPerm in $vPerms)
            #if($vPerm.isGroupPermission())
               <li>$vPerm.getGroupName() (Group)</li>
            #end
        #end
        #foreach($vPerm in $vPerms)
            #if($vPerm.isUserPermission())
               <li> $vPerm.getUserSubject().getFullName() (User)</li>
            #end
        #end
        </ul>
    #else
        There are no view restrictions set.<br />
    #end
    
    ###################
    ##    Editors    ##
    ###################
    #if ($editSize > 0)
        Editors:<br />
        <ul>
        #foreach($ePerm in $ePerms)
            #if($ePerm.isGroupPermission())
                <li>$ePerm.getGroupName() (Group)</li>
            #end
        #end
        #foreach($ePerm in $ePerms)
            #if($ePerm.isUserPermission())
                <li>$ePerm.getUserSubject().getFullName() (User)</li>
            #end
        #end
        </ul>
    #else
        There are no edit restrictions set.<br />
    #end
#end
Davin Studer Community Champion Nov 19, 2014

This could be expand to show space permissions as well using ... $spaceManager.getSpace($content.spaceKey).getPermissions()

ah, great. We are not very good at coding macros at the moment, but i will look into it.

Hi @Davin Studer. I like this macro, but It does not include inherited restrictions sad

Can it be expanded with this functionality?

This widget could not be displayed.

Great question. I would like to have this functionality. Even better would be: check if user XXX is able to view THIS page.

This widget could not be displayed.

Thank you very much for your input. This is one part of the game, but the space permissions is exactly what we need on top.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

445 views 5 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you