You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi all i am new to confluence and we are using script runner for confluence and we want list of permissions which a space have using groovy ..can anyone help me in this ..TIA
What are you actually trying to achieve with this?
Most "I want to see the permissions of a space" questions can be answered by "look at the space permissions page in admin". A request to do it with a script suggests you want to actually do something more clever, and rather than just give you a piece of it, it may be that we can give you a script that can do most of the task.
Hi Nic tnq for the quick response actually we want get the spaces list which were enabled the anonymous access by script runner for confluence for that we need a script can you please help me in this...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, that makes sense.
I don't have a script for that, but I have a user-macro bookmarked that does something similar and could be adapted easily (a user-macro is probably a bit more useful than a script in this case, because you can put it on a page restricted to admins and then visit the page whenever you need it, rather than go look for a script every time).
This in fact lists all your administrators
#set($spaces = $spaceManager.getAllSpaces()) <table class="confluenceTable"> #foreach($thisSpace in $spaces ) #if ($thisSpace.isGlobal() ) <tr> <td class="confluenceTd"> <img class="space logo" width="32" height="32" src="$spaceManager.getLogoForSpace($thisSpace.key).getDownloadPath()" alt="$thisSpace.key"/> $thisSpace.getName() </td> <td class="confluenceTd"> #set($spaceAdmins = $spaceManager.getSpaceAdmins($thisSpace )) #foreach($spaceAdmin in $spaceAdmins ) #usernameLink($spaceAdmin.name)<BR> #end </td> </tr> #end #end </table>
But you could replace the "set($spaceadmins = ..." area with something like
#set($permissions = $thisSpace.getPermissions())
#foreach($perm in $permissions)
$perm <BR>
#end
This would give you everything, which might be a bit much, I'd probably want to put in an "if" to only dump out the permissions I'm interested in
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.
Thanks, this was so helpful! Do you know how to have all the spaces have a hyperlink back to 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 could change the code in the macro so that it embeds HTML links - I'd do it in the space name text myself. Instead of
$thisSpace.getName()
try something like the below (untested, I can't remember how to get the base URL, and I'm not sure the getKey is right)
<a href="<baseurl>/display/$thisSpace.getKey()">$thisSpace.getName()</a>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Nic Brough -Adaptavist- , I ended up fixing this.
However, do you know how to show only active users:
#set($spaces = $spaceManager.getAllSpaces())
<table class="confluenceTable">
<thead>
<tr>
<th>Space Name</th>
<th>Space Administrator</th>
</tr>
</thead>
#foreach($thisSpace in $spaces )
#if ($thisSpace.isGlobal() )
<tr>
<td class="confluenceTd">
<img class="space logo" width="32" height="32" src="$spaceManager.getLogoForSpace($thisSpace.key).getDownloadPath()" alt="$thisSpace.key" />
<a href="$thisSpace.getUrlPath()">$thisSpace.name</a></td>
<td class="confluenceTd">
#set($spaceAdmins = $spaceManager.getSpaceAdmins($thisSpace ))
#foreach($spaceAdmin in $spaceAdmins )
#usernameLink($spaceAdmin.name)<BR>
#end
</td>
</tr>
#end
#end
</table>
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.