-
Notifications
You must be signed in to change notification settings - Fork 1
/
userlastloginbygroup
60 lines (50 loc) · 2.4 KB
/
userlastloginbygroup
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
## Macro title: Last Login by Group
## Macro has a body: Y
##
## Developed by: https://answers.atlassian.com/questions/33385/macro-that-produces-a-list-of-users-last-login-date
## Date created: 25/11/2013
## Updated by: Ahmed Sajid
## @param group:title=Group|type=string|required=true|desc=The group you want to report on
#set($containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null,null))
#set($containerContext = $containerManager.containerContext)
#set($loginManager = $containerContext.getComponent('loginManager'))
#set($crowdService = $containerContext.getComponent('crowdService'))
#set($group = $userAccessor.getGroup($paramgroup))
#if($group)
#set($usernames = $userAccessor.getMemberNames($group))
#set($total=0)
<table class="confluenceTable">
<tr>
<th class="confluenceTh">User</th>
<th class="confluenceTh">Email</th>
<th class="confluenceTh">Last Successful Login Date</th>
<th class="confluenceTh">Creation Date</th>
</tr>
#foreach($username in $usernames)
#set($user = $userAccessor.getUser($username))
#set($crowdUser = $crowdService.getUser($user.name))
#if( !$userAccessor.isDeactivated($user))
<tr>
<td class="confluenceTd">#usernameLink($user.name)</td>
<td class="confluenceTd">$user.email</td>
<td class="confluenceTd">$action.dateFormatter.formatDateTime($loginManager.getLoginInfo($user).lastSuccessfulLoginDate)</td>
<td class="confluenceTd">$action.dateFormatter.formatDateTime($crowdUser.createdDate)</td>
</tr>
#set( $total = $total+1 )
#end
#if( !$velocityHasNext )
<tr>
<td class="confluenceTd"><b>Total Users</b></td>
<td class="confluenceTd"></td>
<td class="confluenceTd"></td>
<td class="confluenceTd"><b>$total</b></td>
</tr>
</b>
#end
#end
</table>
#else
<p><i>No group with name "$paramgroup" found!</i></p>
#end