Hi, I want to write a macro that generates the table (list) for a current page with names of users who have access to this page. So, if one page view is resticted to 5 people, I want to see those 5 users.
I've tried to use {report-table} and {user-reporter:space=view}, but looks like I can't get the permission list for a current page.
Pls help!
Community moderators have prevented the ability to post new answers.
Hello Hello,
I would simply write a little user macro. This macro is using the contentPermissionManager to get the read permitted users. This is the code:
## @noparams #set($containerManagerClass=$action.class.forName('com.atlassian.spring.container.ContainerManager')) #set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null)) #set($containerManager=$getInstanceMethod.invoke(null,null)) #set($containerContext=$containerManager.containerContext) ## the contentPermissionManager gives you access to the page permissions #set($contentPermissionManager=$containerContext.getComponent('contentPermissionManager')) Users with view Permission <ul> ##iterate over all view contentpermissionssets #foreach( $contentPermissionSet in $contentPermissionManager.getContentPermissionSets($content,"View") ) #foreach( $contentPermission in $contentPermissionSet ) ##is the current permission a user permission #if($contentPermission.isUserPermission() ) ##if yes print the name <li>$contentPermission.userName</li> #end #end #end </ul>
Code has been testet with Confluence 4.0.3.
This code is also a demonstration for using API Managers in User Macros. Additional examples for Managers can be found here: http://www.communardo.de/home/techblog/2011/05/18/using-confluence-api-managers-in-user-macros
Check out this plugin: https://plugins.atlassian.com/plugin/details/172
I think it does exactly what you're trying to do. I can confirm that the plugin still works with Confluence 3.5.5, we use it frequently.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, that's a nice one, for sure. But it works 10 seconds! Every time I open this page, it is rendered so long.
Is it possible to wrap this macro in some JScript, so it will be like a button "Watch the permissions to this page...", you click it, and get the resulting table??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is a great macro. Thanks. Really, I'd like to be able to put it in the space header so that people know whether they are editing an externally-visible page or not. Unfortunately, it only seems to work within a page.
Is there any way to make it work in the header for the space? (That way it doesn't show up in search summaries and also it's easy to change all pages in the space.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To display the users AND the group permisson please see the code here:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Anyone know why this macro doesn't work in Confluence 5.5.2? It doesn't return any users.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.