use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class ShibbolethRegistrationUserPropertiesFrom method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// Add all available user fields to this form
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, USERPROPERTIES_FORM_IDENTIFIER, false, formLayout);
propFormItems.put(userPropertyHandler.getName(), fi);
if (fi instanceof TextElement) {
String value = shibbolethAttributes.getValueForUserPropertyName(userPropertyHandler.getName());
if (StringHelper.containsNonWhitespace(value)) {
TextElement formElement = (TextElement) fi;
formElement.setValue(value);
formElement.setEnabled(false);
}
}
}
}
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("save", buttonLayout);
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class GroupController method reloadData.
public void reloadData() {
// refresh view
List<GroupMembership> combo = groupDao.getMemberships(group, role);
List<GroupMemberView> views = new ArrayList<GroupMemberView>(combo.size());
Map<Long, GroupMemberView> idToViews = new HashMap<Long, GroupMemberView>();
Set<Long> loadStatus = new HashSet<Long>();
for (GroupMembership co : combo) {
Identity identity = co.getIdentity();
Date addedAt = co.getCreationDate();
String onlineStatus = null;
if (chatEnabled) {
if (getIdentity().equals(identity)) {
onlineStatus = "me";
} else if (sessionManager.isOnline(identity.getKey())) {
loadStatus.add(identity.getKey());
} else {
onlineStatus = Presence.unavailable.name();
}
}
GroupMemberView member = new GroupMemberView(identity, addedAt, onlineStatus);
views.add(member);
idToViews.put(identity.getKey(), member);
}
if (loadStatus.size() > 0) {
List<Long> statusToLoadList = new ArrayList<Long>(loadStatus);
Map<Long, String> statusMap = imService.getBuddyStatus(statusToLoadList);
for (Long toLoad : statusToLoadList) {
String status = statusMap.get(toLoad);
GroupMemberView member = idToViews.get(toLoad);
if (status == null) {
member.setOnlineStatus(Presence.available.name());
} else {
member.setOnlineStatus(status);
}
}
}
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
identitiesTableModel = new IdentitiesOfGroupTableDataModel(views, getLocale(), userPropertyHandlers, isAdministrativeUser);
tableCtr.setTableDataModel(identitiesTableModel);
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class CheckListAssessmentController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("coach.desc");
setFormContextHelp("Assessment#_checklist_manage");
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
if (dueDate != null) {
layoutCont.contextPut("dueDate", dueDate);
}
}
FlexiTableSortOptions options = new FlexiTableSortOptions();
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
if (isAdministrativeUser) {
options.setDefaultOrderBy(new SortKey(Cols.username.name(), true));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.username.i18nKey(), Cols.username.ordinal(), true, Cols.username.name()));
}
int i = 0;
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
int colIndex = CheckListAssessmentDataModel.USER_PROPS_OFFSET + i++;
if (userPropertyHandler == null)
continue;
String propName = userPropertyHandler.getName();
boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
if (visible) {
FlexiColumnModel col;
if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName)) {
col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, userPropertyHandler.getName(), true, propName, new StaticFlexiCellRenderer(userPropertyHandler.getName(), new TextFlexiCellRenderer()));
} else {
col = new DefaultFlexiColumnModel(true, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, true, propName);
}
columnsModel.addFlexiColumnModel(col);
if (options.getDefaultOrderBy() == null) {
options.setDefaultOrderBy(new SortKey(propName, true));
}
}
}
int numOfCheckbox = checkboxList.getNumOfCheckbox();
List<Checkbox> boxList = checkboxList.getList();
int j = 0;
for (Checkbox box : boxList) {
int colIndex = CheckListAssessmentDataModel.CHECKBOX_OFFSET + j++;
String colName = "checkbox_" + colIndex;
DefaultFlexiColumnModel column = new DefaultFlexiColumnModel(true, colName, colIndex, true, colName);
column.setHeaderLabel(StringHelper.escapeHtml(box.getTitle()));
columnsModel.addFlexiColumnModel(column);
}
if (withScore) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.totalPoints.i18nKey(), Cols.totalPoints.ordinal(), true, "points"));
}
if (coachCourseEnv.isCourseReadOnly()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.view.checkbox", translate("table.header.view.checkbox"), "view"));
} else {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.edit.checkbox", translate("table.header.edit.checkbox"), "edit"));
}
model = new CheckListAssessmentDataModel(checkboxList, new ArrayList<>(), columnsModel, getLocale());
table = uifactory.addTableElement(getWindowControl(), "checkbox-list", model, getTranslator(), formLayout);
if (coachCourseEnv instanceof UserCourseEnvironmentImpl) {
UserCourseEnvironmentImpl env = (UserCourseEnvironmentImpl) coachCourseEnv;
List<BusinessGroup> coachedGroups = env.getCoachedGroups();
List<FlexiTableFilter> filters = new ArrayList<>(coachedGroups.size() + 1);
filters.add(new FlexiTableFilter(translate("filter.all"), "all"));
for (int k = 0; k < coachedGroups.size(); k++) {
BusinessGroup group = coachedGroups.get(k);
String groupName = StringHelper.escapeHtml(group.getName());
filters.add(new FlexiTableFilter(groupName, group.getKey().toString()));
}
table.setFilters("participants", filters, false);
}
table.setExportEnabled(true);
table.setCustomizeColumns(true);
FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
table.setSortSettings(sortOptions);
table.setAndLoadPersistedPreferences(ureq, "checklist-assessment");
pdfExportButton = uifactory.addFormLink("pdf.export", formLayout, Link.BUTTON);
pdfExportButton.setEnabled(numOfCheckbox > 0);
checkedPdfExportButton = uifactory.addFormLink("pdf.export.checked", formLayout, Link.BUTTON);
checkedPdfExportButton.setEnabled(numOfCheckbox > 0);
editButton = uifactory.addFormLink("edit", formLayout, Link.BUTTON);
editButton.setEnabled(numOfCheckbox > 0);
editButton.setVisible(!coachCourseEnv.isCourseReadOnly());
saveButton = uifactory.addFormSubmitButton("save", formLayout);
saveButton.getComponent().setSpanAsDomReplaceable(true);
saveButton.setVisible(false);
cancelButton = uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
cancelButton.setVisible(false);
boxAssessmentButton = uifactory.addFormLink("box.assessment", formLayout, Link.BUTTON);
boxAssessmentButton.setEnabled(numOfCheckbox > 0);
boxAssessmentButton.setVisible(!coachCourseEnv.isCourseReadOnly());
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class UserPropertyEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String page = Util.getPackageVelocityRoot(this.getClass()) + "/user_prop.html";
String id = Long.toString(CodeHelper.getRAMUniqueID());
FormLayoutContainer userPropCont = FormLayoutContainer.createCustomFormLayout("user.prop.".concat(id), formLayout.getTranslator(), page);
userPropCont.setRootForm(formLayout.getRootForm());
formLayout.add(userPropCont);
userPropCont.getFormItemComponent().contextPut("id", id);
Translator trans = Util.createPackageTranslator(UserPropertyHandler.class, ureq.getLocale(), formLayout.getTranslator());
int numOfProperties = userPropertyHandlers.size();
String[] propKeys = new String[numOfProperties];
String[] propValues = new String[numOfProperties];
for (int i = 0; i < numOfProperties; i++) {
UserPropertyHandler handler = userPropertyHandlers.get(i);
propKeys[i] = handler.getName();
propValues[i] = trans.translate(handler.i18nFormElementLabelKey());
}
String currentPropertyName = null;
String currentPropertyValue = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
currentPropertyName = r.getLeftOperand();
currentPropertyValue = r.getRightOperand();
}
propEl = uifactory.addDropdownSingleselect("user.prop.".concat(id), null, userPropCont, propKeys, propValues, null);
propEl.setDomReplacementWrapperRequired(false);
if (currentPropertyName != null) {
for (String propKey : propKeys) {
if (currentPropertyName.equals(propKey)) {
propEl.select(propKey, true);
}
}
}
valueEl = uifactory.addTextElement("user.value.".concat(id), null, 128, currentPropertyValue, userPropCont);
valueEl.setDomReplacementWrapperRequired(false);
return userPropCont;
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class OrdersAdminController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.status, new OrderStatusRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.orderNr));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.creationDate));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.summary));
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.username));
}
int i = 0;
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
int colIndex = USER_PROPS_OFFSET + i++;
if (userPropertyHandler == null)
continue;
String propName = userPropertyHandler.getName();
boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
FlexiColumnModel col = new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, true, propName);
columnsModel.addFlexiColumnModel(col);
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.methods, new AccessMethodRenderer(acModule)));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.total));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.order.details", translate("select"), CMD_SELECT));
dataSource = new OrdersDataSource(acService, resource, null, userPropertyHandlers);
if (resource == null) {
searchForm = new OrdersSearchForm(ureq, getWindowControl(), mainForm);
listenTo(searchForm);
formLayout.add("searchForm", searchForm.getInitialFormItem());
Calendar cal = CalendarUtils.getStartOfDayCalendar(getLocale());
cal.add(Calendar.MONTH, -1);
searchForm.setFrom(cal.getTime());
dataSource.setFrom(cal.getTime());
}
dataModel = new OrdersDataModel(dataSource, getLocale(), userManager, columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "orderList", dataModel, 25, true, getTranslator(), formLayout);
tableEl.setExportEnabled(true);
List<FlexiTableFilter> filters = new ArrayList<>();
filters.add(new FlexiTableFilter(translate("order.status.new"), OrderStatus.NEW.name()));
filters.add(new FlexiTableFilter(translate("order.status.prepayment"), OrderStatus.PREPAYMENT.name()));
filters.add(new FlexiTableFilter(translate("order.status.payed"), OrderStatus.PAYED.name()));
filters.add(new FlexiTableFilter(translate("order.status.canceled"), OrderStatus.CANCELED.name()));
filters.add(new FlexiTableFilter(translate("order.status.error"), OrderStatus.ERROR.name()));
tableEl.setFilters("", filters, false);
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("title", translate("orders.admin.my"));
layoutCont.contextPut("description", translate("orders.admin.my.desc"));
}
}
Aggregations