-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustom-user-profile-macro.vm
93 lines (82 loc) · 3.69 KB
/
custom-user-profile-macro.vm
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
## Macro title: Custom User Profile Macro
## Macro has a body: N
## Developed by: Totally Tot
## Date created: 28/12/2018
## Confluence version: 6.6.2
## Installed by: Totally Tot
## Allows viewing users' profile with selected options
## @param User:title=Username|type=username|required=true
## @param Avatar:title=Avatar|type=boolean|default=true
## @param Email:title=Email|type=boolean|default=true
## @param Phone:title=Phone|type=boolean
## @param IM:title=IM|type=boolean
## @param Website:title=Website|type=boolean
## @param Position:title=Position|type=boolean
## @param Department:title=Department|type=boolean
## @param Location:title=Locatiom|type=boolean
#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 ($userDetailsManager = $containerContext.getComponent("userDetailsManager"))
#set ($settingsManager = $containerContext.getComponent("settingsManager"))
#set ($user = $userAccessor.getUserByName($paramUser))
#if ($user)
#if ($paramPhone == "true") #set ($phone = $userDetailsManager.getStringProperty($user, "phone")) #end
#if ($paramIM == "true") #set ($im = $userDetailsManager.getStringProperty($user, "im")) #end
#if ($paramWebsite == "true") #set ($website = $userDetailsManager.getStringProperty($user, "website")) #end
#if ($paramPosition == "true") #set ($position = $userDetailsManager.getStringProperty($user, "position")) #end
#if ($paramDepartment == "true") #set ($department = $userDetailsManager.getStringProperty($user, "department")) #end
#if ($paramLocation == "true") #set ($location = $userDetailsManager.getStringProperty($user, "location")) #end
<style>
div.custom-user-profile-macro {
display: table;
width:350px;
}
#if ($paramAvatar == "true")
div.user-avatar {
display: contents;;
float: left;
width: 40px;
}
div.main-block {
display: block;
float: right;
width: 295px;
}
#end
div.user-data {
display: block;
float: left;
}
</style>
<div class="custom-user-profile-macro">
## Display a picture of a user via macro. Create divs for avatar in case it was chosen and for user full name and email.
#if ($paramAvatar == "true")
<div class="user-avatar">
<ac:macro ac:name="profile-picture"><ac:parameter ac:name="User">$paramUser</ac:parameter></ac:macro>
</div>
## Display full name and email
<div class="main-block">
<b><i><a href=$settingsManager.getGlobalSettings().getBaseUrl()/display/~$paramUser title="Visit $user.getFullName()'s profile">$user.getFullName()</a></i></b><br/>
#if ($paramEmail == "true") <a href="mailto:$user.getEmail()" title="Send email to $user.getFullName()">$user.getEmail()</a> #end
</div>
#end
## Display user properties. If avatar is not required user full name and email will be presented in user-data block
<div class="user-data">
#if ($paramAvatar == "false")
<b><i><a href=$settingsManager.getGlobalSettings().getBaseUrl()/display/~$paramUser title="Visit $user.getFullName()'s profile">$user.getFullName()</a></i></b><br/>
#if ($paramEmail == "true") <a href="mailto:$user.getEmail()" title="Send email to $user.getFullName()">$user.getEmail()<br/></a>#end
#end
#if ($phone) <b>Phone: </b> $phone <br/> #end
#if ($im) <b>IM: </b> $im <br/> #end
#if ($website) <b>Website: </b> $website <br/> #end
#if ($position) <b>Position: </b> $position <br/> #end
#if ($department) <b>Department: </b> $department <br/> #end
#if ($location) <b>Location: </b> $location <br/> #end
<br/>
</div>
</div>
#else
User $paramUser not found.
#end