Forums de discussion

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

thumbnail
Nithin KV, modifié il y a 11 années.

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

Junior Member Publications: 56 Date d'inscription: 23/07/12 Publications récentes
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, modifié il y a 11 années.

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

Liferay Legend Publications: 7942 Date d'inscription: 24/03/10 Publications récentes
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, modifié il y a 10 années.

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

New Member Publications: 5 Date d'inscription: 07/06/13 Publications récentes
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, modifié il y a 8 années.

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

Junior Member Publications: 56 Date d'inscription: 23/07/12 Publications récentes
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);
}