use of org.olat.admin.user.bulkChange.UserBulkChangeManager in project OpenOLAT by OpenOLAT.
the class EmailProperty method addFormItem.
/**
* @see org.olat.user.propertyhandlers.UserPropertyHandler#addFormItem(java.util.Locale, org.olat.core.id.User, java.lang.String, boolean, org.olat.core.gui.components.form.flexible.FormItemContainer)
*/
@Override
public FormItem addFormItem(Locale locale, final User user, String usageIdentifyer, final boolean isAdministrativeUser, FormItemContainer formItemContainer) {
org.olat.core.gui.components.form.flexible.elements.TextElement tElem = null;
tElem = (org.olat.core.gui.components.form.flexible.elements.TextElement) super.addFormItem(locale, user, usageIdentifyer, isAdministrativeUser, formItemContainer);
// to validate the input a special isValidValue is used.
if (usageIdentifyer.equals(UserBulkChangeStep00.class.getCanonicalName())) {
tElem.setItemValidatorProvider(new ItemValidatorProvider() {
@Override
public boolean isValidValue(String value, ValidationError validationError, Locale locale2) {
UserBulkChangeManager ubcMan = CoreSpringFactory.getImpl(UserBulkChangeManager.class);
Context vcContext = new VelocityContext();
if (user == null) {
vcContext = ubcMan.getDemoContext(locale2);
} else // should be used if user-argument !=null --> move to right place
{
Long userKey = user.getKey();
Identity identity = BaseSecurityManager.getInstance().loadIdentityByKey(userKey);
ubcMan.setUserContext(identity, vcContext);
}
value = value.replace("$", "$!");
String evaluatedValue = ubcMan.evaluateValueWithUserContext(value, vcContext);
return EmailProperty.this.isValidValue(user, evaluatedValue, validationError, locale2);
}
});
}
return tElem;
}
use of org.olat.admin.user.bulkChange.UserBulkChangeManager in project openolat by klemens.
the class EmailProperty method addFormItem.
/**
* @see org.olat.user.propertyhandlers.UserPropertyHandler#addFormItem(java.util.Locale, org.olat.core.id.User, java.lang.String, boolean, org.olat.core.gui.components.form.flexible.FormItemContainer)
*/
@Override
public FormItem addFormItem(Locale locale, final User user, String usageIdentifyer, final boolean isAdministrativeUser, FormItemContainer formItemContainer) {
org.olat.core.gui.components.form.flexible.elements.TextElement tElem = null;
tElem = (org.olat.core.gui.components.form.flexible.elements.TextElement) super.addFormItem(locale, user, usageIdentifyer, isAdministrativeUser, formItemContainer);
// to validate the input a special isValidValue is used.
if (usageIdentifyer.equals(UserBulkChangeStep00.class.getCanonicalName())) {
tElem.setItemValidatorProvider(new ItemValidatorProvider() {
@Override
public boolean isValidValue(String value, ValidationError validationError, Locale locale2) {
UserBulkChangeManager ubcMan = CoreSpringFactory.getImpl(UserBulkChangeManager.class);
Context vcContext = new VelocityContext();
if (user == null) {
vcContext = ubcMan.getDemoContext(locale2);
} else // should be used if user-argument !=null --> move to right place
{
Long userKey = user.getKey();
Identity identity = BaseSecurityManager.getInstance().loadIdentityByKey(userKey);
ubcMan.setUserContext(identity, vcContext);
}
value = value.replace("$", "$!");
String evaluatedValue = ubcMan.evaluateValueWithUserContext(value, vcContext);
return EmailProperty.this.isValidValue(user, evaluatedValue, validationError, locale2);
}
});
}
return tElem;
}
Aggregations