Search in sources :

Example 11 with EmailProperty

use of org.olat.user.propertyhandlers.EmailProperty in project openolat by klemens.

the class MemberSearchForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormLayoutContainer leftContainer = FormLayoutContainer.createDefaultFormLayout("left_1", getTranslator());
    leftContainer.setRootForm(mainForm);
    formLayout.add(leftContainer);
    // user property
    login = uifactory.addTextElement("login", "search.login", 128, "", leftContainer);
    login.setDisplaySize(28);
    userPropertyHandlers = userManager.getUserPropertyHandlersFor(getClass().getCanonicalName(), false);
    propFormItems = new HashMap<String, FormItem>();
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, getClass().getCanonicalName(), false, leftContainer);
        fi.setTranslator(this.getTranslator());
        // 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);
        }
        if (fi instanceof TextElement) {
            ((TextElement) fi).setDisplaySize(28);
        }
        propFormItems.put(userPropertyHandler.getName(), fi);
    }
    // others
    FormLayoutContainer rightContainer = FormLayoutContainer.createDefaultFormLayout("right_1", getTranslator());
    rightContainer.setRootForm(mainForm);
    formLayout.add(rightContainer);
    // roles
    String[] roleValues = new String[roleKeys.length];
    for (int i = roleKeys.length; i-- > 0; ) {
        roleValues[i] = translate("search." + roleKeys[i]);
    }
    rolesEl = uifactory.addCheckboxesHorizontal("roles", "search.roles", rightContainer, roleKeys, roleValues);
    for (String roleKey : roleKeys) {
        rolesEl.select(roleKey, true);
    }
    String[] openValues = new String[originKeys.length];
    for (int i = originKeys.length; i-- > 0; ) {
        openValues[i] = translate("search." + originKeys[i]);
    }
    originEl = uifactory.addRadiosHorizontal("openBg", "search.origin", rightContainer, originKeys, openValues);
    originEl.select("all", true);
    FormLayoutContainer buttonLayout = FormLayoutContainer.createDefaultFormLayout("button_layout", getTranslator());
    formLayout.add(buttonLayout);
    searchButton = uifactory.addFormLink("search", buttonLayout, Link.BUTTON);
    searchButton.setCustomEnabledLinkCSS("btn btn-primary");
}
Also used : EmailProperty(org.olat.user.propertyhandlers.EmailProperty) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 12 with EmailProperty

use of org.olat.user.propertyhandlers.EmailProperty in project openolat by klemens.

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);
}
Also used : EmailProperty(org.olat.user.propertyhandlers.EmailProperty) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Aggregations

FormItem (org.olat.core.gui.components.form.flexible.FormItem)12 EmailProperty (org.olat.user.propertyhandlers.EmailProperty)12 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)12 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)10 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)8 ArrayList (java.util.ArrayList)6 Translator (org.olat.core.gui.translator.Translator)4 Identity (org.olat.core.id.Identity)4 Date (java.util.Date)2 HashMap (java.util.HashMap)2 PermissionOnResourceable (org.olat.basesecurity.PermissionOnResourceable)2 SecurityGroup (org.olat.basesecurity.SecurityGroup)2 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)2 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)2 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)2 Roles (org.olat.core.id.Roles)2 RepositoryEntryLifecycle (org.olat.repository.model.RepositoryEntryLifecycle)2