use of org.olat.user.propertyhandlers.EmailProperty in project OpenOLAT by OpenOLAT.
the class UserSearchFlexiController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
// insert a autocompleter search
Roles roles = ureq.getUserSession().getRoles();
boolean autoCompleteAllowed = securityModule.isUserAllowedAutoComplete(roles);
boolean ajax = Windows.getWindows(ureq).getWindowManager().isAjaxEnabled();
if (ajax && autoCompleteAllowed) {
// auto complete
String velocityAutoCRoot = Util.getPackageVelocityRoot(FlexiAutoCompleterController.class);
String autoCPage = velocityAutoCRoot + "/autocomplete.html";
autoCompleterContainer = FormLayoutContainer.createCustomFormLayout("autocompletionsearch", getTranslator(), autoCPage);
autoCompleterContainer.setRootForm(mainForm);
layoutCont.add(autoCompleterContainer);
layoutCont.add("autocompletionsearch", autoCompleterContainer);
setupAutoCompleter(ureq, autoCompleterContainer, null, isAdministrativeUser, 60, 3, null);
}
// user search form
backLink = uifactory.addFormLink("btn.back", formLayout);
backLink.setIconLeftCSS("o_icon o_icon_back");
searchFormContainer = FormLayoutContainer.createDefaultFormLayout("usersearchPanel", getTranslator());
searchFormContainer.setRootForm(mainForm);
searchFormContainer.setElementCssClass("o_sel_usersearch_searchform");
searchFormContainer.setFormTitle(translate("header.normal"));
layoutCont.add(searchFormContainer);
layoutCont.add("usersearchPanel", searchFormContainer);
loginEl = uifactory.addTextElement("login", "search.form.login", 128, "", searchFormContainer);
loginEl.setVisible(isAdministrativeUser);
propFormItems = new HashMap<>();
for (UserPropertyHandler userPropertyHandler : userSearchFormPropertyHandlers) {
if (userPropertyHandler == null)
continue;
FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, UserSearchForm.class.getCanonicalName(), false, searchFormContainer);
// 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);
}
FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
buttonGroupLayout.setRootForm(mainForm);
searchFormContainer.add(buttonGroupLayout);
// Don't use submit button, form should not be marked as dirty since this is
// not a configuration form but only a search form (OLAT-5626)
searchButton = uifactory.addFormLink("submit.search", buttonGroupLayout, Link.BUTTON);
layoutCont.contextPut("noList", "false");
layoutCont.contextPut("showButton", "false");
// add the table
FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
int colPos = 0;
if (isAdministrativeUser) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.user.login", colPos++, true, "login"));
}
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
List<UserPropertyHandler> resultingPropertyHandlers = new ArrayList<>();
// followed by the users fields
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
boolean visible = UserManager.getInstance().isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
if (visible) {
resultingPropertyHandlers.add(userPropertyHandler);
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos++, true, userPropertyHandler.getName()));
}
}
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select"));
Translator myTrans = userManager.getPropertyHandlerTranslator(getTranslator());
userTableModel = new UserSearchFlexiTableModel(Collections.<Identity>emptyList(), resultingPropertyHandlers, isAdministrativeUser, getLocale(), tableColumnModel);
tableEl = uifactory.addTableElement(getWindowControl(), "users", userTableModel, 250, false, myTrans, formLayout);
tableEl.setCustomizeColumns(false);
tableEl.setMultiSelect(true);
tableEl.setSelectAllEnable(true);
layoutCont.put("userTable", tableEl.getComponent());
}
}
use of org.olat.user.propertyhandlers.EmailProperty in project OpenOLAT by OpenOLAT.
the class UserSearchForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_user_search_form");
login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
login.setVisible(isAdminProps);
login.setElementCssClass("o_sel_user_search_username");
Translator tr = Util.createPackageTranslator(UserPropertyHandler.class, getLocale(), getTranslator());
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null)
continue;
FormItem fi = userPropertyHandler.addFormItem(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);
}
fi.setElementCssClass("o_sel_user_search_".concat(userPropertyHandler.getName().toLowerCase()));
propFormItems.put(userPropertyHandler.getName(), fi);
}
FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
formLayout.add(buttonGroupLayout);
// Don't use submit button, form should not be marked as dirty since this is
// not a configuration form but only a search form (OLAT-5626)
searchButton = uifactory.addFormLink("submit.search", buttonGroupLayout, Link.BUTTON);
searchButton.setElementCssClass("o_sel_user_search_button");
if (cancelButton) {
uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
}
}
use of org.olat.user.propertyhandlers.EmailProperty in project openolat by klemens.
the class LecturesSearchFormController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
login.setVisible(adminProps);
userPropertyHandlers = userManager.getUserPropertyHandlersFor(PROPS_IDENTIFIER, adminProps);
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, PROPS_IDENTIFIER, false, formLayout);
fi.setMandatory(false);
// 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);
}
}
bulkEl = uifactory.addTextAreaElement("bulk", 4, 72, "", formLayout);
bulkEl.setHelpText(translate("bulk.hint"));
bulkEl.setExampleKey("bulk.example", null);
List<RepositoryEntryLifecycle> cycles = lifecycleDao.loadPublicLifecycle();
String[] dateKeys;
String[] dateValues;
if (cycles.isEmpty()) {
dateKeys = new String[] { "none", "private" };
dateValues = new String[] { translate("dates.none"), translate("dates.private") };
} else {
dateKeys = new String[] { "none", "private", "public" };
dateValues = new String[] { translate("dates.none"), translate("dates.private"), translate("dates.public") };
}
dateTypesEl = uifactory.addRadiosVertical("dates", formLayout, dateKeys, dateValues);
dateTypesEl.select(dateKeys[0], true);
dateTypesEl.addActionListener(FormEvent.ONCHANGE);
List<RepositoryEntryLifecycle> filteredCycles = new ArrayList<>();
for (RepositoryEntryLifecycle cycle : cycles) {
if (cycle.getValidTo() == null) {
filteredCycles.add(cycle);
}
}
String[] publicKeys = new String[filteredCycles.size()];
String[] publicValues = new String[filteredCycles.size()];
int count = 0;
for (RepositoryEntryLifecycle cycle : filteredCycles) {
publicKeys[count] = cycle.getKey().toString();
StringBuilder sb = new StringBuilder(32);
boolean labelAvailable = StringHelper.containsNonWhitespace(cycle.getLabel());
if (labelAvailable) {
sb.append(cycle.getLabel());
}
if (StringHelper.containsNonWhitespace(cycle.getSoftKey())) {
if (labelAvailable)
sb.append(" - ");
sb.append(cycle.getSoftKey());
}
publicValues[count++] = sb.toString();
}
publicDatesEl = uifactory.addDropdownSingleselect("public.dates", formLayout, publicKeys, publicValues, null);
String privateDatePage = velocity_root + "/cycle_dates.html";
privateDatesCont = FormLayoutContainer.createCustomFormLayout("private.date", getTranslator(), privateDatePage);
privateDatesCont.setRootForm(mainForm);
privateDatesCont.setLabel("private.dates", null);
formLayout.add("private.date", privateDatesCont);
startDateEl = uifactory.addDateChooser("date.start", "date.start", null, privateDatesCont);
startDateEl.setElementCssClass("o_sel_repo_lifecycle_validfrom");
endDateEl = uifactory.addDateChooser("date.end", "date.end", null, privateDatesCont);
endDateEl.setElementCssClass("o_sel_repo_lifecycle_validto");
FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonCont);
uifactory.addFormSubmitButton("search", buttonCont);
}
use of org.olat.user.propertyhandlers.EmailProperty in project OpenOLAT by OpenOLAT.
the class UsermanagerUserSearchForm method findIdentitiesFromSearchForm.
/**
* @return List of identities that match the criterias from the search form
*/
private List<Identity> findIdentitiesFromSearchForm() {
// get user attributes from form
String login = searchform.getStringValue("login");
// when searching for deleted users, add wildcard to match with backup prefix
if (searchform.getStatus().equals(Identity.STATUS_DELETED)) {
login = "*" + login;
}
Integer status = null;
// get user fields from form
// build user fields search map
Map<String, String> userPropertiesSearch = new HashMap<String, String>();
for (UserPropertyHandler userPropertyHandler : searchform.getPropertyHandlers()) {
if (userPropertyHandler == null)
continue;
FormItem ui = searchform.getItem(userPropertyHandler.getName());
String uiValue = userPropertyHandler.getStringValue(ui);
if (userPropertyHandler.getName().startsWith("genericCheckboxProperty") && ui instanceof MultipleSelectionElement) {
if (!"false".equals(uiValue)) {
// ignore false for the search
userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
}
} else if (StringHelper.containsNonWhitespace(uiValue)) {
// when searching for deleted users, add wildcard to match with backup prefix
if (userPropertyHandler instanceof EmailProperty && searchform.getStatus().equals(Identity.STATUS_DELETED)) {
uiValue = "*" + uiValue;
}
userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
}
}
if (userPropertiesSearch.isEmpty())
userPropertiesSearch = null;
// get group memberships from form
List<SecurityGroup> groupsList = new ArrayList<SecurityGroup>();
if (searchform.getRole("admin")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN);
groupsList.add(group);
}
if (searchform.getRole("author")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS);
groupsList.add(group);
}
if (searchform.getRole("groupmanager")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_GROUPMANAGERS);
groupsList.add(group);
}
if (searchform.getRole("usermanager")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_USERMANAGERS);
groupsList.add(group);
}
if (searchform.getRole("oresmanager")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_INST_ORES_MANAGER);
groupsList.add(group);
}
if (searchform.getRole("poolmanager")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_POOL_MANAGER);
groupsList.add(group);
}
status = searchform.getStatus();
SecurityGroup[] groups = groupsList.toArray(new SecurityGroup[groupsList.size()]);
// no permissions in this form so far
PermissionOnResourceable[] permissionOnResources = null;
String[] authProviders = searchform.getAuthProviders();
// get date constraints from form
Date createdBefore = searchform.getBeforeDate();
Date createdAfter = searchform.getAfterDate();
Date userLoginBefore = searchform.getUserLoginBefore();
Date userLoginAfter = searchform.getUserLoginAfter();
// now perform power search
List<Identity> myIdentities = securityManager.getIdentitiesByPowerSearch((login.equals("") ? null : login), userPropertiesSearch, true, groups, permissionOnResources, authProviders, createdAfter, createdBefore, userLoginAfter, userLoginBefore, status);
return myIdentities;
}
use of org.olat.user.propertyhandlers.EmailProperty in project OpenOLAT by OpenOLAT.
the class UserSearchForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
login.setVisible(adminProps);
userPropertyHandlers = userManager.getUserPropertyHandlersFor(PROPS_IDENTIFIER, adminProps);
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, getClass().getCanonicalName(), false, formLayout);
fi.setMandatory(false);
// 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);
}
}
statusEl = uifactory.addCheckboxesHorizontal("only.active", formLayout, activeKeys, activeValues);
statusEl.select(activeKeys[0], true);
FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonCont);
uifactory.addFormSubmitButton("search", buttonCont);
}
Aggregations