use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class UsrPropCfgManager method setUserManagerProperties.
/**
* updates the userManager with our current config
*/
private void setUserManagerProperties() {
UserPropertiesConfigImpl upConfig = new UserPropertiesConfigImpl();
List<UserPropertyHandler> handlers = new ArrayList<UserPropertyHandler>();
for (UserPropertyHandler handler : cfgObject.getPropertyHandlers()) {
if (cfgObject.isActiveHandler(handler))
handlers.add(handler);
}
upConfig.setUserPropertyHandlers(handlers);
upConfig.setUserPropertyUsageContexts(cfgObject.getUsageContexts());
userManager.setUserPropertiesConfig(upConfig);
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class UsrPropContextEditController method buildPropertyHandlerListFromContext.
/**
* builds a List of handlers to display in the table
* (is also invoked when context changes, to update the gui-table)
*/
private void buildPropertyHandlerListFromContext() {
rowToggleButtonsMap = new HashMap<String, List<FormItem>>();
// add form components for each row
List<UserPropertyHandler> handlerList = new ArrayList<UserPropertyHandler>();
// loop over the handlers within this context
for (UserPropertyHandler handler : context.getPropertyHandlers()) {
// final boolean isActive =
// usrPropCfgMng.getUserPropertiesConfigObject().isActiveHandler(handler);
// if (!isActive) continue;
handlerList.add(handler);
addTableRowComponents(handler, true);
}
// now add all propertyHandlers that are not in this context
for (UserPropertyHandler handler : usrPropCfgMng.getUserPropertiesConfigObject().getPropertyHandlers()) {
if (handlerList.contains(handler))
continue;
final boolean isActive = usrPropCfgMng.getUserPropertiesConfigObject().isActiveHandler(handler);
if (!isActive)
continue;
handlerList.add(handler);
addTableRowComponents(handler, false);
}
contTableFlc.contextPut("rows", handlerList);
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.
the class UserSearchFlexiController method doSearch.
public void doSearch() {
String login = loginEl.getValue();
// build user fields search map
Map<String, String> userPropertiesSearch = new HashMap<>();
for (UserPropertyHandler userPropertyHandler : userSearchFormPropertyHandlers) {
if (userPropertyHandler == null)
continue;
FormItem ui = propFormItems.get(userPropertyHandler.getName());
String uiValue = userPropertyHandler.getStringValue(ui);
if (userPropertyHandler.getName().startsWith("genericCheckboxProperty")) {
if (!"false".equals(uiValue)) {
userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
}
} else if (StringHelper.containsNonWhitespace(uiValue)) {
userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
}
}
if (userPropertiesSearch.isEmpty()) {
userPropertiesSearch = null;
}
tableEl.reset();
List<Identity> users = searchUsers(login, userPropertiesSearch, true);
if (!users.isEmpty()) {
userTableModel.setObjects(users);
flc.contextPut("showButton", "true");
} else {
getWindowControl().setInfo(translate("error.no.user.found"));
}
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.
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.UserPropertyHandler in project openolat by klemens.
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());
}
}
Aggregations