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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations