Hi everybody,
Starting from the last succefull login macro from Andrew Frayling and from the macro that produces a list of users last login date from Remo Siegwart i want to create a macro that will also take personal details from every user like Phone, Position etc in order to create a report.
Any idea how i can take the personal details?
Thanks in advance,
Kostas
I think I have an answer for you, not sure if this is the quickest route but it does the job.
Use your findings in macro that produces a list of users last login date and get another component:
#set($userDetailsManager = $containerContext.getComponent('userDetailsManager'))
You print user details like this:
$userDetailsManager.getStringProperty($action.remoteUser, 'location')
You can even get them by group and iterate using:
$userDetailsManager.getProfileGroups(); $userDetailsManager.getProfileKeys($group);
And lastly, you could load a wiki markup renderer for personal information (about me) user field. This thing was a real pain for me. Check out my findings:
it worked !! :)
Hey Andreas,
Thanx for your help.
I'm getting the component below
#set($userDetailsManager = $containerContext.getComponent('userDetailsManager'))
but i don't know how to print user details for all users.
The macro that i have is:
#set($userDetailsManager = $containerContext.getComponent('userDetailsManager')) #set($loginManager = $containerContext.getComponent('loginManager')) #set($group = $userAccessor.getGroup($paramgroup)) #if($group) #set($usernames = $userAccessor.getMemberNames($group)) <table class="confluenceTable"> <tr> <th class="confluenceTh">Count</th> <th class="confluenceTh">User</th> <th class="confluenceTh">Tel</th> <th class="confluenceTh">Groups</th> <th class="confluenceTh">Last Successful Login Date</th> </tr> #set($count = 0) #foreach($username in $usernames) #set($user = $userAccessor.getUser($username)) #set($groups = $userAccessor.getGroupNamesForUserName($user.name)) <tr> #set($count = $count + 1) <td class="confluenceTd">$count</td> <td class="confluenceTd">#usernameLink($user.name)</td> <td class="confluenceTd">$userDetailsManager.getStringProperty($userAccessor.getUser($username)), 'location')</td> <td class="confluenceTd">$groups</td> <td class="confluenceTd">$action.dateFormatter.formatDateTime($loginManager.getLoginInfo($user).lastSuccessfulLoginDate)</td> </tr> #end </table> #else <p><i>No group with name "$paramgroup" found!</i></p> #end
If i use
$userDetailsManager.getStringProperty($userAccessor.getUser($username)), 'location')
doesn't print anything.
If i use
$userDetailsManager.getStringProperty($action.remoteUser, 'location')
prints the location of currently logged in user for every use.
I have use various combinations without success.
Any idea?
Thanx again for the help patrioti :)
Cheers,
Kostas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Andreas i've pressed on i don't like this post by mistake. I'm trying to undo the action and i have a warning that an error occurs. I'll try to undo it.
I found the solution with your help.
Cheers,
Kostas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Haven't tried to iterate user objects, some suggestions:
Does your loop works? Where do you place the line to get the user's property? If you have the $user, try using it to get its properties, instead of userAccessor.getUser().
Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey andreas,
Macros work fine. The down vote was by mistake.
The problem with undo down vote is not resolved yet. I have raised an issue to atlassian
https://jira.atlassian.com/browse/ANSWERS-818.
Kala Christougenna,
Kostas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No worries Kosta,
Merry Xmas kai KALH XRONIA - Happy new year !!
Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have the same issue patrioti, need to get the "About Me" field from the user.
David said the trick is to get to the UserDetailsManager object, which is not one of the Confluence Objects Accessible From Velocity. (David says)
Check out his answers in the cases below, a bit tricky, need to have confuence source, eclipse or some other IDE - and go figure.
My problem is with velocity, you can get the userAccessor but then, what route do you follow to get to the userDetailsManager :
$action.getUserAccessor()..?... getEditMyProfileAction().getUserDetailsMap().getProperty('website')
Something like this maybe:
$action.getUserAccessor().getUserPreferences($action.remoteUser).getString('website')
.. doesn't work either :/
Maybe, you can get something out of his comments and share it with us
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check out the following two managers:
* com.atlassian.confluence.user.PersonalInformationManager
* com.atlassian.confluence.user.UserDetailsManager
Cheers,
-Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unless you can access the client through a mobile API, I don't think you can get the position (I assume you mean the GPS coordinates of the requesting device) from Confluence. You could use an analytics tool to give you general location-based information about clients, such as country of origin.
As for "Phone", I assume you mean the type of client device used to access the page. You can use JavaScript to get the clienty type (which would be the browser, which would hint at the phone type), but I don't think you can get the type of phone, again, without accessing a mobile API.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think he means the user details stored in the confluence user profile.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeap. Maybe i didn't make it so clear but i need the details of user profile.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.