Search in sources :

Example 21 with Preferences

use of org.olat.core.id.Preferences in project openolat by klemens.

the class SendTokenToUserForm method generateMailText.

private String generateMailText() {
    Preferences prefs = user.getUser().getPreferences();
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(prefs.getLanguage());
    String emailAdress = user.getUser().getProperty(UserConstants.EMAIL, locale);
    if (emailAdress != null) {
        dummyKey = Encoder.md5hash(emailAdress);
        String serverpath = Settings.getServerContextPathURI();
        Translator userTrans = Util.createPackageTranslator(RegistrationManager.class, locale);
        String body = userTrans.translate("pwchange.intro", new String[] { user.getName() }) + userTrans.translate("pwchange.body", new String[] { serverpath, dummyKey, i18nModule.getLocaleKey(locale) });
        return body;
    } else
        return "This function is not available for users without an email-adress!";
}
Also used : Locale(java.util.Locale) Translator(org.olat.core.gui.translator.Translator) Preferences(org.olat.core.id.Preferences)

Example 22 with Preferences

use of org.olat.core.id.Preferences in project openolat by klemens.

the class MailHelper method getMailFooter.

public static String getMailFooter(Identity sender) {
    Preferences prefs = sender.getUser().getPreferences();
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(prefs.getLanguage());
    return getMailFooter(locale, sender);
}
Also used : Locale(java.util.Locale) Preferences(org.olat.core.id.Preferences)

Aggregations

Preferences (org.olat.core.id.Preferences)22 Locale (java.util.Locale)12 Translator (org.olat.core.gui.translator.Translator)8 Identity (org.olat.core.id.Identity)8 Date (java.util.Date)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 BaseSecurity (org.olat.basesecurity.BaseSecurity)4 User (org.olat.core.id.User)4 MailBundle (org.olat.core.util.mail.MailBundle)4 MailerResult (org.olat.core.util.mail.MailerResult)4 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)4 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)4 Charset (java.nio.charset.Charset)2 ArrayList (java.util.ArrayList)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 VelocityContext (org.apache.velocity.VelocityContext)2