Search in sources :

Example 6 with GenderPropertyHandler

use of org.olat.user.propertyhandlers.GenderPropertyHandler in project OpenOLAT by OpenOLAT.

the class UserBulkChangeManager method sendLoginDeniedEmail.

public void sendLoginDeniedEmail(Identity identity) {
    String lang = identity.getUser().getPreferences().getLanguage();
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(lang);
    Translator translator = Util.createPackageTranslator(SystemRolesAndRightsController.class, locale);
    String gender = "";
    UserPropertyHandler handler = userManager.getUserPropertiesConfig().getPropertyHandler(UserConstants.GENDER);
    if (handler instanceof GenderPropertyHandler) {
        String internalGender = ((GenderPropertyHandler) handler).getInternalValue(identity.getUser());
        if (StringHelper.containsNonWhitespace(internalGender)) {
            Translator userPropTrans = userManager.getUserPropertiesConfig().getTranslator(translator);
            gender = userPropTrans.translate("form.name.gender.salutation." + internalGender);
        }
    }
    String email = identity.getUser().getProperty(UserConstants.EMAIL, null);
    email = StringHelper.containsNonWhitespace(email) ? email : "-";
    String[] args = new String[] { // 0: changed users username
    identity.getName(), // 1: changed users email address
    email, // 2: Name (first and last name) of user who changed the password
    userManager.getUserDisplayName(identity.getUser()), // 3: configured support email address
    WebappHelper.getMailConfig("mailSupport"), // 4 last name
    identity.getUser().getProperty(UserConstants.LASTNAME, null), // 5 url system
    getServerURI(), // 6 Mr. Mrs.
    gender };
    MailBundle bundle = new MailBundle();
    bundle.setToId(identity);
    bundle.setContent(translator.translate("mailtemplate.login.denied.subject", args), translator.translate("mailtemplate.login.denied.body", args));
    mailManager.sendExternMessage(bundle, null, false);
}
Also used : Locale(java.util.Locale) Translator(org.olat.core.gui.translator.Translator) GenderPropertyHandler(org.olat.user.propertyhandlers.GenderPropertyHandler) MailBundle(org.olat.core.util.mail.MailBundle) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 7 with GenderPropertyHandler

use of org.olat.user.propertyhandlers.GenderPropertyHandler in project openolat by klemens.

the class UserVOFactory method post.

public static void post(User dbUser, UserVO user, Locale locale) {
    UserManager um = UserManager.getInstance();
    List<UserPropertyHandler> propertyHandlers = um.getUserPropertyHandlersFor(UserWebService.PROPERTY_HANDLER_IDENTIFIER, false);
    dbUser.setProperty(UserConstants.FIRSTNAME, user.getFirstName());
    dbUser.setProperty(UserConstants.LASTNAME, user.getLastName());
    dbUser.setProperty(UserConstants.EMAIL, user.getEmail());
    for (UserPropertyVO entry : user.getProperties()) {
        for (UserPropertyHandler propertyHandler : propertyHandlers) {
            if (entry.getName().equals(propertyHandler.getName())) {
                String value = parseUserProperty(entry.getValue(), propertyHandler, locale);
                String parsedValue;
                if (propertyHandler instanceof DatePropertyHandler) {
                    parsedValue = formatDbDate(value, locale);
                } else if (propertyHandler instanceof GenderPropertyHandler) {
                    parsedValue = parseGender(value, (GenderPropertyHandler) propertyHandler, locale);
                } else {
                    parsedValue = propertyHandler.getStringValue(value, locale);
                }
                dbUser.setProperty(entry.getName(), parsedValue);
                break;
            }
        }
    }
}
Also used : GenderPropertyHandler(org.olat.user.propertyhandlers.GenderPropertyHandler) UserManager(org.olat.user.UserManager) DatePropertyHandler(org.olat.user.propertyhandlers.DatePropertyHandler) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 8 with GenderPropertyHandler

use of org.olat.user.propertyhandlers.GenderPropertyHandler in project openolat by klemens.

the class UserBulkChangeManager method sendLoginDeniedEmail.

public void sendLoginDeniedEmail(Identity identity) {
    String lang = identity.getUser().getPreferences().getLanguage();
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(lang);
    Translator translator = Util.createPackageTranslator(SystemRolesAndRightsController.class, locale);
    String gender = "";
    UserPropertyHandler handler = userManager.getUserPropertiesConfig().getPropertyHandler(UserConstants.GENDER);
    if (handler instanceof GenderPropertyHandler) {
        String internalGender = ((GenderPropertyHandler) handler).getInternalValue(identity.getUser());
        if (StringHelper.containsNonWhitespace(internalGender)) {
            Translator userPropTrans = userManager.getUserPropertiesConfig().getTranslator(translator);
            gender = userPropTrans.translate("form.name.gender.salutation." + internalGender);
        }
    }
    String email = identity.getUser().getProperty(UserConstants.EMAIL, null);
    email = StringHelper.containsNonWhitespace(email) ? email : "-";
    String[] args = new String[] { // 0: changed users username
    identity.getName(), // 1: changed users email address
    email, // 2: Name (first and last name) of user who changed the password
    userManager.getUserDisplayName(identity.getUser()), // 3: configured support email address
    WebappHelper.getMailConfig("mailSupport"), // 4 last name
    identity.getUser().getProperty(UserConstants.LASTNAME, null), // 5 url system
    getServerURI(), // 6 Mr. Mrs.
    gender };
    MailBundle bundle = new MailBundle();
    bundle.setToId(identity);
    bundle.setContent(translator.translate("mailtemplate.login.denied.subject", args), translator.translate("mailtemplate.login.denied.body", args));
    mailManager.sendExternMessage(bundle, null, false);
}
Also used : Locale(java.util.Locale) Translator(org.olat.core.gui.translator.Translator) GenderPropertyHandler(org.olat.user.propertyhandlers.GenderPropertyHandler) MailBundle(org.olat.core.util.mail.MailBundle) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Aggregations

GenderPropertyHandler (org.olat.user.propertyhandlers.GenderPropertyHandler)8 Translator (org.olat.core.gui.translator.Translator)4 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)4 File (java.io.File)2 Locale (java.util.Locale)2 MailBundle (org.olat.core.util.mail.MailBundle)2 UserManager (org.olat.user.UserManager)2 DatePropertyHandler (org.olat.user.propertyhandlers.DatePropertyHandler)2