Foros de discusión

Language selection not enabled for actual users

thumbnail
Iñaki Paz, modificado hace 16 años.

Language selection not enabled for actual users

New Member Mensajes: 16 Fecha de incorporación: 17/01/08 Mensajes recientes
Hello everybody,
Im facing a problem with liferay. We are using Liferay 4.2.1. In this Liferay we have created a new private (group) community. We are using the brochure theme, that has language selection at the bottom of the page.

If the user is the portal admin (liferay.com.1) he is enabled to change the language. However, if the user is a normal user asigned to the community, when you try to change the language for that user, it fails. There is no trace on the catalina.out.

Even more, to the pages we add the language portlet, the bottom images to change the languages do work.

With the guest user over on public (web) pages of the same community changing languages is enabled.

So the question is? Does anyone know what is going on and how to solve it?
Thanks in advance,
Iñaki Paz
PD: Just in case. Users are configured to work from an LDAP and not liferay users.
thumbnail
Rasto Rehak, modificado hace 15 años.

RE: Language selection not enabled for actual users

Junior Member Mensajes: 66 Fecha de incorporación: 8/03/07 Mensajes recientes
Hi

I have the same problem on 4.4.1. but not in 4.4.2 . Maybe it was fixed in that version but I can't see change in code. Maybe it was somewhere in UserService implementation.
The language action should also update user profile.
thumbnail
Rasto Rehak, modificado hace 15 años.

RE: Language selection not enabled for actual users

Junior Member Mensajes: 66 Fecha de incorporación: 8/03/07 Mensajes recientes
Well I found it, it is not fixed. It is BUG.

When user is not in role Administrator the permission check for the Language portlet fails because the portlet is not on the page. Once you have real Language portlet ( not that from the theme ) on the page, there are permissions for the Guest and myabe role User to view the portlet.

Exception is thrown in PortleRequestProces.processRoles()
...
if (!PortletPermissionUtil.contains(
permissionChecker, layout.getPlid(), portlet,
ActionKeys.VIEW)) {

throw new PrincipalException();
}
So you can report it as a bug.
thumbnail
Iñaki Paz, modificado hace 15 años.

RE: Language selection not enabled for actual users

New Member Mensajes: 16 Fecha de incorporación: 17/01/08 Mensajes recientes
Thanks for answering,
I realized it was a bug, however i didnt know where it came from. Anyway I solved it including some Language Change code as the first thing to do on loading the page on the theme (init.jsp). I put here the snippet of code for the 4.2.1 version:

<%
  HttpSession httpSes = request.getSession();
  String languageId = request.getParameter("languageId");
  if (languageId == null) languageId = "";

  Locale newLocale = LocaleUtil.fromLanguageId(languageId);
  Locale oldLocale = (Locale)httpSes.getAttribute(Globals.LOCALE_KEY);
  if (locale.toString().equalsIgnoreCase("en_US") || oldLocale.toString().equalsIgnoreCase("en_US")){
    if (newLocale == null || newLocale.toString().equalsIgnoreCase("en_US")) newLocale = LocaleUtil.fromLanguageId("es_ES");
	}

  List availableLocales = ListUtil.fromArray(LanguageUtil.getAvailableLocales());

  if (availableLocales.contains(newLocale) && !newLocale.equals(oldLocale)) {
          httpSes.setAttribute(Globals.LOCALE_KEY, newLocale);
          LanguageUtil.updateCookie(response, newLocale);
          themeDisplay.setLocale(newLocale);
          locale = newLocale;
          // Send redirect
          response.sendRedirect(PortalUtil.getLayoutURL(themeDisplay.getLayout(), themeDisplay));
  }

%>
thumbnail
chris chris chris, modificado hace 15 años.

RE: Language selection not enabled for actual users

Regular Member Mensajes: 179 Fecha de incorporación: 25/09/07 Mensajes recientes
Hi there,

Could you tell me more how to fix this problem ? Which file did you edit ?


Iñaki Paz:
Thanks for answering,
I realized it was a bug, however i didnt know where it came from. Anyway I solved it including some Language Change code as the first thing to do on loading the page on the theme (init.jsp). I put here the snippet of code for the 4.2.1 version:

<%
  HttpSession httpSes = request.getSession();
  String languageId = request.getParameter("languageId");
  if (languageId == null) languageId = "";

  Locale newLocale = LocaleUtil.fromLanguageId(languageId);
  Locale oldLocale = (Locale)httpSes.getAttribute(Globals.LOCALE_KEY);
  if (locale.toString().equalsIgnoreCase("en_US") || oldLocale.toString().equalsIgnoreCase("en_US")){
    if (newLocale == null || newLocale.toString().equalsIgnoreCase("en_US")) newLocale = LocaleUtil.fromLanguageId("es_ES");
	}

  List availableLocales = ListUtil.fromArray(LanguageUtil.getAvailableLocales());

  if (availableLocales.contains(newLocale) && !newLocale.equals(oldLocale)) {
          httpSes.setAttribute(Globals.LOCALE_KEY, newLocale);
          LanguageUtil.updateCookie(response, newLocale);
          themeDisplay.setLocale(newLocale);
          locale = newLocale;
          // Send redirect
          response.sendRedirect(PortalUtil.getLayoutURL(themeDisplay.getLayout(), themeDisplay));
  }

%>
Bernardo Riveira Faraldo, modificado hace 14 años.

RE: Language selection not enabled for actual users

Regular Member Mensajes: 135 Fecha de incorporación: 30/10/08 Mensajes recientes
Same problem here in 5.2.2: only admins able to change language with theme (not language portlet) links

supposed to be solved in http://issues.liferay.com/browse/LEP-1366 in version 5.0, but....

do you know if your code will work with 5.0? did you upgraded your 4.x installation to 5.x?

thanks in advance
Bernardo Riveira Faraldo, modificado hace 14 años.

RE: Language selection not enabled for actual users

Regular Member Mensajes: 135 Fecha de incorporación: 30/10/08 Mensajes recientes
solved following solution mentioned here:

http://www.liferay.com/community/forums/-/message_boards/message/4552574#_19_message_4108309