Search in sources :

Example 31 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class UserModule method checkMandatoryUserProperty.

private void checkMandatoryUserProperty(String userPropertyIdentifyer) {
    List<UserPropertyHandler> propertyHandlers = userPropertiesConfig.getAllUserPropertyHandlers();
    boolean propertyDefined = false;
    for (UserPropertyHandler propertyHandler : propertyHandlers) {
        if (propertyHandler.getName().equals(userPropertyIdentifyer)) {
            propertyDefined = true;
            break;
        }
    }
    if (!propertyDefined) {
        throw new StartupException("The user property handler for the mandatory user property " + userPropertyIdentifyer + " is not defined. Check your olat_userconfig.xml file!");
    }
}
Also used : StartupException(org.olat.core.logging.StartupException) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 32 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class HomePageSettingsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean firstGroup = true;
    List<UserPropertyHandler> homepagePropertyHanders = userManager.getUserPropertyHandlersFor(HomePageConfig.class.getCanonicalName(), isAdministrativeUser);
    Map<String, FormLayoutContainer> groupContainerMap = new HashMap<>();
    HomePageConfig conf = hpcm.loadConfigFor(identityToModify.getName());
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null) {
            continue;
        }
        // add spacer if necessary (i.e. when group name changes)
        String group = userPropertyHandler.getGroup();
        FormLayoutContainer groupContainer;
        if (groupContainerMap.containsKey(group)) {
            groupContainer = groupContainerMap.get(group);
        } else {
            groupContainer = FormLayoutContainer.createDefaultFormLayout("group." + group, getTranslator());
            groupContainer.setFormTitle(translate("form.group." + group));
            formLayout.add(groupContainer);
            groupContainerMap.put(group, groupContainer);
            if (firstGroup) {
                groupContainer.setFormContextHelp("Configuration");
                firstGroup = false;
            }
        }
        if (homepagePropertyHanders.contains(userPropertyHandler)) {
            // add checkbox to container if configured for homepage usage identifier
            String checkboxName = userPropertyHandler.getName();
            MultipleSelectionElement publishCheckbox = uifactory.addCheckboxesHorizontal(checkboxName, userPropertyHandler.i18nFormElementLabelKey(), groupContainer, checkKeys, checkValues);
            boolean isEnabled = conf.isEnabled(userPropertyHandler.getName());
            publishCheckbox.select(checkKeys[0], isEnabled);
            publishCheckbox.setUserObject(userPropertyHandler.getName());
            // Mandatory homepage properties can not be changed by user
            if (userManager.isMandatoryUserProperty(HomePageConfig.class.getCanonicalName(), userPropertyHandler)) {
                publishCheckbox.select(checkKeys[0], true);
                publishCheckbox.setEnabled(false);
            } else {
                publishCheckbox.addActionListener(FormEvent.ONCHANGE);
            }
        }
    }
    String previewPage = velocity_root + "/homepage_preview.html";
    previewContainer = FormLayoutContainer.createCustomFormLayout("preview", getTranslator(), previewPage);
    previewContainer.setFormTitle(translate("tab.preview"));
    previewContainer.setRootForm(mainForm);
    formLayout.add(previewContainer);
    updatePreview(ureq);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) HashMap(java.util.HashMap) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 33 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class CertificatesSelectionDataModel method getValueAt.

@Override
public Object getValueAt(int row, int col) {
    CertificateInfos infos = getObject(row);
    Identity identity = infos.getAssessedIdentity();
    if (col == USERNAME_COL) {
        return identity.getName();
    } else if (col == PASSED_COL) {
        return infos.getPassed();
    } else if (col == SCORE_COL) {
        Float score = infos.getScore();
        return AssessmentHelper.getRoundedScore(score);
    } else if (col >= 0 && col < userPropertyHandlers.size()) {
        UserPropertyHandler handler = userPropertyHandlers.get(col);
        return handler.getUserProperty(identity.getUser(), null);
    }
    return null;
}
Also used : CertificateInfos(org.olat.course.certificate.model.CertificateInfos) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 34 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class CheckedPDFExport method findPropertyIndex.

private int findPropertyIndex(String propertyName, List<UserPropertyHandler> userPropHandlers) {
    int i = 0;
    int index = -1;
    for (UserPropertyHandler userPropertyHandler : userPropHandlers) {
        if (propertyName.equals(userPropertyHandler.getName())) {
            index = i;
            numOfCols++;
        }
        i++;
    }
    return index;
}
Also used : UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 35 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class MemberInfoController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        Controller dpc = new DisplayPortraitController(ureq, getWindowControl(), identity, true, false);
        // auto dispose
        listenTo(dpc);
        layoutCont.put("image", dpc.getInitialComponent());
        layoutCont.contextPut("fullname", StringHelper.escapeHtml(userManager.getUserDisplayName(identity)));
    }
    // user properties
    FormLayoutContainer userPropertiesContainer = FormLayoutContainer.createDefaultFormLayout_6_6("userProperties", getTranslator());
    formLayout.add("userProperties", userPropertiesContainer);
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(getClass().getCanonicalName(), false);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        String value = userPropertyHandler.getUserProperty(identity.getUser(), getLocale());
        String key = userPropertyHandler.i18nFormElementLabelKey();
        if (value == null) {
            value = "";
        }
        uifactory.addStaticTextElement("up_" + propName, key, value, userPropertiesContainer);
    }
    // course informations
    FormLayoutContainer courseInfosContainer = FormLayoutContainer.createDefaultFormLayout_9_3("courseInfos", getTranslator());
    formLayout.add("courseInfos", courseInfosContainer);
    membershipCreationEl = uifactory.addStaticTextElement("firstTime", "course.membership.creation", "", courseInfosContainer);
    if (securityModule.isUserLastVisitVisible(ureq.getUserSession().getRoles())) {
        Formatter formatter = Formatter.getInstance(getLocale());
        String lastVisit = "";
        String numOfVisits = "0";
        if (courseInfos != null) {
            if (courseInfos.getRecentLaunch() != null) {
                lastVisit = formatter.formatDate(courseInfos.getRecentLaunch());
            }
            if (courseInfos.getVisit() >= 0) {
                numOfVisits = Integer.toString(courseInfos.getVisit());
            }
        }
        uifactory.addStaticTextElement("lastTime", "course.lastTime", lastVisit, courseInfosContainer);
        uifactory.addStaticTextElement("numOfVisits", "course.numOfVisits", numOfVisits, courseInfosContainer);
    }
    // links
    if (withLinks) {
        homeLink = uifactory.addFormLink("home", formLayout, Link.BUTTON);
        homeLink.setIconLeftCSS("o_icon o_icon_home");
        formLayout.add("home", homeLink);
        contactLink = uifactory.addFormLink("contact", formLayout, Link.BUTTON);
        contactLink.setIconLeftCSS("o_icon o_icon_mail");
        formLayout.add("contact", contactLink);
        if (repoEntryKey != null) {
            assessmentLink = uifactory.addFormLink("assessment", formLayout, Link.BUTTON);
            assessmentLink.setIconLeftCSS("o_icon o_icon_certificate");
            formLayout.add("assessment", assessmentLink);
        }
    }
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) Formatter(org.olat.core.util.Formatter) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) DisplayPortraitController(org.olat.user.DisplayPortraitController) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) Controller(org.olat.core.gui.control.Controller) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Aggregations

UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)319 Identity (org.olat.core.id.Identity)84 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)74 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)70 ArrayList (java.util.ArrayList)62 FormItem (org.olat.core.gui.components.form.flexible.FormItem)62 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)56 User (org.olat.core.id.User)52 HashMap (java.util.HashMap)40 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)36 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)34 Translator (org.olat.core.gui.translator.Translator)32 Date (java.util.Date)30 UserManager (org.olat.user.UserManager)28 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)24 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)24 File (java.io.File)22 BusinessGroup (org.olat.group.BusinessGroup)22 SortKey (org.olat.core.commons.persistence.SortKey)18 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)18