Fórumok

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

thumbnail
Nithin KV, módosítva 11 év-val korábban

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

Junior Member Bejegyzések: 56 Csatlakozás dátuma: 2012.07.23. Legújabb bejegyzések
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, módosítva 11 év-val korábban

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

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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, módosítva 10 év-val korábban

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

New Member Bejegyzések: 5 Csatlakozás dátuma: 2013.06.07. Legújabb bejegyzések
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, módosítva 8 év-val korábban

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

Junior Member Bejegyzések: 56 Csatlakozás dátuma: 2012.07.23. Legújabb bejegyzések
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);
}