-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathspace-permissions.vtl
131 lines (122 loc) · 5.29 KB
/
space-permissions.vtl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#** ===========================================================================
SPACE PERMISSIONS
This Confluence user macro lists groups and users having permissions to the
current or given space.
Version: 3.0.1
Updated: 2022-01-09
Author/s: George Lewe, Benny Varughese, Zsolt Balint
Source: https://github.com/glewe/confluence-user-macros
License: GNU LGPLv3
Macro Body processing: No macro body
*#
#** ---------------------------------------------------------------------------
PARAMETER
*#
## @param SpaceKey:title=Space Key|type=string|desc=Enter a space key. Leave empty for current space.
## @param Header:title=Header|type=string|desc=Enter the header here|default=Space Permissions
## @param ShowHeader:title=Show Header|type=boolean|desc=Select whether to show an h1 header above the permissions table.|default=true
## @param ShowView:title=Show View Permissions|type=boolean|desc=Select whether to show View permissions|default=true
## @param ShowComment:title=Show Comment Permissions|type=boolean|desc=Select whether to show Comment permissions|default=false
## @param ShowEdit:title=Show Edit Permissions|type=boolean|desc=Select whether to show Edit permissions|default=true
## @param ShowAdmin:title=Show Admin Permissions|type=boolean|desc=Select whether to show Admin permissions|default=true
## @param ShowMembers:title=Show Group Members|type=boolean|desc=Select whether to show the members of each group in an expandable section below the group name. This will only be done for groups with less than 100 members.|default=true
#** ---------------------------------------------------------------------------
PROCESS INPUT
*#
#set($permArray = [])
#if (!$paramSpaceKey)
#set($paramSpaceKey = $space.key)
#end
#set($forspace = $spaceManager.getSpace($paramSpaceKey))
#set($spacename = $forspace.getName())
#set($header = $paramHeader + " for " + $spacename + " (" + $paramSpaceKey + ")")
#if ($paramShowView==true)
#set ($res = $permArray.add("VIEWSPACE"))
#end
#if ($paramShowComment==true)
#set ($res = $permArray.add("COMMENT"))
#end
#if ($paramShowEdit==true)
#set ($res = $permArray.add("EDITSPACE"))
#end
#if ($paramShowAdmin==true)
#set ($res = $permArray.add("SETSPACEPERMISSIONS"))
#end
#** ---------------------------------------------------------------------------
OUTPUT
*#
<!-- User Macro: Space Permissions START -->
#if ($paramShowHeader==true)
<h1>$header</h1>
#end
#set ($colspan = 1)
<table class="confluenceTable">
<tr>
#if ($paramShowView==true)
<th class="highlight-green" data-highlight-colour="green">View Permissions</th>
#set ($colspan = $colspan + 1)
#end
#if ($paramShowComment==true)
<th class="highlight-yellow" data-highlight-colour="yellow">Comment Permissions</th>
#set ($colspan = $colspan + 1)
#end
#if ($paramShowEdit==true)
<th class="highlight-blue" data-highlight-colour="blue">Edit Permissions</th>
#set ($colspan = $colspan + 1)
#end
#if ($paramShowAdmin==true)
<th class="highlight-red" data-highlight-colour="red">Admin Permissions</th>
#set ($colspan = $colspan + 1)
#end
</tr>
<tr>
<th class="confluenceTh" colspan="$colspan">Users</th>
</tr>
<tr>
#foreach( $perm in $permArray )
<td class="confluenceTd">
#foreach ($permission in $forspace.getPermissions())
#if ($permission.isUserPermission() && $permission.getType() == $perm)
#usernameLink($permission.getUserName())<br/>
#end
#end
</td>
#end
</tr>
<tr>
<th class="confluenceTh" colspan="$colspan">Groups</th>
</tr>
<tr>
#foreach( $perm in $permArray )
<td class="confluenceTd">
#foreach ($permission in $forspace.getPermissions())
#if ($permission.isGroupPermission() && $permission.getType() == $perm)
#set ( $groupString = $permission.getGroup() )
#set ( $groupObject = $userAccessor.getGroup($groupString) )
<b>$groupString</b>
#if ($paramShowMembers==true)
<ac:structured-macro ac:name="expand">
<ac:parameter ac:name="title">Click to show members...</ac:parameter>
<ac:rich-text-body>
#if($groupString != "LSY Employee" && $groupString != "confluence-users" && $groupString != "jira-users")
#set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )
#if ($memberList.size()<100)
#foreach ($member in $memberList)
#usernameLink($member)<br />
#end
#else
Too many users to be displayed ($memberList.size())
#end
#else
Too many users to be displayed (>100)
#end
</ac:rich-text-body>
</ac:structured-macro>
#end
#end
#end
</td>
#end
</tr>
</table>
<!-- User Macro: Space Permissions END -->