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

1 vote
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?

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

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 Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

1,084 views 17 14
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