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);
}
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;
}
}
}
}
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);
}
Aggregations