Foros de discusión

Loading the Locale as user Preference in PostLogin Hook in Liferay 6.1

thumbnail
Nithin KV, modificado hace 11 años.

Loading the Locale as user Preference in PostLogin Hook in Liferay 6.1

Junior Member Mensajes: 56 Fecha de incorporación: 23/07/12 Mensajes recientes
Hi,

I have developed a PostLogin hook which will load the user preferences like default landing page,locales etc . The logged in user's locale can either be english or arabic. There is a requirement in which i want to show the portal in Arabic once he logs in if the loaded locale preference for that user is arabic in my hook.

Please let me know if any one has got any solution.......................
thumbnail
Hitoshi Ozawa, modificado hace 11 años.

RE: Loading the Locale as user Preference in PostLogin Hook in Liferay 6.1

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
I have developed a PostLogin hook which will load the user preferences like default landing page,locales etc . The logged in user's locale can either be english or arabic. There is a requirement in which i want to show the portal in Arabic once he logs in if the loaded locale preference for that user is arabic in my hook.

Please let me know if any one has got any solution.......................


I think you are the first one with the solution for you need. Would appreciate if you can shared it with the rest of us.
Erwin Tanasie, modificado hace 10 años.

RE: Loading the Locale as user Preference in PostLogin Hook in Liferay 6.1

New Member Mensajes: 5 Fecha de incorporación: 7/06/13 Mensajes recientes
Hi!
Did you by any chance found a solution for loading the locale for an user after the login? I am facing the same issue now.
Thanks in advance!emoticon
thumbnail
Nithin KV, modificado hace 8 años.

RE: Loading the Locale as user Preference in PostLogin Hook in Liferay 6.1

Junior Member Mensajes: 56 Fecha de incorporación: 23/07/12 Mensajes recientes
Hi,

Use the below method in the Custom Util Class and call it in your action class to achieve what you want. pass the requird language Id in the UserServiceUtil.updateUser method !!!

public static User updateUser(
HttpServletRequest request, long userId, String screenName,
String emailAddress, long facebookId, String openId,
String languageId, String timeZoneId, String greeting,
String comments, String smsSn, String aimSn, String facebookSn,
String icqSn, String jabberSn, String msnSn, String mySpaceSn,
String skypeSn, String twitterSn, String ymSn)
throws PortalException, SystemException {

String password = getUpdateUserPassword(request, userId);

User user = UserLocalServiceUtil.getUserById(userId);

Contact contact = user.getContact();

Calendar birthdayCal = CalendarFactoryUtil.getCalendar();

birthdayCal.setTime(contact.getBirthday());

int birthdayMonth = birthdayCal.get(Calendar.MONTH);
int birthdayDay = birthdayCal.get(Calendar.DATE);
int birthdayYear = birthdayCal.get(Calendar.YEAR);

long[] groupIds = null;
long[] organizationIds = null;
long[] roleIds = null;
List<UserGroupRole> userGroupRoles = null;
long[] userGroupIds = null;
ServiceContext serviceContext = new ServiceContext();

return UserServiceUtil.updateUser(
userId, password, StringPool.BLANK, StringPool.BLANK,
user.isPasswordReset(), user.getReminderQueryQuestion(),
user.getReminderQueryAnswer(), screenName, emailAddress, facebookId,
openId, languageId, timeZoneId, greeting, comments,
contact.getFirstName(), contact.getMiddleName(),
contact.getLastName(), contact.getPrefixId(), contact.getSuffixId(),
contact.isMale(), birthdayMonth, birthdayDay, birthdayYear, smsSn,
aimSn, facebookSn, icqSn, jabberSn, msnSn, mySpaceSn, skypeSn,
twitterSn, ymSn, contact.getJobTitle(), groupIds, organizationIds,
roleIds, userGroupRoles, userGroupIds, serviceContext);
}