Search in sources :

Example 31 with UserManager

use of org.olat.user.UserManager in project openolat by klemens.

the class ExtendedIdentitiesTableDataModel method addColumnDescriptors.

/**
 * Add all column descriptors to this table that are available in the table
 * model
 *
 * @param tableCtr
 */
public void addColumnDescriptors(TableController tableCtr, Translator trans) {
    setLocale(trans.getLocale());
    if (isAdministrativeUser) {
        String action = actionEnabled ? COMMAND_SELECTUSER : null;
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.identity.name", colCount++, action, getLocale()));
    }
    UserManager um = UserManager.getInstance();
    // followed by the users fields
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        boolean visible = um.isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
        String action = null;
        if (actionEnabled && i < 2) {
            action = COMMAND_SELECTUSER;
        }
        tableCtr.addColumnDescriptor(visible, userPropertyHandler.getColumnDescriptor(colCount++, action, getLocale()));
    }
    // in the end the last login and creation date
    tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.identity.lastlogin", colCount++, null, getLocale()));
    // creation date at the end, enabled by default
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.identity.creationdate", colCount++, null, getLocale()));
    if (actionEnabled) {
        StaticColumnDescriptor vcd = new StaticColumnDescriptor(COMMAND_VCARD, "table.header.vcard", trans.translate("table.identity.vcard"));
        vcd.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        tableCtr.addColumnDescriptor(vcd);
    }
}
Also used : UserManager(org.olat.user.UserManager) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 32 with UserManager

use of org.olat.user.UserManager in project OpenOLAT by OpenOLAT.

the class CourseHandler method readyToDelete.

@Override
public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
    ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
    String referencesSummary = refM.getReferencesToSummary(entry.getOlatResource(), locale);
    if (referencesSummary != null) {
        Translator translator = Util.createPackageTranslator(RepositoryManager.class, locale);
        errors.setError(translator.translate("details.delete.error.references", new String[] { referencesSummary, entry.getDisplayname() }));
        return false;
    }
    /*
		 * make an archive of the course nodes with valuable data
		 */
    UserManager um = UserManager.getInstance();
    String charset = um.getUserCharset(identity);
    try {
        CourseFactory.archiveCourse(entry.getOlatResource(), charset, locale, identity, roles);
    } catch (CorruptedCourseException e) {
        log.error("The course is corrupted, cannot archive it: " + entry, e);
    }
    return true;
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) Translator(org.olat.core.gui.translator.Translator) UserManager(org.olat.user.UserManager) ReferenceManager(org.olat.resource.references.ReferenceManager)

Example 33 with UserManager

use of org.olat.user.UserManager in project OpenOLAT by OpenOLAT.

the class CountryCodePropertyHandler method addFormItem.

/**
 * @see org.olat.user.propertyhandlers.UserPropertyHandler#addFormItem(java.util.Locale,
 *      org.olat.core.id.User, java.lang.String, boolean,
 *      org.olat.core.gui.components.form.flexible.FormItemContainer)
 */
@Override
public FormItem addFormItem(Locale locale, User user, String usageIdentifyer, boolean isAdministrativeUser, FormItemContainer formItemContainer) {
    String[] allKeys = new String[countryKeys.length + 1];
    System.arraycopy(countryKeys, 0, allKeys, 1, countryKeys.length);
    allKeys[0] = NO_SEL_KEY;
    SingleSelection sse = FormUIFactory.getInstance().addDropdownSingleselect(getName(), i18nFormElementLabelKey(), formItemContainer, allKeys, getTranslatedValues(allKeys, locale), null);
    // make pre-selection of the formItem
    String internalValue = getInternalValue(user);
    if (internalValue == null || internalValue.isEmpty() || NO_SEL_KEY.equals(internalValue)) {
        sse.select(NO_SEL_KEY, true);
    } else if (isValidValue(user, internalValue, null, null) && internalValue != null) {
        sse.select("country.code." + internalValue, true);
    }
    // enable/disable according to settings
    UserManager um = UserManager.getInstance();
    if (um.isUserViewReadOnly(usageIdentifyer, this) && !isAdministrativeUser) {
        sse.setEnabled(false);
    }
    if (um.isMandatoryUserProperty(usageIdentifyer, this)) {
        sse.setMandatory(true);
    }
    return sse;
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) UserManager(org.olat.user.UserManager)

Example 34 with UserManager

use of org.olat.user.UserManager in project OpenOLAT by OpenOLAT.

the class GenericSelectionPropertyHandler method addFormItem.

/**
 * @see org.olat.user.propertyhandlers.UserPropertyHandler#addFormItem(java.util.Locale,
 *      org.olat.core.id.User, java.lang.String, boolean,
 *      org.olat.core.gui.components.form.flexible.FormItemContainer)
 */
@Override
public FormItem addFormItem(Locale locale, User user, String usageIdentifyer, boolean isAdministrativeUser, FormItemContainer formItemContainer) {
    FormItem newItem = null;
    if (isMultiselect) {
        MultipleSelectionElement mse = FormUIFactory.getInstance().addCheckboxesHorizontal(getName(), i18nFormElementLabelKey(), formItemContainer, selectionKeys, getTranslatedValues(selectionKeys, locale));
        for (String sKey : getSelectedKeys(user)) {
            mse.select(sKey, true);
        }
        newItem = mse;
    } else {
        String[] allKeys = new String[selectionKeys.length + 1];
        System.arraycopy(selectionKeys, 0, allKeys, 1, selectionKeys.length);
        allKeys[0] = NO_SEL_KEY;
        SingleSelection sse = FormUIFactory.getInstance().addDropdownSingleselect(getName(), i18nFormElementLabelKey(), formItemContainer, allKeys, getTranslatedValues(allKeys, locale), null);
        // make pre-selection of the formItem
        String internalValue = getInternalValue(user);
        if (isValidValue(user, internalValue, null, null) && internalValue != null)
            sse.select(internalValue, true);
        newItem = sse;
    }
    // enable/disable according to settings
    UserManager um = UserManager.getInstance();
    if (um.isUserViewReadOnly(usageIdentifyer, this) && !isAdministrativeUser) {
        newItem.setEnabled(false);
    }
    if (um.isMandatoryUserProperty(usageIdentifyer, this)) {
        newItem.setMandatory(true);
    }
    return newItem;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) UserManager(org.olat.user.UserManager)

Example 35 with UserManager

use of org.olat.user.UserManager in project OpenOLAT by OpenOLAT.

the class GenderPropertyHandler method addFormItem.

/**
 * @see org.olat.user.propertyhandlers.UserPropertyHandler#addFormItem(java.util.Locale, org.olat.core.id.User, java.lang.String, boolean, org.olat.core.gui.components.form.flexible.FormItemContainer)
 */
@Override
public FormItem addFormItem(Locale locale, User user, String usageIdentifyer, boolean isAdministrativeUser, FormItemContainer formItemContainer) {
    org.olat.core.gui.components.form.flexible.elements.SingleSelection genderElem = null;
    // genderElem = FormUIFactory.getInstance().addDropdownSingleselect(getName(), i18nFormElementLabelKey(), formItemContainer, keys, getTranslatedValues(locale), null);
    genderElem = FormUIFactory.getInstance().addRadiosVertical(getName(), i18nFormElementLabelKey(), formItemContainer, keys, getTranslatedValues(locale));
    String key = user == null ? "-" : getInternalValue(user);
    for (int i = keys.length; i-- > 0; ) {
        if (keys[i].equals(key)) {
            genderElem.select(keys[i], true);
        }
    }
    UserManager um = UserManager.getInstance();
    if (um.isUserViewReadOnly(usageIdentifyer, this) && !isAdministrativeUser) {
        genderElem.setEnabled(false);
    }
    if (um.isMandatoryUserProperty(usageIdentifyer, this)) {
        genderElem.setMandatory(true);
    }
    return genderElem;
}
Also used : UserManager(org.olat.user.UserManager)

Aggregations

UserManager (org.olat.user.UserManager)64 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)22 Locale (java.util.Locale)12 Identity (org.olat.core.id.Identity)12 Date (java.util.Date)10 FormItem (org.olat.core.gui.components.form.flexible.FormItem)10 Translator (org.olat.core.gui.translator.Translator)10 User (org.olat.core.id.User)10 ArrayList (java.util.ArrayList)8 File (java.io.File)6 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)6 RestSecurityHelper.getLocale (org.olat.restapi.security.RestSecurityHelper.getLocale)6 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 ValidationError (org.olat.core.gui.components.form.ValidationError)4 SelectionElement (org.olat.core.gui.components.form.flexible.elements.SelectionElement)4 ItemValidatorProvider (org.olat.core.gui.components.form.flexible.impl.elements.ItemValidatorProvider)4 AssertException (org.olat.core.logging.AssertException)4 ICourse (org.olat.course.ICourse)4 RestSecurityHelper.isUserManager (org.olat.restapi.security.RestSecurityHelper.isUserManager)4