Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get user details (Phone, Position, etc) for macro in Confluence?

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2012

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

4 answers

1 accepted

4 votes
Answer accepted
Andreas Gounaris
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 5, 2012

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:

https://answers.atlassian.com/questions/98010/how-do-i-get-the-about-me-field-from-a-confluence-user-macro

it worked !! :)

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2012

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

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2012

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

Andreas Gounaris
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2012

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

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 23, 2012

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

Andreas Gounaris
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 23, 2012

No worries Kosta,

Merry Xmas kai KALH XRONIA - Happy new year !!

Andreas

0 votes
Andreas Gounaris
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 3, 2012

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

Case 1: https://answers.atlassian.com/questions/98010/how-do-i-get-the-about-me-field-from-a-confluence-user-macro

Case 2: https://answers.atlassian.com/questions/11686/can-i-pull-a-specific-value-out-of-a-user-s-profile-for-use-in-another-macro



0 votes
Stefan Kleineikenscheidt _K15t_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2012

Check out the following two managers:

* com.atlassian.confluence.user.PersonalInformationManager
* com.atlassian.confluence.user.UserDetailsManager

Cheers,
-Stefan

0 votes
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2012

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.

Stefan Kleineikenscheidt _K15t_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2012

I think he means the user details stored in the confluence user profile.

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 4, 2012

Yeap. Maybe i didn't make it so clear but i need the details of user profile.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events