Skip to content
Snippets Groups Projects
Commit 6ecb31b9 authored by srosse's avatar srosse
Browse files

OO-222: don't valid email field in search form

parent 9dd2fedf
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,7 @@ import org.olat.core.id.UserConstants;
import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.user.UserManager;
import org.olat.user.propertyhandlers.EmailProperty;
import org.olat.user.propertyhandlers.UserPropertyHandler;
/**
......@@ -393,14 +394,12 @@ class UserSearchForm extends FormBasicController {
protected List<UserPropertyHandler> userPropertyHandlers;
protected Map <String,FormItem>propFormItems;
/**
* @param name
* @param cancelbutton
* @param isAdmin if true, no field must be filled in at all, otherwise
* validation takes place
*/
public UserSearchForm(UserRequest ureq, WindowControl wControl, boolean isAdmin, boolean cancelButton) {
super(ureq, wControl);
......@@ -409,7 +408,6 @@ class UserSearchForm extends FormBasicController {
initForm(ureq);
}
@Override
@SuppressWarnings("unused")
......@@ -417,7 +415,6 @@ class UserSearchForm extends FormBasicController {
// override for admins
if (isAdmin) return true;
boolean filled = !login.isEmpty();
StringBuffer full = new StringBuffer(login.getValue().trim());
FormItem lastFormElement = login;
......@@ -429,16 +426,17 @@ class UserSearchForm extends FormBasicController {
// "this e-mail exists already"
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
FormItem ui = propFormItems.get(userPropertyHandler.getName());
String uiValue = userPropertyHandler.getStringValue(ui);
// add value for later non-empty search check
if (StringHelper.containsNonWhitespace(uiValue)) {
full.append(uiValue.trim());
filled = true;
}else{
//its an empty field
filled = filled || false;
}
lastFormElement = ui;
String uiValue = userPropertyHandler.getStringValue(ui);
// add value for later non-empty search check
if (StringHelper.containsNonWhitespace(uiValue)) {
full.append(uiValue.trim());
filled = true;
}else{
//its an empty field
filled = filled || false;
}
lastFormElement = ui;
}
// Don't allow searches with * or % or @ chars only (wild cards). We don't want
......@@ -464,18 +462,12 @@ class UserSearchForm extends FormBasicController {
return true;
}
@Override
@SuppressWarnings("unused")
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
UserManager um = UserManager.getInstance();
Translator tr = Util.createPackageTranslator(
UserPropertyHandler.class,
getLocale(),
......@@ -494,6 +486,12 @@ class UserSearchForm extends FormBasicController {
getLocale(), null, getClass().getCanonicalName(), false, formLayout
);
fi.setTranslator(tr);
// DO NOT validate email field => see OLAT-3324, OO-155, OO-222
if (userPropertyHandler instanceof EmailProperty && fi instanceof TextElement) {
TextElement textElement = (TextElement)fi;
textElement.setItemValidatorProvider(null);
}
propFormItems.put(userPropertyHandler.getName(), fi);
}
......
......@@ -57,7 +57,7 @@ import org.olat.core.id.Identity;
* Fires a MultiIdentityChoosenEvent when multiples identities have been
* chosen which contains the choosen identities<br>
* <p>
* Optionally set the useMultiSelect boolean to true whcih allows to
* Optionally set the useMultiSelect boolean to true which allows to
* select multiple identities from within the search results.
*/
public class DeletableUserSearchController extends UserSearchController {
......@@ -72,12 +72,13 @@ public class DeletableUserSearchController extends UserSearchController {
* @param userPropertiesSearch
* @return
*/
protected List searchUsers(String login, Map<String, String> userPropertiesSearch, boolean userPropertiesAsIntersectionSearch) {
List users = BaseSecurityManager.getInstance().getVisibleIdentitiesByPowerSearch(
@Override
protected List<Identity> searchUsers(String login, Map<String, String> userPropertiesSearch, boolean userPropertiesAsIntersectionSearch) {
List<Identity> users = BaseSecurityManager.getInstance().getVisibleIdentitiesByPowerSearch(
(login.equals("") ? null : login),
userPropertiesSearch, userPropertiesAsIntersectionSearch, // in normal search fields are intersected
null, null, null, null, null);
List notDeletable = BaseSecurityManager.getInstance().getIdentitiesByPowerSearch(
List<Identity> notDeletable = BaseSecurityManager.getInstance().getIdentitiesByPowerSearch(
(login.equals("") ? null : login),
userPropertiesSearch, userPropertiesAsIntersectionSearch, // in normal search fields are intersected
null, null, null, null, null, null, null,Identity.STATUS_PERMANENT);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment