From 0543cd86858224d38677c159d62c31807e7eca14 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 19 Mar 2014 20:42:06 -0500 Subject: [PATCH] IDEMPIERE-1829 Impossible to send reset password email in the user language / based on patch from Nicolas Micoud (nmicoud) --- .../src/org/compiere/model/MMailText.java | 26 ++++++++++++------- .../webui/panel/ResetPasswordPanel.java | 1 + 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MMailText.java b/org.adempiere.base/src/org/compiere/model/MMailText.java index 53ac18a862..39fe1ea796 100644 --- a/org.adempiere.base/src/org/compiere/model/MMailText.java +++ b/org.adempiere.base/src/org/compiere/model/MMailText.java @@ -27,6 +27,7 @@ import org.compiere.util.DB; import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Msg; +import org.compiere.util.Util; /** * Request Mail Template Model. @@ -39,7 +40,7 @@ public class MMailText extends X_R_MailText /** * */ - private static final long serialVersionUID = -9121875595478208460L; + private static final long serialVersionUID = -3278575461023934790L; /** * Standard Constructor @@ -79,6 +80,7 @@ public class MMailText extends X_R_MailText private String m_MailText3 = null; /** Translation Cache */ private static CCache s_cacheTrl = new CCache (Table_Name, 20); + private String m_language = null; /** * Get parsed/translated Mail Text @@ -323,13 +325,19 @@ public class MMailText extends X_R_MailText */ private void translate() { - if (m_bpartner != null && m_bpartner.getAD_Language() != null) + // Default if no Translation + m_MailHeader = super.getMailHeader(); + m_MailText = super.getMailText(); + m_MailText2 = super.getMailText2(); + m_MailText3 = super.getMailText3(); + if ((m_bpartner != null && m_bpartner.getAD_Language() != null) || !Util.isEmpty(m_language)) { - StringBuilder key = new StringBuilder().append(m_bpartner.getAD_Language()).append(get_ID()); + String adLanguage = m_bpartner != null ? m_bpartner.getAD_Language() : m_language; + StringBuilder key = new StringBuilder().append(adLanguage).append(get_ID()); MMailTextTrl trl = s_cacheTrl.get(key.toString()); if (trl == null) { - trl = getTranslation(m_bpartner.getAD_Language()); + trl = getTranslation(adLanguage); if (trl != null) s_cacheTrl.put(key.toString(), trl); } @@ -341,11 +349,6 @@ public class MMailText extends X_R_MailText m_MailText3 = trl.MailText3; } } - // No Translation - m_MailHeader = super.getMailHeader(); - m_MailText = super.getMailText(); - m_MailText2 = super.getMailText2(); - m_MailText3 = super.getMailText3(); } // translate /** @@ -406,4 +409,9 @@ public class MMailText extends X_R_MailText String MailText3 = null; } // MMailTextTrl + public void setLanguage(String language) + { + m_language = language; + } + } // MMailText diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ResetPasswordPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ResetPasswordPanel.java index 13a620b5c9..d7cfdc1c9b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ResetPasswordPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ResetPasswordPanel.java @@ -506,6 +506,7 @@ public class ResetPasswordPanel extends Window implements EventListener return false; MMailText mailText = new MMailText(m_ctx, R_MailText_ID, null); + mailText.setLanguage(Env.getContext(m_ctx, "#AD_Language")); to.set_ValueOfColumn("Password", newPassword); // will be hashed and validate on saveEx mailText.setUser(to); String message = mailText.getMailText(true);