macro to display all authorized readers of a page

Michael Bernhardt November 18, 2014

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 19, 2014

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

Michael Bernhardt November 19, 2014

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

sniadeks February 10, 2015

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

Can it be expanded with this functionality?

0 votes
Michael Bernhardt November 19, 2014

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.

0 votes
MichalS November 19, 2014

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events