[Building Sakai] Display logged in user First Name in header area

Wilson, Kimberly wilsonk at mail.amc.edu
Wed Nov 6 10:55:45 PST 2013


Hi everybody, I figured it out!

This is what I did:

1.      \portal\portal-impl\impl\src\java\org\sakaiproject\portal\charon\SkinnableCharonPortal.java

Created two variables (Line 1740):
String removeLastName = null;
String loginUserFirstName = null;

Used some string functions to get at the first name from the Display Name (Line 1806):

removeLastName = StringUtils.substringAfterLast(loginUserDispName," ");
loginUserFirstName = StringUtils.removeEnd(loginUserDispName,removeLastName);

This way when there is a two part first name, like "Jo Anne", both of those will be picked up


2.      portal\portal-render-engine-impl\pack\src\webapp\vm\defaultskin\site.vm
Line 82:

#if (${displayUserloginInfo})
            <span id="loginUser">Welcome, ${loginUserFirstName} | </span>
#end


I also added this on Line 1868, not sure what it pertains to though - but maven produced an error without it:
rcontext.put("loginUserFirstName", loginUserFirstName);

I used this page for reference:
http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html

Also, this page was somewhat useful:
http://grepcode.com/file/repo1.maven.org/maven2/org.sakaiproject.kernel/sakai-kernel-api/1.3.0-b03/org/sakaiproject/user/api/UserDirectoryService.java



Kim Wilson, MSCIS | Systems Analyst - IS Academic Systems | Albany Medical Center | 518-264-1055

[Walk-to-End-Alzheimers-Logo_sm]

From: Wilson, Kimberly
Sent: Wednesday, November 6, 2013 10:21 AM
To: 'sakai-dev at collab.sakaiproject.org'
Subject: RE: Display logged in user First Name in header area

Thank you, everyone's suggestions have been extremely helpful, but I still can't get at the first name

I found the variables on the site.vm page are being set from this file:
SkinnableCharonPortal.java

So I added this to define the first name variable:

String loginUserFirstName = null;

(and I noticed this is ok:  )
boolean displayUserloginInfo = ServerConfigurationService.
getBoolean("display.userlogin.info", true);


But I can't figure out how to display this information on my site to see what is contained in it:
UserDirectoryService.getUser(userId)

I found this site:
https://fisheye6.atlassian.com/browse/SakaiSVN/user/trunk/user-tool/tool/src/webapp/vm/user/chef_users_view.vm?r2=128776
That contains this line:
 $validator.escapeHtml($user.FirstName)

But I have tried various methods of setting the value with no luck so far and I'm getting errors in the maven build (around line 1800 of SkinnableCharonPortal.java):
loginUserFirstName = Validator.escapeHtml(thisUser.FirstName);
loginUserFirstName = Validator.escapeHtml(thisUser.getFirstName());

and put this in the site.vm in the mastLogin div:

#if (${displayUserloginInfo})
            <span id="loginUser">Welcome, ${loginUserFirstName} | </span>
#end

I'm still searching.  Any more help will be greatly appreciated!


Kim Wilson, MSCIS | Systems Analyst - IS Academic Systems | Albany Medical Center | 518-264-1055

[Walk-to-End-Alzheimers-Logo_sm]

From: Schauer, Christopher R [mailto:cschauer at txstate.edu]
Sent: Saturday, November 2, 2013 5:54 AM
To: Wilson, Kimberly; sakai-dev at collab.sakaiproject.org<mailto:sakai-dev at collab.sakaiproject.org>
Subject: RE: Display logged in user First Name in header area

Hi Kim,

One possibility would be to add it in 'portal/portal-render-engine-impl/pack/src/webapp/vm/neoskin/site.vm'. That is the velocity file that is used to render the header area. The handler for that view is at 'portal/portal-impl/impl/src/java/org/sakaiproject/portal/charon/handlers/SiteHandler.java' and you can add the user's first name to the context there. The userId is in the session and you can use UserDirectoryService.getUser(userId) to get the User object for the current user.

-Chris

________________________________
From: sakai-dev-bounces at collab.sakaiproject.org<mailto:sakai-dev-bounces at collab.sakaiproject.org> [sakai-dev-bounces at collab.sakaiproject.org] on behalf of Wilson, Kimberly [wilsonk at mail.amc.edu]
Sent: Friday, November 01, 2013 3:31 PM
To: sakai-dev at collab.sakaiproject.org<mailto:sakai-dev at collab.sakaiproject.org>
Subject: [Building Sakai] Display logged in user First Name in header area
Hi:

I've been modifying our Sakai portal.css for our 2.9.3 upcoming release

I need to figure out how to display the logged in user's first name in a Welcome message in the header of the page

Does anyone know how to do this?  Maybe with jQuery or Javascript?

I don't know how to call the first name from the logged in user information.

Thanks!

Kim Wilson, MSCIS | Systems Analyst - IS Academic Systems | Albany Medical Center | 518-264-1055

[Walk-to-End-Alzheimers-Logo_sm]

________________________________
----------------------------------------- CONFIDENTIALITY NOTICE: This email and any attachments may contain confidential information that is protected by law and is for the sole use of the individuals or entities to which it is addressed. If you are not the intended recipient, please notify the sender by replying to this email and destroying all copies of the communication and attachments. Further use, disclosure, copying, distribution of, or reliance upon the contents of this email and attachments is strictly prohibited. To contact Albany Medical Center, or for a copy of our privacy practices, please visit us on the Internet at www.amc.edu<http://www.amc.edu>.


-----------------------------------------
CONFIDENTIALITY NOTICE: This email and any attachments may contain confidential information that is protected by law and is for the sole use of the individuals or entities to which it is addressed. If you are not the intended recipient, please notify the sender by replying to this email and destroying all copies of the communication and attachments. Further use, disclosure, copying, distribution of, or reliance upon the contents of this email and attachments is strictly prohibited. To contact Albany Medical Center, or for a copy of our privacy practices, please visit us on the Internet at www.amc.edu.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20131106/d1c37708/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.jpg
Type: image/jpeg
Size: 982 bytes
Desc: image005.jpg
Url : http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20131106/d1c37708/attachment.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image006.jpg
Type: image/jpeg
Size: 980 bytes
Desc: image006.jpg
Url : http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20131106/d1c37708/attachment-0001.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 982 bytes
Desc: image001.jpg
Url : http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20131106/d1c37708/attachment-0002.jpg 


More information about the sakai-dev mailing list